]> xenbits.xensource.com Git - libvirt.git/commitdiff
storage: Check if provided parent is vHBA capable
authorJohn Ferlan <jferlan@redhat.com>
Thu, 20 Jul 2017 15:14:46 +0000 (11:14 -0400)
committerJohn Ferlan <jferlan@redhat.com>
Mon, 24 Jul 2017 16:27:41 +0000 (12:27 -0400)
https://bugzilla.redhat.com/show_bug.cgi?id=1458708

If the parent provided for the storage pool adapter is not vHBA
capable, then issue a configuration error even though the provided
wwnn/wwpn were found.

It is a configuration error to provide a mismatched parent to
the wwnn/wwpn. The @parent is optional and is used as a means to
perform duplicate pool source checks.

src/storage/storage_backend_scsi.c

index 359d2d2597396c74e273e4997e39c5bab688842c..af12889cdff81d18b5c390e0fde7262aba647aff 100644 (file)
@@ -220,6 +220,7 @@ checkParent(virConnectPtr conn,
             const char *name,
             const char *parent_name)
 {
+    unsigned int host_num;
     char *scsi_host_name = NULL;
     char *vhba_parent = NULL;
     bool retval = false;
@@ -230,6 +231,20 @@ checkParent(virConnectPtr conn,
     if (!conn)
         return true;
 
+    if (virSCSIHostGetNumber(parent_name, &host_num) < 0) {
+        virReportError(VIR_ERR_XML_ERROR,
+                       _("parent '%s' is not properly formatted"),
+                       parent_name);
+        goto cleanup;
+    }
+
+    if (!virVHBAPathExists(NULL, host_num)) {
+        virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
+                       _("parent '%s' is not an fc_host for the wwnn/wwpn"),
+                       parent_name);
+        goto cleanup;
+    }
+
     if (virAsprintf(&scsi_host_name, "scsi_%s", name) < 0)
         goto cleanup;