From f7237d63e8f02f3689f9b63b413fae7d4221faa9 Mon Sep 17 00:00:00 2001 From: John Ferlan Date: Thu, 20 Jul 2017 11:14:46 -0400 Subject: [PATCH] storage: Check if provided parent is vHBA capable 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 | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/storage/storage_backend_scsi.c b/src/storage/storage_backend_scsi.c index 359d2d2597..af12889cdf 100644 --- a/src/storage/storage_backend_scsi.c +++ b/src/storage/storage_backend_scsi.c @@ -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; -- 2.39.5