From nobody Fri May 16 03:17:39 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1500580146536150.6873665555894; Thu, 20 Jul 2017 12:49:06 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 09369806A8; Thu, 20 Jul 2017 19:49:05 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id CF66517B82; Thu, 20 Jul 2017 19:49:04 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 8753F41F76; Thu, 20 Jul 2017 19:49:04 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id v6KJmstl016258 for ; Thu, 20 Jul 2017 15:48:54 -0400 Received: by smtp.corp.redhat.com (Postfix) id D563D4DA23; Thu, 20 Jul 2017 19:48:54 +0000 (UTC) Received: from localhost.localdomain.com (ovpn-117-46.phx2.redhat.com [10.3.117.46]) by smtp.corp.redhat.com (Postfix) with ESMTP id 98BA058824 for ; Thu, 20 Jul 2017 19:48:54 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 09369806A8 Authentication-Results: ext-mx02.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx02.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=libvir-list-bounces@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 09369806A8 From: John Ferlan To: libvir-list@redhat.com Date: Thu, 20 Jul 2017 15:48:49 -0400 Message-Id: <20170720194849.8539-5-jferlan@redhat.com> In-Reply-To: <20170720194849.8539-1-jferlan@redhat.com> References: <20170720194849.8539-1-jferlan@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH v3 4/4] storage: Disallow usage of the HBA for a fc_host backing X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.26]); Thu, 20 Jul 2017 19:49:05 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Disallow providing the wwnn/wwpn of the HBA in the adapter XML: This should be considered a configuration error since a vHBA would not be created. In order to use the HBA as the backing the following XML should be used: This also alters the caller such that the @parent_name param into checkParent can be NULL so as to confirm that at least the provided wwnn/wwpn found a vHBA instead of an HBA. Signed-off-by: John Ferlan --- docs/formatstorage.html.in | 27 +++++++++++++---------- src/storage/storage_backend_scsi.c | 45 ++++++++++++++++++++++++++++------= ---- 2 files changed, 49 insertions(+), 23 deletions(-) diff --git a/docs/formatstorage.html.in b/docs/formatstorage.html.in index 4946ddf..27578e8 100644 --- a/docs/formatstorage.html.in +++ b/docs/formatstorage.html.in @@ -207,18 +207,21 @@
wwnn and wwpn
-
The "World Wide Node Name" (wwnn) and "World Wi= de - Port Name" (wwpn) are used by the "fc_host" adapt= er - to uniquely identify the device in the Fibre Channel storage f= abric - (the device can be either a HBA or vHBA). Both wwnn and wwpn s= hould - be specified. Use the command 'virsh nodedev-dumpxml' to deter= mine - how to set the values for the wwnn/wwpn of a (v)HBA. The wwnn = and - wwpn have very specific numerical format requirements based on= the - hypervisor being used, thus care should be taken if you decide= to - generate your own to follow the standards; otherwise, the pool - will fail to start with an opaque error message indicating fai= lure - to write to the vport_create file during vport create/delete d= ue - to "No such file or directory". +
The required "World Wide Node Name" (wwnn) and + "World Wide Port Name" (wwpn) are used by the + "fc_host" adapter to uniquely identify the vHBA device in the + Fibre Channel storage fabric. If the vHBA device already exists + as a Node Device, then libvirt will use it; otherwise, the vHBA + will be created using the provided values. It is considered a + configuration error use the values from the HBA as those would + be for a "scsi_host" type pool instead. The + wwnn and wwpn have very specific + format requirements based on the hypervisor being used, thus + care should be taken if you decide to generate your own to + follow the standards; otherwise, the pool will fail to start + with an opaque error message indicating failure to write to + the vport_create file during vport create/delete due to + "No such file or directory". Since 1.0.4
diff --git a/src/storage/storage_backend_scsi.c b/src/storage/storage_backe= nd_scsi.c index af12889..c802738 100644 --- a/src/storage/storage_backend_scsi.c +++ b/src/storage/storage_backend_scsi.c @@ -231,22 +231,47 @@ checkParent(virConnectPtr conn, if (!conn) return true; =20 - if (virSCSIHostGetNumber(parent_name, &host_num) < 0) { - virReportError(VIR_ERR_XML_ERROR, - _("parent '%s' is not properly formatted"), - parent_name); + /* If there's a parent_name, then make sure it's valid */ + if (parent_name) { + 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/w= wpn"), + parent_name); + goto cleanup; + } + } + + if (virAsprintf(&scsi_host_name, "scsi_%s", name) < 0) + goto cleanup; + + if (virSCSIHostGetNumber(scsi_host_name, &host_num) < 0) { + virReportError(VIR_ERR_INTERNAL_ERROR, + _("host name '%s' is not properly formatted"), + name); goto cleanup; } =20 - if (!virVHBAPathExists(NULL, host_num)) { + /* If scsi_host_name is vport capable, then it's an HBA. This is + * a configuration error as the wwnn/wwpn should only be for a vHBA */ + if (virVHBAIsVportCapable(NULL, host_num)) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, - _("parent '%s' is not an fc_host for the wwnn/wwpn"= ), - parent_name); + _("the wwnn/wwpn for '%s' are assigned to an HBA"), + scsi_host_name); goto cleanup; } =20 - if (virAsprintf(&scsi_host_name, "scsi_%s", name) < 0) + /* No parent name, then no need to get/compare against vhba_parent */ + if (!parent_name) { + retval =3D true; goto cleanup; + } =20 if (!(vhba_parent =3D virNodeDeviceGetParentName(conn, scsi_host_name)= )) goto cleanup; @@ -288,9 +313,7 @@ createVport(virConnectPtr conn, * this pool and we don't have to create the vHBA */ if ((name =3D virVHBAGetHostByWWN(NULL, fchost->wwnn, fchost->wwpn))) { - /* If a parent was provided, let's make sure the 'name' we've - * retrieved has the same parent. If not this will cause failure. = */ - if (!fchost->parent || checkParent(conn, name, fchost->parent)) + if (checkParent(conn, name, fchost->parent)) ret =3D 0; =20 goto cleanup; --=20 2.9.4 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list