render / rpms / libvirt

Forked from rpms/libvirt 9 months ago
Clone
9119d9
From 8df8488b6c87026be4048930772a0c81ca30b0d1 Mon Sep 17 00:00:00 2001
9119d9
Message-Id: <8df8488b6c87026be4048930772a0c81ca30b0d1@dist-git>
9119d9
From: John Ferlan <jferlan@redhat.com>
9119d9
Date: Wed, 12 Nov 2014 13:34:46 -0500
9119d9
Subject: [PATCH] storage: Check for valid fc_host parent at startup
9119d9
9119d9
https://bugzilla.redhat.com/show_bug.cgi?id=1160565
9119d9
9119d9
If a 'parent' attribute is provided for the fchost, then at startup
9119d9
time check to ensure it is a vport capable scsi_host. If the parent
9119d9
is not vport capable, then disallow the startup. The following is the
9119d9
expected results:
9119d9
9119d9
error: Failed to start pool fc_pool
9119d9
error: XML error: parent 'scsi_host2' specified for vHBA is not vport capable
9119d9
9119d9
where the XML for the fc_pool is:
9119d9
9119d9
    <pool type='scsi'>
9119d9
      <name>fc_pool</name>
9119d9
      <source>
9119d9
        <adapter type='fc_host' parent='scsi_host2' wwnn='5001a4aaf3ca174b' wwpn='5001a4a77192b864'/>
9119d9
      </source>
9119d9
...
9119d9
9119d9
and 'scsi_host2' is not vport capable.
9119d9
9119d9
Providing an incorrect parent and a correct wwnn/wwpn could lead to
9119d9
failures at shutdown (deleteVport) where the assumption is the parent
9119d9
is for the fchost.
9119d9
9119d9
NOTE: If the provided wwnn/wwpn doesn't resolve to an existing scsi_host,
9119d9
      then we will be creating one with code (virManageVport) which
9119d9
      assumes the parent is vport capable.
9119d9
9119d9
Signed-off-by: John Ferlan <jferlan@redhat.com>
9119d9
(cherry picked from commit 844c1d7e3283be652bffddf17254c392d68c405d)
9119d9
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
9119d9
---
9119d9
 src/storage/storage_backend_scsi.c | 33 ++++++++++++++++++++++++---------
9119d9
 1 file changed, 24 insertions(+), 9 deletions(-)
9119d9
9119d9
diff --git a/src/storage/storage_backend_scsi.c b/src/storage/storage_backend_scsi.c
9119d9
index 02160bc..88928c9 100644
9119d9
--- a/src/storage/storage_backend_scsi.c
9119d9
+++ b/src/storage/storage_backend_scsi.c
9119d9
@@ -556,6 +556,20 @@ createVport(virStoragePoolSourceAdapter adapter)
9119d9
     if (adapter.type != VIR_STORAGE_POOL_SOURCE_ADAPTER_TYPE_FC_HOST)
9119d9
         return 0;
9119d9
 
9119d9
+    /* If a parent was provided, then let's make sure it's vhost capable */
9119d9
+    if (adapter.data.fchost.parent) {
9119d9
+        if (virGetSCSIHostNumber(adapter.data.fchost.parent, &parent_host) < 0)
9119d9
+            return -1;
9119d9
+
9119d9
+        if (!virIsCapableFCHost(NULL, parent_host)) {
9119d9
+            virReportError(VIR_ERR_XML_ERROR,
9119d9
+                           _("parent '%s' specified for vHBA "
9119d9
+                             "is not vport capable"),
9119d9
+                           adapter.data.fchost.parent);
9119d9
+            return -1;
9119d9
+        }
9119d9
+    }
9119d9
+
9119d9
     /* This filters either HBA or already created vHBA */
9119d9
     if ((name = virGetFCHostNameByWWN(NULL, adapter.data.fchost.wwnn,
9119d9
                                       adapter.data.fchost.wwpn))) {
9119d9
@@ -563,16 +577,17 @@ createVport(virStoragePoolSourceAdapter adapter)
9119d9
         return 0;
9119d9
     }
9119d9
 
9119d9
-    if (!adapter.data.fchost.parent &&
9119d9
-        !(adapter.data.fchost.parent = virFindFCHostCapableVport(NULL))) {
9119d9
-         virReportError(VIR_ERR_XML_ERROR, "%s",
9119d9
-                       _("'parent' for vHBA not specified, and "
9119d9
-                         "cannot find one on this host"));
9119d9
-         return -1;
9119d9
-    }
9119d9
+    if (!adapter.data.fchost.parent) {
9119d9
+        if (!(adapter.data.fchost.parent = virFindFCHostCapableVport(NULL))) {
9119d9
+            virReportError(VIR_ERR_XML_ERROR, "%s",
9119d9
+                           _("'parent' for vHBA not specified, and "
9119d9
+                             "cannot find one on this host"));
9119d9
+            return -1;
9119d9
+        }
9119d9
 
9119d9
-    if (virGetSCSIHostNumber(adapter.data.fchost.parent, &parent_host) < 0)
9119d9
-        return -1;
9119d9
+        if (virGetSCSIHostNumber(adapter.data.fchost.parent, &parent_host) < 0)
9119d9
+            return -1;
9119d9
+    }
9119d9
 
9119d9
     if (virManageVport(parent_host, adapter.data.fchost.wwpn,
9119d9
                        adapter.data.fchost.wwnn, VPORT_CREATE) < 0)
9119d9
-- 
9119d9
2.1.3
9119d9