From nobody Sun Apr 28 21:47:40 2024 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 1500580146535343.94321377511164; Thu, 20 Jul 2017 12:49:06 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id EC77879700; Thu, 20 Jul 2017 19:49:04 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id C8D0A179E9; 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 838011853E30; 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 v6KJmrog016243 for ; Thu, 20 Jul 2017 15:48:53 -0400 Received: by smtp.corp.redhat.com (Postfix) id B0DA258824; Thu, 20 Jul 2017 19:48:53 +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 728AA4DA23 for ; Thu, 20 Jul 2017 19:48:53 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com EC77879700 Authentication-Results: ext-mx01.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx01.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 EC77879700 From: John Ferlan To: libvir-list@redhat.com Date: Thu, 20 Jul 2017 15:48:46 -0400 Message-Id: <20170720194849.8539-2-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 1/4] storage: Fix existing parent check for vHBA creation 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.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.25]); Thu, 20 Jul 2017 19:49:05 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" https://bugzilla.redhat.com/show_bug.cgi?id=3D1472277 Commit id '106930aaa' altered the order of checking for an existing vHBA (e.g something created via nodedev-create functionality outside of the storage pool logic) which inadvertantly broke the code to decide whether to alter/force the fchost->managed field to be 'yes' because the storage pool will be managing the created vHBA in order to ensure when the storage pool is destroyed that the vHBA is also destroyed. This patch moves the check (and checkParent helper) for an existing vHBA back into the createVport in storage_backend_scsi. It also adjusts the checkParent logic to more closely follow the intentions prior to commit id '79ab0935'. The changes made by commit id '08c0ea16f' are only necessary to run the virStoragePoolFCRefreshThread when a vHBA was really created because there's a timing lag such that the refreshPool call made after a startPool from storagePoolCreate* wouldn't necessarily find LUNs, but the thread would. For an already existing vHBA, using the thread is unnecessary since the vHBA already exists and the lag to configure the LUNs wouldn't exist. Signed-off-by: John Ferlan --- src/conf/node_device_conf.c | 55 ----------------------------------= ---- src/storage/storage_backend_scsi.c | 54 ++++++++++++++++++++++++++++++++++= +++ 2 files changed, 54 insertions(+), 55 deletions(-) diff --git a/src/conf/node_device_conf.c b/src/conf/node_device_conf.c index 503b129..9c0ffa5 100644 --- a/src/conf/node_device_conf.c +++ b/src/conf/node_device_conf.c @@ -2259,48 +2259,6 @@ virNodeDeviceGetParentName(virConnectPtr conn, } =20 =20 -/* - * Using the host# name found via wwnn/wwpn lookup in the fc_host - * sysfs tree to get the parent 'scsi_host#' to ensure it matches. - */ -static bool -checkParent(virConnectPtr conn, - const char *name, - const char *parent_name) -{ - char *scsi_host_name =3D NULL; - char *vhba_parent =3D NULL; - bool retval =3D false; - - VIR_DEBUG("conn=3D%p, name=3D%s, parent_name=3D%s", conn, name, parent= _name); - - /* autostarted pool - assume we're OK */ - if (!conn) - return true; - - if (virAsprintf(&scsi_host_name, "scsi_%s", name) < 0) - goto cleanup; - - if (!(vhba_parent =3D virNodeDeviceGetParentName(conn, scsi_host_name)= )) - goto cleanup; - - if (STRNEQ(parent_name, vhba_parent)) { - virReportError(VIR_ERR_XML_ERROR, - _("Parent attribute '%s' does not match parent '%s'= " - "determined for the '%s' wwnn/wwpn lookup."), - parent_name, vhba_parent, name); - goto cleanup; - } - - retval =3D true; - - cleanup: - VIR_FREE(vhba_parent); - VIR_FREE(scsi_host_name); - return retval; -} - - /** * @conn: Connection pointer * @fchost: Pointer to vHBA adapter @@ -2326,19 +2284,6 @@ virNodeDeviceCreateVport(virConnectPtr conn, VIR_DEBUG("conn=3D%p, parent=3D'%s', wwnn=3D'%s' wwpn=3D'%s'", conn, NULLSTR(fchost->parent), fchost->wwnn, fchost->wwpn); =20 - /* If we find an existing HBA/vHBA within the fc_host sysfs - * using the wwnn/wwpn, then a nodedev is already created for - * 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)) - VIR_FREE(name); - - return name; - } - if (fchost->parent) { if (VIR_STRDUP(parent_hoststr, fchost->parent) < 0) goto cleanup; diff --git a/src/storage/storage_backend_scsi.c b/src/storage/storage_backe= nd_scsi.c index f7378d3..e6aa643 100644 --- a/src/storage/storage_backend_scsi.c +++ b/src/storage/storage_backend_scsi.c @@ -211,6 +211,48 @@ getAdapterName(virStorageAdapterPtr adapter) } =20 =20 +/* + * Using the host# name found via wwnn/wwpn lookup in the fc_host + * sysfs tree to get the parent 'scsi_host#' to ensure it matches. + */ +static bool +checkParent(virConnectPtr conn, + const char *name, + const char *parent_name) +{ + char *scsi_host_name =3D NULL; + char *vhba_parent =3D NULL; + bool retval =3D false; + + VIR_DEBUG("conn=3D%p, name=3D%s, parent_name=3D%s", conn, name, parent= _name); + + /* autostarted pool - assume we're OK */ + if (!conn) + return true; + + if (virAsprintf(&scsi_host_name, "scsi_%s", name) < 0) + goto cleanup; + + if (!(vhba_parent =3D virNodeDeviceGetParentName(conn, scsi_host_name)= )) + goto cleanup; + + if (STRNEQ(parent_name, vhba_parent)) { + virReportError(VIR_ERR_XML_ERROR, + _("Parent attribute '%s' does not match parent '%s'= " + "determined for the '%s' wwnn/wwpn lookup."), + parent_name, vhba_parent, name); + goto cleanup; + } + + retval =3D true; + + cleanup: + VIR_FREE(vhba_parent); + VIR_FREE(scsi_host_name); + return retval; +} + + static int createVport(virConnectPtr conn, virStoragePoolDefPtr def, @@ -226,6 +268,18 @@ createVport(virConnectPtr conn, conn, NULLSTR(configFile), NULLSTR(fchost->parent), fchost->wwnn, fchost->wwpn); =20 + /* If we find an existing HBA/vHBA within the fc_host sysfs + * using the wwnn/wwpn, then a nodedev is already created for + * 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)) + ret =3D 0; + + goto cleanup; + } =20 /* Since we're creating the vHBA, then we need to manage removing it * as well. Since we need this setting to "live" through a libvirtd --=20 2.9.4 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Sun Apr 28 21:47:40 2024 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 15005801495461011.7213622196386; Thu, 20 Jul 2017 12:49:09 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 340192C1557; Thu, 20 Jul 2017 19:49:08 +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 076CE82062; Thu, 20 Jul 2017 19:49:08 +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 B40543FADE; Thu, 20 Jul 2017 19:49:07 +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 v6KJms8N016248 for ; Thu, 20 Jul 2017 15:48:54 -0400 Received: by smtp.corp.redhat.com (Postfix) id 186ED4DA23; 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 D18AB58824 for ; Thu, 20 Jul 2017 19:48:53 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 340192C1557 Authentication-Results: ext-mx10.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx10.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 340192C1557 From: John Ferlan To: libvir-list@redhat.com Date: Thu, 20 Jul 2017 15:48:47 -0400 Message-Id: <20170720194849.8539-3-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 2/4] storage: Remove @conn from virNodeDeviceCreateVport 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.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.39]); Thu, 20 Jul 2017 19:49:08 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" It's no longer needed since the checkParent code moved back to storage_backend_scsi.c Signed-off-by: John Ferlan --- src/conf/node_device_conf.c | 8 +++----- src/conf/node_device_conf.h | 3 +-- src/storage/storage_backend_scsi.c | 2 +- 3 files changed, 5 insertions(+), 8 deletions(-) diff --git a/src/conf/node_device_conf.c b/src/conf/node_device_conf.c index 9c0ffa5..82f02fa 100644 --- a/src/conf/node_device_conf.c +++ b/src/conf/node_device_conf.c @@ -2260,7 +2260,6 @@ virNodeDeviceGetParentName(virConnectPtr conn, =20 =20 /** - * @conn: Connection pointer * @fchost: Pointer to vHBA adapter * * Create a vHBA for Storage. This code accomplishes this via searching @@ -2273,16 +2272,15 @@ virNodeDeviceGetParentName(virConnectPtr conn, * Returns vHBA name on success, NULL on failure with an error message set */ char * -virNodeDeviceCreateVport(virConnectPtr conn, - virStorageAdapterFCHostPtr fchost) +virNodeDeviceCreateVport(virStorageAdapterFCHostPtr fchost) { unsigned int parent_host; char *name =3D NULL; char *parent_hoststr =3D NULL; bool skip_capable_check =3D false; =20 - VIR_DEBUG("conn=3D%p, parent=3D'%s', wwnn=3D'%s' wwpn=3D'%s'", - conn, NULLSTR(fchost->parent), fchost->wwnn, fchost->wwpn); + VIR_DEBUG("parent=3D'%s', wwnn=3D'%s' wwpn=3D'%s'", + NULLSTR(fchost->parent), fchost->wwnn, fchost->wwpn); =20 if (fchost->parent) { if (VIR_STRDUP(parent_hoststr, fchost->parent) < 0) diff --git a/src/conf/node_device_conf.h b/src/conf/node_device_conf.h index d10683d..da56eaf 100644 --- a/src/conf/node_device_conf.h +++ b/src/conf/node_device_conf.h @@ -384,8 +384,7 @@ virNodeDeviceGetParentName(virConnectPtr conn, const char *nodedev_name); =20 char * -virNodeDeviceCreateVport(virConnectPtr conn, - virStorageAdapterFCHostPtr fchost); +virNodeDeviceCreateVport(virStorageAdapterFCHostPtr fchost); =20 int virNodeDeviceDeleteVport(virConnectPtr conn, diff --git a/src/storage/storage_backend_scsi.c b/src/storage/storage_backe= nd_scsi.c index e6aa643..359d2d2 100644 --- a/src/storage/storage_backend_scsi.c +++ b/src/storage/storage_backend_scsi.c @@ -294,7 +294,7 @@ createVport(virConnectPtr conn, } } =20 - if (!(name =3D virNodeDeviceCreateVport(conn, fchost))) + if (!(name =3D virNodeDeviceCreateVport(fchost))) goto cleanup; =20 /* Creating our own VPORT didn't leave enough time to find any LUN's, --=20 2.9.4 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Sun Apr 28 21:47:40 2024 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 1500580141268145.31743179120417; Thu, 20 Jul 2017 12:49:01 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id CB1E0336F22; Thu, 20 Jul 2017 19:48:59 +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 A6D4518AAB; Thu, 20 Jul 2017 19:48:59 +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 446E44A491; Thu, 20 Jul 2017 19:48:59 +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 v6KJmsVG016253 for ; Thu, 20 Jul 2017 15:48:54 -0400 Received: by smtp.corp.redhat.com (Postfix) id 772B04DA23; 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 3C2095885E for ; Thu, 20 Jul 2017 19:48:54 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com CB1E0336F22 Authentication-Results: ext-mx09.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx09.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 CB1E0336F22 From: John Ferlan To: libvir-list@redhat.com Date: Thu, 20 Jul 2017 15:48:48 -0400 Message-Id: <20170720194849.8539-4-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 3/4] storage: Check if provided parent is vHBA capable 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.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.38]); Thu, 20 Jul 2017 19:49:00 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" https://bugzilla.redhat.com/show_bug.cgi?id=3D1458708 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. Signed-off-by: John Ferlan --- 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_backe= nd_scsi.c index 359d2d2..af12889 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 =3D NULL; char *vhba_parent =3D NULL; bool retval =3D false; @@ -230,6 +231,20 @@ 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); + 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; =20 --=20 2.9.4 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Sun Apr 28 21:47:40 2024 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