From nobody Fri Mar 29 15:13:27 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.zoho.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 1499107946433210.5832080042951; Mon, 3 Jul 2017 11:52:26 -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 DB48BE3DFF; Mon, 3 Jul 2017 18:52:24 +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 A07A55D9C9; Mon, 3 Jul 2017 18:52:24 +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 B849E4A493; Mon, 3 Jul 2017 18:52:23 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id v63IqAjJ026662 for ; Mon, 3 Jul 2017 14:52:10 -0400 Received: by smtp.corp.redhat.com (Postfix) id 62AD360470; Mon, 3 Jul 2017 18:52:10 +0000 (UTC) Received: from localhost.localdomain.com (ovpn-116-36.phx2.redhat.com [10.3.116.36]) by smtp.corp.redhat.com (Postfix) with ESMTP id 2A916600CC for ; Mon, 3 Jul 2017 18:52:10 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com DB48BE3DFF 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 DB48BE3DFF From: John Ferlan To: libvir-list@redhat.com Date: Mon, 3 Jul 2017 14:52:05 -0400 Message-Id: <20170703185206.23237-2-jferlan@redhat.com> In-Reply-To: <20170703185206.23237-1-jferlan@redhat.com> References: <20170703185206.23237-1-jferlan@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 1/2] storage: Alter check for default managed setting 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.38]); Mon, 03 Jul 2017 18:52:25 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Only alter the managed setting if it wasn't provided. If someone provided 'no', then honor that rather than overwriting. Signed-off-by: John Ferlan --- src/storage/storage_backend_scsi.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/storage/storage_backend_scsi.c b/src/storage/storage_backe= nd_scsi.c index f7378d3..f3e62fb 100644 --- a/src/storage/storage_backend_scsi.c +++ b/src/storage/storage_backend_scsi.c @@ -227,12 +227,12 @@ createVport(virConnectPtr conn, fchost->wwnn, fchost->wwpn); =20 =20 - /* Since we're creating the vHBA, then we need to manage removing it + /* Since we're creating the vHBA, then we may need to manage removing = it * as well. Since we need this setting to "live" through a libvirtd * restart, we need to save the persistent configuration. So if not - * already defined as YES, then force the issue. + * already defined as YES or NO, then force the issue. */ - if (fchost->managed !=3D VIR_TRISTATE_BOOL_YES) { + if (fchost->managed =3D=3D VIR_TRISTATE_BOOL_ABSENT) { fchost->managed =3D VIR_TRISTATE_BOOL_YES; if (configFile) { if (virStoragePoolSaveConfig(configFile, def) < 0) --=20 2.9.4 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Fri Mar 29 15:13:27 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.zoho.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 1499107951015127.92469500051652; Mon, 3 Jul 2017 11:52:31 -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 6EA9BE3E09; Mon, 3 Jul 2017 18:52:29 +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 4AF145D96A; Mon, 3 Jul 2017 18:52:29 +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 096B141F78; Mon, 3 Jul 2017 18:52:29 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id v63IqAtL026667 for ; Mon, 3 Jul 2017 14:52:10 -0400 Received: by smtp.corp.redhat.com (Postfix) id BA86160470; Mon, 3 Jul 2017 18:52:10 +0000 (UTC) Received: from localhost.localdomain.com (ovpn-116-36.phx2.redhat.com [10.3.116.36]) by smtp.corp.redhat.com (Postfix) with ESMTP id 83650600CC for ; Mon, 3 Jul 2017 18:52:10 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 6EA9BE3E09 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 6EA9BE3E09 From: John Ferlan To: libvir-list@redhat.com Date: Mon, 3 Jul 2017 14:52:06 -0400 Message-Id: <20170703185206.23237-3-jferlan@redhat.com> In-Reply-To: <20170703185206.23237-1-jferlan@redhat.com> References: <20170703185206.23237-1-jferlan@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 2/2] conf: Fix vHBA checkParent logic for pool 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.38]); Mon, 03 Jul 2017 18:52:30 +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 When originally designed in commit id '42a021c1', providing the 'parent' attribute to the was checked to make sure that the "parent" of the wwnn/wwpn matched that of the provided parent "just in case" someone created the node device first, then defined the storage pool using that node device afterwards. The result is to not perform the vport_create call when the scsi_host represented by the wwnn/wwpn already exists since it would fail. Eventually someone came up with the brilliant idea to provide wwnn/wwpn of an HBA instead of a vHBA, e.g. . This is the same as creating a storage pool backed to the HBA that just happens to also be vport (vHBA) capable. The logic to bypass the vport_create call was the same as the vHBA code since the wwn's already exist. Once that was determined to work, adding in the 'parent' attribute caused a problem for the DeleteVport code, which was fixed by commit id '2c8e30ee7e'. The next test tried was providing a valid pair of wwns that would find the scsi_host HBA, but providing the wrong name for the 'parent' attribute. This caused a different failure because at DeleteVport time if a parent is provided it was assumed valid especially since the CreateVport code would check that by calling virVHBAPathExists. So alter the checkParent code to first ensure that the provided parent_name is a valid HBA/vHBA, then check if the found scsi_host is an HBA or a vHBA and make the appropriate check similar to the check made during DestroyVpor= t. This restores some checks that were "lost" during various refactorings such as commit id '79ab0935' which altered the return value logic and commit id '9fdc8c426' which moved the parent host name validity check, but neglected to add a similar check for this odd HBA configuration. As it turns out prior to this patch, the checkParent code would fail for an HBA, but that was masked by the changed return value checking logic. Signed-off-by: John Ferlan --- src/conf/node_device_conf.c | 50 +++++++++++++++++++++++++++++++++++++----= ---- 1 file changed, 42 insertions(+), 8 deletions(-) diff --git a/src/conf/node_device_conf.c b/src/conf/node_device_conf.c index e5947e6..d4075b5 100644 --- a/src/conf/node_device_conf.c +++ b/src/conf/node_device_conf.c @@ -2268,6 +2268,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; @@ -2278,20 +2279,53 @@ checkParent(virConnectPtr conn, if (!conn) return true; =20 - if (virAsprintf(&scsi_host_name, "scsi_%s", name) < 0) + if (virSCSIHostGetNumber(parent_name, &host_num) < 0) { + virReportError(VIR_ERR_XML_ERROR, + _("parent '%s' is not properly formatted"), name); goto cleanup; + } =20 - if (!(vhba_parent =3D virNodeDeviceGetParentName(conn, scsi_host_name)= )) + if (!virVHBAPathExists(NULL, host_num)) { + virReportError(VIR_ERR_XML_ERROR, + _("parent '%s' is not a vHBA/HBA"), parent_name); goto cleanup; + } =20 - 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); + 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 scsi_host_name is vport capable, then it's an HBA, thus compare + * only against the parent_name; otherwise, as long as the scsi_host_n= ame + * path exists, then the scsi_host_name is a vHBA in which case we need + * to compare against it's parent. */ + if (virVHBAIsVportCapable(NULL, host_num)) { + if (STRNEQ(parent_name, scsi_host_name)) { + virReportError(VIR_ERR_XML_ERROR, + _("parent HBA '%s' doesn't match the wwnn/wwpn " + "scsi_host '%s'"), + parent_name, scsi_host_name); + goto cleanup; + } + } else { + if (!(vhba_parent =3D virNodeDeviceGetParentName(conn, scsi_host_n= ame))) + goto cleanup; + + if (STRNEQ(parent_name, vhba_parent)) { + virReportError(VIR_ERR_XML_ERROR, + _("parent vHBA '%s' doesn't match the wwnn/wwpn= " + "scsi_host '%s' parent '%s'"), + parent_name, scsi_host_name, vhba_parent); + goto cleanup; + } + } + + retval =3D true; =20 cleanup: @@ -2333,7 +2367,7 @@ virNodeDeviceCreateVport(virConnectPtr conn, 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 (fchost->parent && !checkParent(conn, name, fchost->parent)) VIR_FREE(name); =20 return name; --=20 2.9.4 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list