From nobody Fri May 3 01:20:00 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.37 as permitted sender) client-ip=209.132.183.37; envelope-from=libvir-list-bounces@redhat.com; helo=mx5-phx2.redhat.com; Authentication-Results: mx.zoho.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.37 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; Return-Path: Received: from mx5-phx2.redhat.com (mx5-phx2.redhat.com [209.132.183.37]) by mx.zohomail.com with SMTPS id 1489180451256674.9785115082078; Fri, 10 Mar 2017 13:14:11 -0800 (PST) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by mx5-phx2.redhat.com (8.14.4/8.14.4) with ESMTP id v2ALAuDU044631; Fri, 10 Mar 2017 16:10:56 -0500 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id v2ALAtUL023886 for ; Fri, 10 Mar 2017 16:10:55 -0500 Received: from localhost.localdomain.com (ovpn-117-9.phx2.redhat.com [10.3.117.9]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id v2ALArRh011410 for ; Fri, 10 Mar 2017 16:10:54 -0500 From: John Ferlan To: libvir-list@redhat.com Date: Fri, 10 Mar 2017 16:10:33 -0500 Message-Id: <20170310211050.27784-2-jferlan@redhat.com> In-Reply-To: <20170310211050.27784-1-jferlan@redhat.com> References: <20170310211050.27784-1-jferlan@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.24 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH v3 01/18] conf: Ensure both parent_wwnn/parent_wwpn provided 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-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" https://bugzilla.redhat.com/show_bug.cgi?id=3D1428209 Commit id 'bb74a7ffe' neglected to check that both the parent_wwnn parent_wwpn are in the XML if one or the other is similar to how the node device code checked (commit id '2b13361bc'). If only one is provided, the "default" is to use a vHBA capable adapter (see commit id '78be2e8b'), so the vHBA could start, but perhaps not on the expected adapter. Signed-off-by: John Ferlan --- src/conf/storage_conf.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/conf/storage_conf.c b/src/conf/storage_conf.c index a52eeba..e4d89dd 100644 --- a/src/conf/storage_conf.c +++ b/src/conf/storage_conf.c @@ -941,6 +941,17 @@ virStoragePoolDefParseXML(xmlXPathContextPtr ctxt) if (!virValidateWWN(ret->source.adapter.data.fchost.wwnn) || !virValidateWWN(ret->source.adapter.data.fchost.wwpn)) goto error; + + if ((ret->source.adapter.data.fchost.parent_wwnn && + !ret->source.adapter.data.fchost.parent_wwpn) || + (!ret->source.adapter.data.fchost.parent_wwnn && + ret->source.adapter.data.fchost.parent_wwpn)) { + virReportError(VIR_ERR_XML_ERROR, "%s", + _("must supply both parent_wwnn and " + "parent_wwpn not just one or the other")); + goto error; + } + } else if (ret->source.adapter.type =3D=3D VIR_STORAGE_POOL_SOURCE_ADAPTER_TYPE_SCSI_HOST) { if (!ret->source.adapter.data.scsi_host.name && --=20 2.9.3 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Fri May 3 01:20:00 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.39 as permitted sender) client-ip=209.132.183.39; envelope-from=libvir-list-bounces@redhat.com; helo=mx6-phx2.redhat.com; Authentication-Results: mx.zoho.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.39 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; Return-Path: Received: from mx6-phx2.redhat.com (mx6-phx2.redhat.com [209.132.183.39]) by mx.zohomail.com with SMTPS id 1489180449519819.0725192421827; Fri, 10 Mar 2017 13:14:09 -0800 (PST) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by mx6-phx2.redhat.com (8.14.4/8.14.4) with ESMTP id v2ALAvkP051492; Fri, 10 Mar 2017 16:10:57 -0500 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id v2ALAt8t023891 for ; Fri, 10 Mar 2017 16:10:55 -0500 Received: from localhost.localdomain.com (ovpn-117-9.phx2.redhat.com [10.3.117.9]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id v2ALArRi011410 for ; Fri, 10 Mar 2017 16:10:55 -0500 From: John Ferlan To: libvir-list@redhat.com Date: Fri, 10 Mar 2017 16:10:34 -0500 Message-Id: <20170310211050.27784-3-jferlan@redhat.com> In-Reply-To: <20170310211050.27784-1-jferlan@redhat.com> References: <20170310211050.27784-1-jferlan@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.24 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH v3 02/18] conf: Add missing validate for fchost search fields 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-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Commit id 'bb74a7ffe' added some new fields to search for a fchost by parent wwnn/wwpn or parent_fabric_name, but neglected to validate that the data within the fields was valid at parse time. This could lead to eventual failure at run time, so rather than have the failure then, let's validate now. Signed-off-by: John Ferlan --- src/conf/storage_conf.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/conf/storage_conf.c b/src/conf/storage_conf.c index e4d89dd..8e3b175 100644 --- a/src/conf/storage_conf.c +++ b/src/conf/storage_conf.c @@ -952,6 +952,18 @@ virStoragePoolDefParseXML(xmlXPathContextPtr ctxt) goto error; } =20 + if (ret->source.adapter.data.fchost.parent_wwnn && + !virValidateWWN(ret->source.adapter.data.fchost.parent_wwn= n)) + goto error; + + if (ret->source.adapter.data.fchost.parent_wwpn && + !virValidateWWN(ret->source.adapter.data.fchost.parent_wwp= n)) + goto error; + + if (ret->source.adapter.data.fchost.parent_fabric_wwn && + !virValidateWWN(ret->source.adapter.data.fchost.parent_fab= ric_wwn)) + goto error; + } else if (ret->source.adapter.type =3D=3D VIR_STORAGE_POOL_SOURCE_ADAPTER_TYPE_SCSI_HOST) { if (!ret->source.adapter.data.scsi_host.name && --=20 2.9.3 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Fri May 3 01:20:00 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.25 as permitted sender) client-ip=209.132.183.25; envelope-from=libvir-list-bounces@redhat.com; helo=mx4-phx2.redhat.com; Authentication-Results: mx.zoho.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.25 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; Return-Path: Received: from mx4-phx2.redhat.com (mx4-phx2.redhat.com [209.132.183.25]) by mx.zohomail.com with SMTPS id 1489180488118909.2499673532136; Fri, 10 Mar 2017 13:14:48 -0800 (PST) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by mx4-phx2.redhat.com (8.13.8/8.13.8) with ESMTP id v2ALBQN2009171; Fri, 10 Mar 2017 16:11:26 -0500 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id v2ALAt4X023899 for ; Fri, 10 Mar 2017 16:10:55 -0500 Received: from localhost.localdomain.com (ovpn-117-9.phx2.redhat.com [10.3.117.9]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id v2ALArRj011410 for ; Fri, 10 Mar 2017 16:10:55 -0500 From: John Ferlan To: libvir-list@redhat.com Date: Fri, 10 Mar 2017 16:10:35 -0500 Message-Id: <20170310211050.27784-4-jferlan@redhat.com> In-Reply-To: <20170310211050.27784-1-jferlan@redhat.com> References: <20170310211050.27784-1-jferlan@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.24 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH v3 03/18] conf: Split out storage pool source adapter helpers 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-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Split out the code that munges through the storage pool adapter into helpers - it's about to be moved into it's own source file. This is purely code motion at this point. Signed-off-by: John Ferlan --- src/conf/storage_conf.c | 455 ++++++++++++++++++++++++++------------------= ---- 1 file changed, 243 insertions(+), 212 deletions(-) diff --git a/src/conf/storage_conf.c b/src/conf/storage_conf.c index 8e3b175..1993d3a 100644 --- a/src/conf/storage_conf.c +++ b/src/conf/storage_conf.c @@ -463,6 +463,128 @@ virStoragePoolObjRemove(virStoragePoolObjListPtr pool= s, } =20 static int +virStoragePoolDefParseSourceAdapter(virStoragePoolSourcePtr source, + xmlXPathContextPtr ctxt) +{ + int ret =3D -1; + char *adapter_type =3D NULL; + char *managed =3D NULL; + + if ((adapter_type =3D virXPathString("string(./adapter/@type)", ctxt))= ) { + if ((source->adapter.type =3D + virStoragePoolSourceAdapterTypeFromString(adapter_type)) <=3D= 0) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("Unknown pool adapter type '%s'"), + adapter_type); + goto cleanup; + } + + if (source->adapter.type =3D=3D + VIR_STORAGE_POOL_SOURCE_ADAPTER_TYPE_FC_HOST) { + source->adapter.data.fchost.parent =3D + virXPathString("string(./adapter/@parent)", ctxt); + managed =3D virXPathString("string(./adapter/@managed)", ctxt); + if (managed) { + source->adapter.data.fchost.managed =3D + virTristateBoolTypeFromString(managed); + if (source->adapter.data.fchost.managed < 0) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("unknown fc_host managed setting '%s'= "), + managed); + goto cleanup; + } + } + + source->adapter.data.fchost.parent_wwnn =3D + virXPathString("string(./adapter/@parent_wwnn)", ctxt); + source->adapter.data.fchost.parent_wwpn =3D + virXPathString("string(./adapter/@parent_wwpn)", ctxt); + source->adapter.data.fchost.parent_fabric_wwn =3D + virXPathString("string(./adapter/@parent_fabric_wwn)", ctx= t); + + source->adapter.data.fchost.wwpn =3D + virXPathString("string(./adapter/@wwpn)", ctxt); + source->adapter.data.fchost.wwnn =3D + virXPathString("string(./adapter/@wwnn)", ctxt); + } else if (source->adapter.type =3D=3D + VIR_STORAGE_POOL_SOURCE_ADAPTER_TYPE_SCSI_HOST) { + + source->adapter.data.scsi_host.name =3D + virXPathString("string(./adapter/@name)", ctxt); + if (virXPathNode("./adapter/parentaddr", ctxt)) { + xmlNodePtr addrnode =3D virXPathNode("./adapter/parentaddr= /address", + ctxt); + virPCIDeviceAddressPtr addr =3D + &source->adapter.data.scsi_host.parentaddr; + + if (!addrnode) { + virReportError(VIR_ERR_XML_ERROR, "%s", + _("Missing scsi_host PCI address elemen= t")); + goto cleanup; + } + source->adapter.data.scsi_host.has_parent =3D true; + if (virPCIDeviceAddressParseXML(addrnode, addr) < 0) + goto cleanup; + if ((virXPathInt("string(./adapter/parentaddr/@unique_id)", + ctxt, + &source->adapter.data.scsi_host.unique_id= ) < 0) || + (source->adapter.data.scsi_host.unique_id < 0)) { + virReportError(VIR_ERR_XML_ERROR, "%s", + _("Missing or invalid scsi adapter " + "'unique_id' value")); + goto cleanup; + } + } + } + } else { + char *wwnn =3D NULL; + char *wwpn =3D NULL; + char *parent =3D NULL; + + /* "type" was not specified in the XML, so we must verify that + * "wwnn", "wwpn", "parent", or "parentaddr" are also not in the + * XML. If any are found, then we cannot just use "name" alone". + */ + wwnn =3D virXPathString("string(./adapter/@wwnn)", ctxt); + wwpn =3D virXPathString("string(./adapter/@wwpn)", ctxt); + parent =3D virXPathString("string(./adapter/@parent)", ctxt); + + if (wwnn || wwpn || parent) { + VIR_FREE(wwnn); + VIR_FREE(wwpn); + VIR_FREE(parent); + virReportError(VIR_ERR_XML_ERROR, "%s", + _("Use of 'wwnn', 'wwpn', and 'parent' attribut= es " + "requires use of the adapter 'type'")); + goto cleanup; + } + + if (virXPathNode("./adapter/parentaddr", ctxt)) { + virReportError(VIR_ERR_XML_ERROR, "%s", + _("Use of 'parent' element requires use " + "of the adapter 'type'")); + goto cleanup; + } + + /* To keep back-compat, 'type' is not required to specify + * for scsi_host adapter. + */ + if ((source->adapter.data.scsi_host.name =3D + virXPathString("string(./adapter/@name)", ctxt))) + source->adapter.type =3D + VIR_STORAGE_POOL_SOURCE_ADAPTER_TYPE_SCSI_HOST; + } + + ret =3D 0; + + cleanup: + VIR_FREE(adapter_type); + VIR_FREE(managed); + return ret; +} + + +static int virStoragePoolDefParseSource(xmlXPathContextPtr ctxt, virStoragePoolSourcePtr source, int pool_type, @@ -476,8 +598,6 @@ virStoragePoolDefParseSource(xmlXPathContextPtr ctxt, virStorageAuthDefPtr authdef =3D NULL; char *name =3D NULL; char *port =3D NULL; - char *adapter_type =3D NULL; - char *managed =3D NULL; int n; =20 relnode =3D ctxt->node; @@ -583,110 +703,8 @@ virStoragePoolDefParseSource(xmlXPathContextPtr ctxt, VIR_STRDUP(source->dir, "/") < 0) goto cleanup; =20 - if ((adapter_type =3D virXPathString("string(./adapter/@type)", ctxt))= ) { - if ((source->adapter.type =3D - virStoragePoolSourceAdapterTypeFromString(adapter_type)) <=3D= 0) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, - _("Unknown pool adapter type '%s'"), - adapter_type); - goto cleanup; - } - - if (source->adapter.type =3D=3D - VIR_STORAGE_POOL_SOURCE_ADAPTER_TYPE_FC_HOST) { - source->adapter.data.fchost.parent =3D - virXPathString("string(./adapter/@parent)", ctxt); - managed =3D virXPathString("string(./adapter/@managed)", ctxt); - if (managed) { - source->adapter.data.fchost.managed =3D - virTristateBoolTypeFromString(managed); - if (source->adapter.data.fchost.managed < 0) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, - _("unknown fc_host managed setting '%s'= "), - managed); - goto cleanup; - } - } - - source->adapter.data.fchost.parent_wwnn =3D - virXPathString("string(./adapter/@parent_wwnn)", ctxt); - source->adapter.data.fchost.parent_wwpn =3D - virXPathString("string(./adapter/@parent_wwpn)", ctxt); - source->adapter.data.fchost.parent_fabric_wwn =3D - virXPathString("string(./adapter/@parent_fabric_wwn)", ctx= t); - - source->adapter.data.fchost.wwpn =3D - virXPathString("string(./adapter/@wwpn)", ctxt); - source->adapter.data.fchost.wwnn =3D - virXPathString("string(./adapter/@wwnn)", ctxt); - } else if (source->adapter.type =3D=3D - VIR_STORAGE_POOL_SOURCE_ADAPTER_TYPE_SCSI_HOST) { - - source->adapter.data.scsi_host.name =3D - virXPathString("string(./adapter/@name)", ctxt); - if (virXPathNode("./adapter/parentaddr", ctxt)) { - xmlNodePtr addrnode =3D virXPathNode("./adapter/parentaddr= /address", - ctxt); - virPCIDeviceAddressPtr addr =3D - &source->adapter.data.scsi_host.parentaddr; - - if (!addrnode) { - virReportError(VIR_ERR_XML_ERROR, "%s", - _("Missing scsi_host PCI address elemen= t")); - goto cleanup; - } - source->adapter.data.scsi_host.has_parent =3D true; - if (virPCIDeviceAddressParseXML(addrnode, addr) < 0) - goto cleanup; - if ((virXPathInt("string(./adapter/parentaddr/@unique_id)", - ctxt, - &source->adapter.data.scsi_host.unique_id= ) < 0) || - (source->adapter.data.scsi_host.unique_id < 0)) { - virReportError(VIR_ERR_XML_ERROR, "%s", - _("Missing or invalid scsi adapter " - "'unique_id' value")); - goto cleanup; - } - } - } - } else { - char *wwnn =3D NULL; - char *wwpn =3D NULL; - char *parent =3D NULL; - - /* "type" was not specified in the XML, so we must verify that - * "wwnn", "wwpn", "parent", or "parentaddr" are also not in the - * XML. If any are found, then we cannot just use "name" alone". - */ - wwnn =3D virXPathString("string(./adapter/@wwnn)", ctxt); - wwpn =3D virXPathString("string(./adapter/@wwpn)", ctxt); - parent =3D virXPathString("string(./adapter/@parent)", ctxt); - - if (wwnn || wwpn || parent) { - VIR_FREE(wwnn); - VIR_FREE(wwpn); - VIR_FREE(parent); - virReportError(VIR_ERR_XML_ERROR, "%s", - _("Use of 'wwnn', 'wwpn', and 'parent' attribut= es " - "requires use of the adapter 'type'")); - goto cleanup; - } - - if (virXPathNode("./adapter/parentaddr", ctxt)) { - virReportError(VIR_ERR_XML_ERROR, "%s", - _("Use of 'parent' element requires use " - "of the adapter 'type'")); - goto cleanup; - } - - /* To keep back-compat, 'type' is not required to specify - * for scsi_host adapter. - */ - if ((source->adapter.data.scsi_host.name =3D - virXPathString("string(./adapter/@name)", ctxt))) - source->adapter.type =3D - VIR_STORAGE_POOL_SOURCE_ADAPTER_TYPE_SCSI_HOST; - } + if (virStoragePoolDefParseSourceAdapter(source, ctxt) < 0) + goto cleanup; =20 if ((authnode =3D virXPathNode("./auth", ctxt))) { if (!(authdef =3D virStorageAuthDefParse(node->doc, authnode))) @@ -711,8 +729,6 @@ virStoragePoolDefParseSource(xmlXPathContextPtr ctxt, =20 VIR_FREE(port); VIR_FREE(nodeset); - VIR_FREE(adapter_type); - VIR_FREE(managed); virStorageAuthDefFree(authdef); return ret; } @@ -831,6 +847,74 @@ virStorageDefParsePerms(xmlXPathContextPtr ctxt, return ret; } =20 +static int +virStoragePoolSourceAdapterParseValidate(virStoragePoolDefPtr ret) +{ + if (!ret->source.adapter.type) { + virReportError(VIR_ERR_XML_ERROR, "%s", + _("missing storage pool source adapter")); + return -1; + } + + if (ret->source.adapter.type =3D=3D + VIR_STORAGE_POOL_SOURCE_ADAPTER_TYPE_FC_HOST) { + if (!ret->source.adapter.data.fchost.wwnn || + !ret->source.adapter.data.fchost.wwpn) { + virReportError(VIR_ERR_XML_ERROR, "%s", + _("'wwnn' and 'wwpn' must be specified for adap= ter " + "type 'fchost'")); + return -1; + } + + if (!virValidateWWN(ret->source.adapter.data.fchost.wwnn) || + !virValidateWWN(ret->source.adapter.data.fchost.wwpn)) + return -1; + + if ((ret->source.adapter.data.fchost.parent_wwnn && + !ret->source.adapter.data.fchost.parent_wwpn) || + (!ret->source.adapter.data.fchost.parent_wwnn && + ret->source.adapter.data.fchost.parent_wwpn)) { + virReportError(VIR_ERR_XML_ERROR, "%s", + _("must supply both parent_wwnn and " + "parent_wwpn not just one or the other")); + return -1; + } + + if (ret->source.adapter.data.fchost.parent_wwnn && + !virValidateWWN(ret->source.adapter.data.fchost.parent_wwnn)) + return -1; + + if (ret->source.adapter.data.fchost.parent_wwpn && + !virValidateWWN(ret->source.adapter.data.fchost.parent_wwpn)) + return -1; + + if (ret->source.adapter.data.fchost.parent_fabric_wwn && + !virValidateWWN(ret->source.adapter.data.fchost.parent_fabric_= wwn)) + return -1; + + } else if (ret->source.adapter.type =3D=3D + VIR_STORAGE_POOL_SOURCE_ADAPTER_TYPE_SCSI_HOST) { + if (!ret->source.adapter.data.scsi_host.name && + !ret->source.adapter.data.scsi_host.has_parent) { + virReportError(VIR_ERR_XML_ERROR, "%s", + _("Either 'name' or 'parent' must be specified " + "for the 'scsi_host' adapter")); + return -1; + } + + if (ret->source.adapter.data.scsi_host.name && + ret->source.adapter.data.scsi_host.has_parent) { + virReportError(VIR_ERR_XML_ERROR, "%s", + _("Both 'name' and 'parent' cannot be specified= " + "for the 'scsi_host' adapter")); + return -1; + } + } + + return 0; +} + + static virStoragePoolDefPtr virStoragePoolDefParseXML(xmlXPathContextPtr ctxt) { @@ -921,68 +1005,9 @@ virStoragePoolDefParseXML(xmlXPathContextPtr ctxt) } } =20 - if (options->flags & VIR_STORAGE_POOL_SOURCE_ADAPTER) { - if (!ret->source.adapter.type) { - virReportError(VIR_ERR_XML_ERROR, "%s", - _("missing storage pool source adapter")); + if ((options->flags & VIR_STORAGE_POOL_SOURCE_ADAPTER) && + (virStoragePoolSourceAdapterParseValidate(ret)) < 0) goto error; - } - - if (ret->source.adapter.type =3D=3D - VIR_STORAGE_POOL_SOURCE_ADAPTER_TYPE_FC_HOST) { - if (!ret->source.adapter.data.fchost.wwnn || - !ret->source.adapter.data.fchost.wwpn) { - virReportError(VIR_ERR_XML_ERROR, "%s", - _("'wwnn' and 'wwpn' must be specified for = adapter " - "type 'fchost'")); - goto error; - } - - if (!virValidateWWN(ret->source.adapter.data.fchost.wwnn) || - !virValidateWWN(ret->source.adapter.data.fchost.wwpn)) - goto error; - - if ((ret->source.adapter.data.fchost.parent_wwnn && - !ret->source.adapter.data.fchost.parent_wwpn) || - (!ret->source.adapter.data.fchost.parent_wwnn && - ret->source.adapter.data.fchost.parent_wwpn)) { - virReportError(VIR_ERR_XML_ERROR, "%s", - _("must supply both parent_wwnn and " - "parent_wwpn not just one or the other")); - goto error; - } - - if (ret->source.adapter.data.fchost.parent_wwnn && - !virValidateWWN(ret->source.adapter.data.fchost.parent_wwn= n)) - goto error; - - if (ret->source.adapter.data.fchost.parent_wwpn && - !virValidateWWN(ret->source.adapter.data.fchost.parent_wwp= n)) - goto error; - - if (ret->source.adapter.data.fchost.parent_fabric_wwn && - !virValidateWWN(ret->source.adapter.data.fchost.parent_fab= ric_wwn)) - goto error; - - } else if (ret->source.adapter.type =3D=3D - VIR_STORAGE_POOL_SOURCE_ADAPTER_TYPE_SCSI_HOST) { - if (!ret->source.adapter.data.scsi_host.name && - !ret->source.adapter.data.scsi_host.has_parent) { - virReportError(VIR_ERR_XML_ERROR, "%s", - _("Either 'name' or 'parent' must be specif= ied " - "for the 'scsi_host' adapter")); - goto error; - } - - if (ret->source.adapter.data.scsi_host.name && - ret->source.adapter.data.scsi_host.has_parent) { - virReportError(VIR_ERR_XML_ERROR, "%s", - _("Both 'name' and 'parent' cannot be speci= fied " - "for the 'scsi_host' adapter")); - goto error; - } - } - } =20 /* If DEVICE is the only source type, then its required */ if (options->flags =3D=3D VIR_STORAGE_POOL_SOURCE_DEVICE) { @@ -1086,6 +1111,51 @@ virStoragePoolDefParseFile(const char *filename) return virStoragePoolDefParse(NULL, filename); } =20 +static void +virStoragePoolSourceAdapterFormat(virBufferPtr buf, + virStoragePoolSourcePtr src) +{ + virBufferAsprintf(buf, "adapter= .type)); + + if (src->adapter.type =3D=3D VIR_STORAGE_POOL_SOURCE_ADAPTER_TYPE_FC_H= OST) { + virBufferEscapeString(buf, " parent=3D'%s'", + src->adapter.data.fchost.parent); + if (src->adapter.data.fchost.managed) + virBufferAsprintf(buf, " managed=3D'%s'", + virTristateBoolTypeToString(src->adapter.dat= a.fchost.managed)); + virBufferEscapeString(buf, " parent_wwnn=3D'%s'", + src->adapter.data.fchost.parent_wwnn); + virBufferEscapeString(buf, " parent_wwpn=3D'%s'", + src->adapter.data.fchost.parent_wwpn); + virBufferEscapeString(buf, " parent_fabric_wwn=3D'%s'", + src->adapter.data.fchost.parent_fabric_wwn); + + virBufferAsprintf(buf, " wwnn=3D'%s' wwpn=3D'%s'/>\n", + src->adapter.data.fchost.wwnn, + src->adapter.data.fchost.wwpn); + } else if (src->adapter.type =3D=3D + VIR_STORAGE_POOL_SOURCE_ADAPTER_TYPE_SCSI_HOST) { + if (src->adapter.data.scsi_host.name) { + virBufferAsprintf(buf, " name=3D'%s'/>\n", + src->adapter.data.scsi_host.name); + } else { + virPCIDeviceAddress addr; + virBufferAddLit(buf, ">\n"); + virBufferAdjustIndent(buf, 2); + virBufferAsprintf(buf, "\n", + src->adapter.data.scsi_host.unique_id); + virBufferAdjustIndent(buf, 2); + addr =3D src->adapter.data.scsi_host.parentaddr; + ignore_value(virPCIDeviceAddressFormat(buf, addr, false)); + virBufferAdjustIndent(buf, -2); + virBufferAddLit(buf, "\n"); + virBufferAdjustIndent(buf, -2); + virBufferAddLit(buf, "\n"); + } + } +} + static int virStoragePoolSourceFormat(virBufferPtr buf, virStoragePoolOptionsPtr options, @@ -1135,49 +1205,10 @@ virStoragePoolSourceFormat(virBufferPtr buf, if (options->flags & VIR_STORAGE_POOL_SOURCE_DIR) virBufferEscapeString(buf, "\n", src->dir); =20 - if ((options->flags & VIR_STORAGE_POOL_SOURCE_ADAPTER)) { - if (src->adapter.type =3D=3D VIR_STORAGE_POOL_SOURCE_ADAPTER_TYPE_= FC_HOST || - src->adapter.type =3D=3D VIR_STORAGE_POOL_SOURCE_ADAPTER_TYPE_= SCSI_HOST) - virBufferAsprintf(buf, "adapter.type)); - - if (src->adapter.type =3D=3D VIR_STORAGE_POOL_SOURCE_ADAPTER_TYPE_= FC_HOST) { - virBufferEscapeString(buf, " parent=3D'%s'", - src->adapter.data.fchost.parent); - if (src->adapter.data.fchost.managed) - virBufferAsprintf(buf, " managed=3D'%s'", - virTristateBoolTypeToString(src->adapter= .data.fchost.managed)); - virBufferEscapeString(buf, " parent_wwnn=3D'%s'", - src->adapter.data.fchost.parent_wwnn); - virBufferEscapeString(buf, " parent_wwpn=3D'%s'", - src->adapter.data.fchost.parent_wwpn); - virBufferEscapeString(buf, " parent_fabric_wwn=3D'%s'", - src->adapter.data.fchost.parent_fabric_w= wn); - - virBufferAsprintf(buf, " wwnn=3D'%s' wwpn=3D'%s'/>\n", - src->adapter.data.fchost.wwnn, - src->adapter.data.fchost.wwpn); - } else if (src->adapter.type =3D=3D - VIR_STORAGE_POOL_SOURCE_ADAPTER_TYPE_SCSI_HOST) { - if (src->adapter.data.scsi_host.name) { - virBufferAsprintf(buf, " name=3D'%s'/>\n", - src->adapter.data.scsi_host.name); - } else { - virPCIDeviceAddress addr; - virBufferAddLit(buf, ">\n"); - virBufferAdjustIndent(buf, 2); - virBufferAsprintf(buf, "\n", - src->adapter.data.scsi_host.unique_id); - virBufferAdjustIndent(buf, 2); - addr =3D src->adapter.data.scsi_host.parentaddr; - ignore_value(virPCIDeviceAddressFormat(buf, addr, false)); - virBufferAdjustIndent(buf, -2); - virBufferAddLit(buf, "\n"); - virBufferAdjustIndent(buf, -2); - virBufferAddLit(buf, "\n"); - } - } - } + if ((options->flags & VIR_STORAGE_POOL_SOURCE_ADAPTER) && + (src->adapter.type =3D=3D VIR_STORAGE_POOL_SOURCE_ADAPTER_TYPE_FC_= HOST || + src->adapter.type =3D=3D VIR_STORAGE_POOL_SOURCE_ADAPTER_TYPE_SCS= I_HOST)) + virStoragePoolSourceAdapterFormat(buf, src); =20 if (options->flags & VIR_STORAGE_POOL_SOURCE_NAME) virBufferEscapeString(buf, "%s\n", src->name); --=20 2.9.3 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Fri May 3 01:20:00 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.24 as permitted sender) client-ip=209.132.183.24; envelope-from=libvir-list-bounces@redhat.com; helo=mx3-phx2.redhat.com; Authentication-Results: mx.zoho.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.24 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; Return-Path: Received: from mx3-phx2.redhat.com (mx3-phx2.redhat.com [209.132.183.24]) by mx.zohomail.com with SMTPS id 1489180483573899.550810886138; Fri, 10 Mar 2017 13:14:43 -0800 (PST) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by mx3-phx2.redhat.com (8.13.8/8.13.8) with ESMTP id v2ALBSLr006692; Fri, 10 Mar 2017 16:11:28 -0500 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id v2ALAuZG023908 for ; Fri, 10 Mar 2017 16:10:56 -0500 Received: from localhost.localdomain.com (ovpn-117-9.phx2.redhat.com [10.3.117.9]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id v2ALArRk011410 for ; Fri, 10 Mar 2017 16:10:56 -0500 From: John Ferlan To: libvir-list@redhat.com Date: Fri, 10 Mar 2017 16:10:36 -0500 Message-Id: <20170310211050.27784-5-jferlan@redhat.com> In-Reply-To: <20170310211050.27784-1-jferlan@redhat.com> References: <20170310211050.27784-1-jferlan@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.24 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH v3 04/18] conf: Rework parsing in virStoragePoolDefParseSourceAdapter 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-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Rather than use virXPathString, pass along an virXPathNode and alter the parsing to use virXMLPropString. Signed-off-by: John Ferlan --- src/conf/storage_conf.c | 51 ++++++++++++++++++++++++++-------------------= ---- 1 file changed, 27 insertions(+), 24 deletions(-) diff --git a/src/conf/storage_conf.c b/src/conf/storage_conf.c index 1993d3a..4fa7c12 100644 --- a/src/conf/storage_conf.c +++ b/src/conf/storage_conf.c @@ -464,13 +464,17 @@ virStoragePoolObjRemove(virStoragePoolObjListPtr pool= s, =20 static int virStoragePoolDefParseSourceAdapter(virStoragePoolSourcePtr source, + xmlNodePtr node, xmlXPathContextPtr ctxt) { int ret =3D -1; + xmlNodePtr relnode =3D ctxt->node; char *adapter_type =3D NULL; char *managed =3D NULL; =20 - if ((adapter_type =3D virXPathString("string(./adapter/@type)", ctxt))= ) { + ctxt->node =3D node; + + if ((adapter_type =3D virXMLPropString(node, "type"))) { if ((source->adapter.type =3D virStoragePoolSourceAdapterTypeFromString(adapter_type)) <=3D= 0) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, @@ -482,8 +486,8 @@ virStoragePoolDefParseSourceAdapter(virStoragePoolSourc= ePtr source, if (source->adapter.type =3D=3D VIR_STORAGE_POOL_SOURCE_ADAPTER_TYPE_FC_HOST) { source->adapter.data.fchost.parent =3D - virXPathString("string(./adapter/@parent)", ctxt); - managed =3D virXPathString("string(./adapter/@managed)", ctxt); + virXMLPropString(node, "parent"); + managed =3D virXMLPropString(node, "managed"); if (managed) { source->adapter.data.fchost.managed =3D virTristateBoolTypeFromString(managed); @@ -496,23 +500,21 @@ virStoragePoolDefParseSourceAdapter(virStoragePoolSou= rcePtr source, } =20 source->adapter.data.fchost.parent_wwnn =3D - virXPathString("string(./adapter/@parent_wwnn)", ctxt); + virXMLPropString(node, "parent_wwnn"); source->adapter.data.fchost.parent_wwpn =3D - virXPathString("string(./adapter/@parent_wwpn)", ctxt); + virXMLPropString(node, "parent_wwpn"); source->adapter.data.fchost.parent_fabric_wwn =3D - virXPathString("string(./adapter/@parent_fabric_wwn)", ctx= t); + virXMLPropString(node, "parent_fabric_wwn"); =20 - source->adapter.data.fchost.wwpn =3D - virXPathString("string(./adapter/@wwpn)", ctxt); - source->adapter.data.fchost.wwnn =3D - virXPathString("string(./adapter/@wwnn)", ctxt); + source->adapter.data.fchost.wwpn =3D virXMLPropString(node, "w= wpn"); + source->adapter.data.fchost.wwnn =3D virXMLPropString(node, "w= wnn"); } else if (source->adapter.type =3D=3D VIR_STORAGE_POOL_SOURCE_ADAPTER_TYPE_SCSI_HOST) { =20 source->adapter.data.scsi_host.name =3D - virXPathString("string(./adapter/@name)", ctxt); - if (virXPathNode("./adapter/parentaddr", ctxt)) { - xmlNodePtr addrnode =3D virXPathNode("./adapter/parentaddr= /address", + virXMLPropString(node, "name"); + if (virXPathNode("./parentaddr", ctxt)) { + xmlNodePtr addrnode =3D virXPathNode("./parentaddr/address= ", ctxt); virPCIDeviceAddressPtr addr =3D &source->adapter.data.scsi_host.parentaddr; @@ -525,7 +527,7 @@ virStoragePoolDefParseSourceAdapter(virStoragePoolSourc= ePtr source, source->adapter.data.scsi_host.has_parent =3D true; if (virPCIDeviceAddressParseXML(addrnode, addr) < 0) goto cleanup; - if ((virXPathInt("string(./adapter/parentaddr/@unique_id)", + if ((virXPathInt("string(./parentaddr/@unique_id)", ctxt, &source->adapter.data.scsi_host.unique_id= ) < 0) || (source->adapter.data.scsi_host.unique_id < 0)) { @@ -537,17 +539,14 @@ virStoragePoolDefParseSourceAdapter(virStoragePoolSou= rcePtr source, } } } else { - char *wwnn =3D NULL; - char *wwpn =3D NULL; - char *parent =3D NULL; + char *wwnn =3D virXMLPropString(node, "wwnn"); + char *wwpn =3D virXMLPropString(node, "wwpn"); + char *parent =3D virXMLPropString(node, "parent"); =20 /* "type" was not specified in the XML, so we must verify that * "wwnn", "wwpn", "parent", or "parentaddr" are also not in the * XML. If any are found, then we cannot just use "name" alone". */ - wwnn =3D virXPathString("string(./adapter/@wwnn)", ctxt); - wwpn =3D virXPathString("string(./adapter/@wwpn)", ctxt); - parent =3D virXPathString("string(./adapter/@parent)", ctxt); =20 if (wwnn || wwpn || parent) { VIR_FREE(wwnn); @@ -559,7 +558,7 @@ virStoragePoolDefParseSourceAdapter(virStoragePoolSourc= ePtr source, goto cleanup; } =20 - if (virXPathNode("./adapter/parentaddr", ctxt)) { + if (virXPathNode("./parentaddr", ctxt)) { virReportError(VIR_ERR_XML_ERROR, "%s", _("Use of 'parent' element requires use " "of the adapter 'type'")); @@ -570,7 +569,7 @@ virStoragePoolDefParseSourceAdapter(virStoragePoolSourc= ePtr source, * for scsi_host adapter. */ if ((source->adapter.data.scsi_host.name =3D - virXPathString("string(./adapter/@name)", ctxt))) + virXMLPropString(node, "name"))) source->adapter.type =3D VIR_STORAGE_POOL_SOURCE_ADAPTER_TYPE_SCSI_HOST; } @@ -578,6 +577,7 @@ virStoragePoolDefParseSourceAdapter(virStoragePoolSourc= ePtr source, ret =3D 0; =20 cleanup: + ctxt->node =3D relnode; VIR_FREE(adapter_type); VIR_FREE(managed); return ret; @@ -592,6 +592,7 @@ virStoragePoolDefParseSource(xmlXPathContextPtr ctxt, { int ret =3D -1; xmlNodePtr relnode, authnode, *nodeset =3D NULL; + xmlNodePtr adapternode; int nsource; size_t i; virStoragePoolOptionsPtr options; @@ -703,8 +704,10 @@ virStoragePoolDefParseSource(xmlXPathContextPtr ctxt, VIR_STRDUP(source->dir, "/") < 0) goto cleanup; =20 - if (virStoragePoolDefParseSourceAdapter(source, ctxt) < 0) - goto cleanup; + if ((adapternode =3D virXPathNode("./adapter", ctxt))) { + if (virStoragePoolDefParseSourceAdapter(source, adapternode, ctxt)= < 0) + goto cleanup; + } =20 if ((authnode =3D virXPathNode("./auth", ctxt))) { if (!(authdef =3D virStorageAuthDefParse(node->doc, authnode))) --=20 2.9.3 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Fri May 3 01:20:00 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.25 as permitted sender) client-ip=209.132.183.25; envelope-from=libvir-list-bounces@redhat.com; helo=mx4-phx2.redhat.com; Authentication-Results: mx.zoho.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.25 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; Return-Path: Received: from mx4-phx2.redhat.com (mx4-phx2.redhat.com [209.132.183.25]) by mx.zohomail.com with SMTPS id 14891805004371019.1262023538075; Fri, 10 Mar 2017 13:15:00 -0800 (PST) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by mx4-phx2.redhat.com (8.13.8/8.13.8) with ESMTP id v2ALBU7t009183; Fri, 10 Mar 2017 16:11:30 -0500 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id v2ALAuc1023916 for ; Fri, 10 Mar 2017 16:10:56 -0500 Received: from localhost.localdomain.com (ovpn-117-9.phx2.redhat.com [10.3.117.9]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id v2ALArRl011410 for ; Fri, 10 Mar 2017 16:10:56 -0500 From: John Ferlan To: libvir-list@redhat.com Date: Fri, 10 Mar 2017 16:10:37 -0500 Message-Id: <20170310211050.27784-6-jferlan@redhat.com> In-Reply-To: <20170310211050.27784-1-jferlan@redhat.com> References: <20170310211050.27784-1-jferlan@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.24 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH v3 05/18] conf: Introduce storage_adapter_conf 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-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Move code from storage_conf into storage_adapter_conf Pure code motion Signed-off-by: John Ferlan --- po/POTFILES.in | 1 + src/Makefile.am | 1 + src/conf/storage_adapter_conf.c | 290 ++++++++++++++++++++++++++++++++++++= ++++ src/conf/storage_adapter_conf.h | 43 ++++++ src/conf/storage_conf.c | 253 +---------------------------------- src/libvirt_private.syms | 7 + 6 files changed, 343 insertions(+), 252 deletions(-) create mode 100644 src/conf/storage_adapter_conf.c create mode 100644 src/conf/storage_adapter_conf.h diff --git a/po/POTFILES.in b/po/POTFILES.in index ceda3ed..d802bdc 100644 --- a/po/POTFILES.in +++ b/po/POTFILES.in @@ -39,6 +39,7 @@ src/conf/nwfilter_params.c src/conf/object_event.c src/conf/secret_conf.c src/conf/snapshot_conf.c +src/conf/storage_adapter_conf.c src/conf/storage_conf.c src/conf/virchrdev.c src/conf/virdomainobjlist.c diff --git a/src/Makefile.am b/src/Makefile.am index 0257965..67db861 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -379,6 +379,7 @@ NWFILTER_CONF_SOURCES =3D \ =20 # Storage driver generic impl APIs STORAGE_CONF_SOURCES =3D \ + conf/storage_adapter_conf.h conf/storage_adapter_conf.c \ conf/storage_conf.h conf/storage_conf.c =20 # Interface driver generic impl APIs diff --git a/src/conf/storage_adapter_conf.c b/src/conf/storage_adapter_con= f.c new file mode 100644 index 0000000..3a16bcc --- /dev/null +++ b/src/conf/storage_adapter_conf.c @@ -0,0 +1,290 @@ +/* + * storage_adapter_conf.c: helpers to handle storage pool adapter manipula= tion + * (derived from storage_conf.c) + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library. If not, see + * . + */ + +#include + +#include "storage_adapter_conf.h" + +#include "viralloc.h" +#include "virerror.h" +#include "virlog.h" +#include "virstring.h" +#include "virutil.h" +#include "virxml.h" + +#define VIR_FROM_THIS VIR_FROM_STORAGE + +VIR_LOG_INIT("conf.storage_adapter_conf"); + +VIR_ENUM_IMPL(virStoragePoolSourceAdapter, + VIR_STORAGE_POOL_SOURCE_ADAPTER_TYPE_LAST, + "default", "scsi_host", "fc_host") + + +void +virStoragePoolSourceAdapterClear(virStoragePoolSourceAdapterPtr adapter) +{ + if (adapter->type =3D=3D VIR_STORAGE_POOL_SOURCE_ADAPTER_TYPE_FC_HOST)= { + VIR_FREE(adapter->data.fchost.wwnn); + VIR_FREE(adapter->data.fchost.wwpn); + VIR_FREE(adapter->data.fchost.parent); + VIR_FREE(adapter->data.fchost.parent_wwnn); + VIR_FREE(adapter->data.fchost.parent_wwpn); + VIR_FREE(adapter->data.fchost.parent_fabric_wwn); + } else if (adapter->type =3D=3D + VIR_STORAGE_POOL_SOURCE_ADAPTER_TYPE_SCSI_HOST) { + VIR_FREE(adapter->data.scsi_host.name); + } +} + + +int +virStoragePoolDefParseSourceAdapter(virStoragePoolSourcePtr source, + xmlNodePtr node, + xmlXPathContextPtr ctxt) +{ + int ret =3D -1; + xmlNodePtr relnode =3D ctxt->node; + char *adapter_type =3D NULL; + char *managed =3D NULL; + + ctxt->node =3D node; + + if ((adapter_type =3D virXMLPropString(node, "type"))) { + if ((source->adapter.type =3D + virStoragePoolSourceAdapterTypeFromString(adapter_type)) <=3D= 0) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("Unknown pool adapter type '%s'"), + adapter_type); + goto cleanup; + } + + if (source->adapter.type =3D=3D + VIR_STORAGE_POOL_SOURCE_ADAPTER_TYPE_FC_HOST) { + source->adapter.data.fchost.parent =3D + virXMLPropString(node, "parent"); + managed =3D virXMLPropString(node, "managed"); + if (managed) { + source->adapter.data.fchost.managed =3D + virTristateBoolTypeFromString(managed); + if (source->adapter.data.fchost.managed < 0) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("unknown fc_host managed setting '%s'= "), + managed); + goto cleanup; + } + } + + source->adapter.data.fchost.parent_wwnn =3D + virXMLPropString(node, "parent_wwnn"); + source->adapter.data.fchost.parent_wwpn =3D + virXMLPropString(node, "parent_wwpn"); + source->adapter.data.fchost.parent_fabric_wwn =3D + virXMLPropString(node, "parent_fabric_wwn"); + + source->adapter.data.fchost.wwpn =3D virXMLPropString(node, "w= wpn"); + source->adapter.data.fchost.wwnn =3D virXMLPropString(node, "w= wnn"); + } else if (source->adapter.type =3D=3D + VIR_STORAGE_POOL_SOURCE_ADAPTER_TYPE_SCSI_HOST) { + + source->adapter.data.scsi_host.name =3D + virXMLPropString(node, "name"); + if (virXPathNode("./parentaddr", ctxt)) { + xmlNodePtr addrnode =3D virXPathNode("./parentaddr/address= ", + ctxt); + virPCIDeviceAddressPtr addr =3D + &source->adapter.data.scsi_host.parentaddr; + + if (!addrnode) { + virReportError(VIR_ERR_XML_ERROR, "%s", + _("Missing scsi_host PCI address elemen= t")); + goto cleanup; + } + source->adapter.data.scsi_host.has_parent =3D true; + if (virPCIDeviceAddressParseXML(addrnode, addr) < 0) + goto cleanup; + if ((virXPathInt("string(./parentaddr/@unique_id)", + ctxt, + &source->adapter.data.scsi_host.unique_id= ) < 0) || + (source->adapter.data.scsi_host.unique_id < 0)) { + virReportError(VIR_ERR_XML_ERROR, "%s", + _("Missing or invalid scsi adapter " + "'unique_id' value")); + goto cleanup; + } + } + } + } else { + char *wwnn =3D virXMLPropString(node, "wwnn"); + char *wwpn =3D virXMLPropString(node, "wwpn"); + char *parent =3D virXMLPropString(node, "parent"); + + /* "type" was not specified in the XML, so we must verify that + * "wwnn", "wwpn", "parent", or "parentaddr" are also not in the + * XML. If any are found, then we cannot just use "name" alone". + */ + + if (wwnn || wwpn || parent) { + VIR_FREE(wwnn); + VIR_FREE(wwpn); + VIR_FREE(parent); + virReportError(VIR_ERR_XML_ERROR, "%s", + _("Use of 'wwnn', 'wwpn', and 'parent' attribut= es " + "requires use of the adapter 'type'")); + goto cleanup; + } + + if (virXPathNode("./parentaddr", ctxt)) { + virReportError(VIR_ERR_XML_ERROR, "%s", + _("Use of 'parent' element requires use " + "of the adapter 'type'")); + goto cleanup; + } + + /* To keep back-compat, 'type' is not required to specify + * for scsi_host adapter. + */ + if ((source->adapter.data.scsi_host.name =3D + virXMLPropString(node, "name"))) + source->adapter.type =3D + VIR_STORAGE_POOL_SOURCE_ADAPTER_TYPE_SCSI_HOST; + } + + ret =3D 0; + + cleanup: + ctxt->node =3D relnode; + VIR_FREE(adapter_type); + VIR_FREE(managed); + return ret; +} + + +int +virStoragePoolSourceAdapterParseValidate(virStoragePoolDefPtr ret) +{ + if (!ret->source.adapter.type) { + virReportError(VIR_ERR_XML_ERROR, "%s", + _("missing storage pool source adapter")); + return -1; + } + + if (ret->source.adapter.type =3D=3D + VIR_STORAGE_POOL_SOURCE_ADAPTER_TYPE_FC_HOST) { + if (!ret->source.adapter.data.fchost.wwnn || + !ret->source.adapter.data.fchost.wwpn) { + virReportError(VIR_ERR_XML_ERROR, "%s", + _("'wwnn' and 'wwpn' must be specified for adap= ter " + "type 'fchost'")); + return -1; + } + + if (!virValidateWWN(ret->source.adapter.data.fchost.wwnn) || + !virValidateWWN(ret->source.adapter.data.fchost.wwpn)) + return -1; + + if ((ret->source.adapter.data.fchost.parent_wwnn && + !ret->source.adapter.data.fchost.parent_wwpn) || + (!ret->source.adapter.data.fchost.parent_wwnn && + ret->source.adapter.data.fchost.parent_wwpn)) { + virReportError(VIR_ERR_XML_ERROR, "%s", + _("must supply both parent_wwnn and " + "parent_wwpn not just one or the other")); + return -1; + } + + if (ret->source.adapter.data.fchost.parent_wwnn && + !virValidateWWN(ret->source.adapter.data.fchost.parent_wwnn)) + return -1; + + if (ret->source.adapter.data.fchost.parent_wwpn && + !virValidateWWN(ret->source.adapter.data.fchost.parent_wwpn)) + return -1; + + if (ret->source.adapter.data.fchost.parent_fabric_wwn && + !virValidateWWN(ret->source.adapter.data.fchost.parent_fabric_= wwn)) + return -1; + + } else if (ret->source.adapter.type =3D=3D + VIR_STORAGE_POOL_SOURCE_ADAPTER_TYPE_SCSI_HOST) { + if (!ret->source.adapter.data.scsi_host.name && + !ret->source.adapter.data.scsi_host.has_parent) { + virReportError(VIR_ERR_XML_ERROR, "%s", + _("Either 'name' or 'parent' must be specified " + "for the 'scsi_host' adapter")); + return -1; + } + + if (ret->source.adapter.data.scsi_host.name && + ret->source.adapter.data.scsi_host.has_parent) { + virReportError(VIR_ERR_XML_ERROR, "%s", + _("Both 'name' and 'parent' cannot be specified= " + "for the 'scsi_host' adapter")); + return -1; + } + } + + return 0; +} + + +void +virStoragePoolSourceAdapterFormat(virBufferPtr buf, + virStoragePoolSourcePtr src) +{ + virBufferAsprintf(buf, "adapter= .type)); + + if (src->adapter.type =3D=3D VIR_STORAGE_POOL_SOURCE_ADAPTER_TYPE_FC_H= OST) { + virBufferEscapeString(buf, " parent=3D'%s'", + src->adapter.data.fchost.parent); + if (src->adapter.data.fchost.managed) + virBufferAsprintf(buf, " managed=3D'%s'", + virTristateBoolTypeToString(src->adapter.dat= a.fchost.managed)); + virBufferEscapeString(buf, " parent_wwnn=3D'%s'", + src->adapter.data.fchost.parent_wwnn); + virBufferEscapeString(buf, " parent_wwpn=3D'%s'", + src->adapter.data.fchost.parent_wwpn); + virBufferEscapeString(buf, " parent_fabric_wwn=3D'%s'", + src->adapter.data.fchost.parent_fabric_wwn); + + virBufferAsprintf(buf, " wwnn=3D'%s' wwpn=3D'%s'/>\n", + src->adapter.data.fchost.wwnn, + src->adapter.data.fchost.wwpn); + } else if (src->adapter.type =3D=3D + VIR_STORAGE_POOL_SOURCE_ADAPTER_TYPE_SCSI_HOST) { + if (src->adapter.data.scsi_host.name) { + virBufferAsprintf(buf, " name=3D'%s'/>\n", + src->adapter.data.scsi_host.name); + } else { + virPCIDeviceAddress addr; + virBufferAddLit(buf, ">\n"); + virBufferAdjustIndent(buf, 2); + virBufferAsprintf(buf, "\n", + src->adapter.data.scsi_host.unique_id); + virBufferAdjustIndent(buf, 2); + addr =3D src->adapter.data.scsi_host.parentaddr; + ignore_value(virPCIDeviceAddressFormat(buf, addr, false)); + virBufferAdjustIndent(buf, -2); + virBufferAddLit(buf, "\n"); + virBufferAdjustIndent(buf, -2); + virBufferAddLit(buf, "\n"); + } + } +} diff --git a/src/conf/storage_adapter_conf.h b/src/conf/storage_adapter_con= f.h new file mode 100644 index 0000000..dec2f18 --- /dev/null +++ b/src/conf/storage_adapter_conf.h @@ -0,0 +1,43 @@ +/* + * storage_adapter_conf.h: helpers to handle storage pool adapter manipula= tion + * (derived from storage_conf.h) + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library. If not, see + * . + */ + +#ifndef __VIR_STORAGE_ADAPTER_CONF_H__ +# define __VIR_STORAGE_ADAPTER_CONF_H__ + +# include "virpci.h" +# include "virxml.h" + +# include "storage_conf.h" + +void +virStoragePoolSourceAdapterClear(virStoragePoolSourceAdapterPtr adapter); + +int +virStoragePoolDefParseSourceAdapter(virStoragePoolSourcePtr source, + xmlNodePtr node, + xmlXPathContextPtr ctxt); + +int +virStoragePoolSourceAdapterParseValidate(virStoragePoolDefPtr ret); + +void +virStoragePoolSourceAdapterFormat(virBufferPtr buf, + virStoragePoolSourcePtr src); + +#endif /* __VIR_STORAGE_ADAPTER_CONF_H__ */ diff --git a/src/conf/storage_conf.c b/src/conf/storage_conf.c index 4fa7c12..9314504 100644 --- a/src/conf/storage_conf.c +++ b/src/conf/storage_conf.c @@ -36,6 +36,7 @@ #include "virerror.h" #include "datatypes.h" #include "node_device_conf.h" +#include "storage_adapter_conf.h" #include "storage_conf.h" #include "virstoragefile.h" =20 @@ -100,10 +101,6 @@ VIR_ENUM_IMPL(virStoragePartedFs, "ext2", "ext2", "extended") =20 -VIR_ENUM_IMPL(virStoragePoolSourceAdapter, - VIR_STORAGE_POOL_SOURCE_ADAPTER_TYPE_LAST, - "default", "scsi_host", "fc_host") - typedef const char *(*virStorageVolFormatToString)(int format); typedef int (*virStorageVolFormatFromString)(const char *format); =20 @@ -342,22 +339,6 @@ virStorageVolDefFree(virStorageVolDefPtr def) VIR_FREE(def); } =20 -static void -virStoragePoolSourceAdapterClear(virStoragePoolSourceAdapterPtr adapter) -{ - if (adapter->type =3D=3D VIR_STORAGE_POOL_SOURCE_ADAPTER_TYPE_FC_HOST)= { - VIR_FREE(adapter->data.fchost.wwnn); - VIR_FREE(adapter->data.fchost.wwpn); - VIR_FREE(adapter->data.fchost.parent); - VIR_FREE(adapter->data.fchost.parent_wwnn); - VIR_FREE(adapter->data.fchost.parent_wwpn); - VIR_FREE(adapter->data.fchost.parent_fabric_wwn); - } else if (adapter->type =3D=3D - VIR_STORAGE_POOL_SOURCE_ADAPTER_TYPE_SCSI_HOST) { - VIR_FREE(adapter->data.scsi_host.name); - } -} - void virStoragePoolSourceDeviceClear(virStoragePoolSourceDevicePtr dev) { @@ -462,127 +443,6 @@ virStoragePoolObjRemove(virStoragePoolObjListPtr pool= s, } } =20 -static int -virStoragePoolDefParseSourceAdapter(virStoragePoolSourcePtr source, - xmlNodePtr node, - xmlXPathContextPtr ctxt) -{ - int ret =3D -1; - xmlNodePtr relnode =3D ctxt->node; - char *adapter_type =3D NULL; - char *managed =3D NULL; - - ctxt->node =3D node; - - if ((adapter_type =3D virXMLPropString(node, "type"))) { - if ((source->adapter.type =3D - virStoragePoolSourceAdapterTypeFromString(adapter_type)) <=3D= 0) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, - _("Unknown pool adapter type '%s'"), - adapter_type); - goto cleanup; - } - - if (source->adapter.type =3D=3D - VIR_STORAGE_POOL_SOURCE_ADAPTER_TYPE_FC_HOST) { - source->adapter.data.fchost.parent =3D - virXMLPropString(node, "parent"); - managed =3D virXMLPropString(node, "managed"); - if (managed) { - source->adapter.data.fchost.managed =3D - virTristateBoolTypeFromString(managed); - if (source->adapter.data.fchost.managed < 0) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, - _("unknown fc_host managed setting '%s'= "), - managed); - goto cleanup; - } - } - - source->adapter.data.fchost.parent_wwnn =3D - virXMLPropString(node, "parent_wwnn"); - source->adapter.data.fchost.parent_wwpn =3D - virXMLPropString(node, "parent_wwpn"); - source->adapter.data.fchost.parent_fabric_wwn =3D - virXMLPropString(node, "parent_fabric_wwn"); - - source->adapter.data.fchost.wwpn =3D virXMLPropString(node, "w= wpn"); - source->adapter.data.fchost.wwnn =3D virXMLPropString(node, "w= wnn"); - } else if (source->adapter.type =3D=3D - VIR_STORAGE_POOL_SOURCE_ADAPTER_TYPE_SCSI_HOST) { - - source->adapter.data.scsi_host.name =3D - virXMLPropString(node, "name"); - if (virXPathNode("./parentaddr", ctxt)) { - xmlNodePtr addrnode =3D virXPathNode("./parentaddr/address= ", - ctxt); - virPCIDeviceAddressPtr addr =3D - &source->adapter.data.scsi_host.parentaddr; - - if (!addrnode) { - virReportError(VIR_ERR_XML_ERROR, "%s", - _("Missing scsi_host PCI address elemen= t")); - goto cleanup; - } - source->adapter.data.scsi_host.has_parent =3D true; - if (virPCIDeviceAddressParseXML(addrnode, addr) < 0) - goto cleanup; - if ((virXPathInt("string(./parentaddr/@unique_id)", - ctxt, - &source->adapter.data.scsi_host.unique_id= ) < 0) || - (source->adapter.data.scsi_host.unique_id < 0)) { - virReportError(VIR_ERR_XML_ERROR, "%s", - _("Missing or invalid scsi adapter " - "'unique_id' value")); - goto cleanup; - } - } - } - } else { - char *wwnn =3D virXMLPropString(node, "wwnn"); - char *wwpn =3D virXMLPropString(node, "wwpn"); - char *parent =3D virXMLPropString(node, "parent"); - - /* "type" was not specified in the XML, so we must verify that - * "wwnn", "wwpn", "parent", or "parentaddr" are also not in the - * XML. If any are found, then we cannot just use "name" alone". - */ - - if (wwnn || wwpn || parent) { - VIR_FREE(wwnn); - VIR_FREE(wwpn); - VIR_FREE(parent); - virReportError(VIR_ERR_XML_ERROR, "%s", - _("Use of 'wwnn', 'wwpn', and 'parent' attribut= es " - "requires use of the adapter 'type'")); - goto cleanup; - } - - if (virXPathNode("./parentaddr", ctxt)) { - virReportError(VIR_ERR_XML_ERROR, "%s", - _("Use of 'parent' element requires use " - "of the adapter 'type'")); - goto cleanup; - } - - /* To keep back-compat, 'type' is not required to specify - * for scsi_host adapter. - */ - if ((source->adapter.data.scsi_host.name =3D - virXMLPropString(node, "name"))) - source->adapter.type =3D - VIR_STORAGE_POOL_SOURCE_ADAPTER_TYPE_SCSI_HOST; - } - - ret =3D 0; - - cleanup: - ctxt->node =3D relnode; - VIR_FREE(adapter_type); - VIR_FREE(managed); - return ret; -} - =20 static int virStoragePoolDefParseSource(xmlXPathContextPtr ctxt, @@ -850,73 +710,6 @@ virStorageDefParsePerms(xmlXPathContextPtr ctxt, return ret; } =20 -static int -virStoragePoolSourceAdapterParseValidate(virStoragePoolDefPtr ret) -{ - if (!ret->source.adapter.type) { - virReportError(VIR_ERR_XML_ERROR, "%s", - _("missing storage pool source adapter")); - return -1; - } - - if (ret->source.adapter.type =3D=3D - VIR_STORAGE_POOL_SOURCE_ADAPTER_TYPE_FC_HOST) { - if (!ret->source.adapter.data.fchost.wwnn || - !ret->source.adapter.data.fchost.wwpn) { - virReportError(VIR_ERR_XML_ERROR, "%s", - _("'wwnn' and 'wwpn' must be specified for adap= ter " - "type 'fchost'")); - return -1; - } - - if (!virValidateWWN(ret->source.adapter.data.fchost.wwnn) || - !virValidateWWN(ret->source.adapter.data.fchost.wwpn)) - return -1; - - if ((ret->source.adapter.data.fchost.parent_wwnn && - !ret->source.adapter.data.fchost.parent_wwpn) || - (!ret->source.adapter.data.fchost.parent_wwnn && - ret->source.adapter.data.fchost.parent_wwpn)) { - virReportError(VIR_ERR_XML_ERROR, "%s", - _("must supply both parent_wwnn and " - "parent_wwpn not just one or the other")); - return -1; - } - - if (ret->source.adapter.data.fchost.parent_wwnn && - !virValidateWWN(ret->source.adapter.data.fchost.parent_wwnn)) - return -1; - - if (ret->source.adapter.data.fchost.parent_wwpn && - !virValidateWWN(ret->source.adapter.data.fchost.parent_wwpn)) - return -1; - - if (ret->source.adapter.data.fchost.parent_fabric_wwn && - !virValidateWWN(ret->source.adapter.data.fchost.parent_fabric_= wwn)) - return -1; - - } else if (ret->source.adapter.type =3D=3D - VIR_STORAGE_POOL_SOURCE_ADAPTER_TYPE_SCSI_HOST) { - if (!ret->source.adapter.data.scsi_host.name && - !ret->source.adapter.data.scsi_host.has_parent) { - virReportError(VIR_ERR_XML_ERROR, "%s", - _("Either 'name' or 'parent' must be specified " - "for the 'scsi_host' adapter")); - return -1; - } - - if (ret->source.adapter.data.scsi_host.name && - ret->source.adapter.data.scsi_host.has_parent) { - virReportError(VIR_ERR_XML_ERROR, "%s", - _("Both 'name' and 'parent' cannot be specified= " - "for the 'scsi_host' adapter")); - return -1; - } - } - - return 0; -} - =20 static virStoragePoolDefPtr virStoragePoolDefParseXML(xmlXPathContextPtr ctxt) @@ -1114,50 +907,6 @@ virStoragePoolDefParseFile(const char *filename) return virStoragePoolDefParse(NULL, filename); } =20 -static void -virStoragePoolSourceAdapterFormat(virBufferPtr buf, - virStoragePoolSourcePtr src) -{ - virBufferAsprintf(buf, "adapter= .type)); - - if (src->adapter.type =3D=3D VIR_STORAGE_POOL_SOURCE_ADAPTER_TYPE_FC_H= OST) { - virBufferEscapeString(buf, " parent=3D'%s'", - src->adapter.data.fchost.parent); - if (src->adapter.data.fchost.managed) - virBufferAsprintf(buf, " managed=3D'%s'", - virTristateBoolTypeToString(src->adapter.dat= a.fchost.managed)); - virBufferEscapeString(buf, " parent_wwnn=3D'%s'", - src->adapter.data.fchost.parent_wwnn); - virBufferEscapeString(buf, " parent_wwpn=3D'%s'", - src->adapter.data.fchost.parent_wwpn); - virBufferEscapeString(buf, " parent_fabric_wwn=3D'%s'", - src->adapter.data.fchost.parent_fabric_wwn); - - virBufferAsprintf(buf, " wwnn=3D'%s' wwpn=3D'%s'/>\n", - src->adapter.data.fchost.wwnn, - src->adapter.data.fchost.wwpn); - } else if (src->adapter.type =3D=3D - VIR_STORAGE_POOL_SOURCE_ADAPTER_TYPE_SCSI_HOST) { - if (src->adapter.data.scsi_host.name) { - virBufferAsprintf(buf, " name=3D'%s'/>\n", - src->adapter.data.scsi_host.name); - } else { - virPCIDeviceAddress addr; - virBufferAddLit(buf, ">\n"); - virBufferAdjustIndent(buf, 2); - virBufferAsprintf(buf, "\n", - src->adapter.data.scsi_host.unique_id); - virBufferAdjustIndent(buf, 2); - addr =3D src->adapter.data.scsi_host.parentaddr; - ignore_value(virPCIDeviceAddressFormat(buf, addr, false)); - virBufferAdjustIndent(buf, -2); - virBufferAddLit(buf, "\n"); - virBufferAdjustIndent(buf, -2); - virBufferAddLit(buf, "\n"); - } - } -} =20 static int virStoragePoolSourceFormat(virBufferPtr buf, diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index 6c89d44..76cf2ae 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -847,6 +847,13 @@ virDomainSnapshotStateTypeToString; virDomainSnapshotUpdateRelations; =20 =20 +# conf/storage_adapter_conf.h +virStoragePoolDefParseSourceAdapter; +virStoragePoolSourceAdapterClear; +virStoragePoolSourceAdapterFormat; +virStoragePoolSourceAdapterParseValidate; + + # conf/storage_conf.h virStoragePartedFsTypeToString; virStoragePoolDefFormat; --=20 2.9.3 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Fri May 3 01:20:00 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.39 as permitted sender) client-ip=209.132.183.39; envelope-from=libvir-list-bounces@redhat.com; helo=mx6-phx2.redhat.com; Authentication-Results: mx.zoho.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.39 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; Return-Path: Received: from mx6-phx2.redhat.com (mx6-phx2.redhat.com [209.132.183.39]) by mx.zohomail.com with SMTPS id 1489180463648469.4484589572463; Fri, 10 Mar 2017 13:14:23 -0800 (PST) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by mx6-phx2.redhat.com (8.14.4/8.14.4) with ESMTP id v2ALBQHv051924; Fri, 10 Mar 2017 16:11:26 -0500 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id v2ALAvQk023921 for ; Fri, 10 Mar 2017 16:10:57 -0500 Received: from localhost.localdomain.com (ovpn-117-9.phx2.redhat.com [10.3.117.9]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id v2ALArRm011410 for ; Fri, 10 Mar 2017 16:10:57 -0500 From: John Ferlan To: libvir-list@redhat.com Date: Fri, 10 Mar 2017 16:10:38 -0500 Message-Id: <20170310211050.27784-7-jferlan@redhat.com> In-Reply-To: <20170310211050.27784-1-jferlan@redhat.com> References: <20170310211050.27784-1-jferlan@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.24 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH v3 06/18] conf: Rename API's in storage_adapter_conf 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-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Rename the API's to remove the storage pool source pieces Signed-off-by: John Ferlan --- src/conf/storage_adapter_conf.c | 14 +++++++------- src/conf/storage_adapter_conf.h | 14 +++++++------- src/conf/storage_conf.c | 8 ++++---- src/libvirt_private.syms | 8 ++++---- 4 files changed, 22 insertions(+), 22 deletions(-) diff --git a/src/conf/storage_adapter_conf.c b/src/conf/storage_adapter_con= f.c index 3a16bcc..4f5b665 100644 --- a/src/conf/storage_adapter_conf.c +++ b/src/conf/storage_adapter_conf.c @@ -38,7 +38,7 @@ VIR_ENUM_IMPL(virStoragePoolSourceAdapter, =20 =20 void -virStoragePoolSourceAdapterClear(virStoragePoolSourceAdapterPtr adapter) +virStorageAdapterClear(virStoragePoolSourceAdapterPtr adapter) { if (adapter->type =3D=3D VIR_STORAGE_POOL_SOURCE_ADAPTER_TYPE_FC_HOST)= { VIR_FREE(adapter->data.fchost.wwnn); @@ -55,9 +55,9 @@ virStoragePoolSourceAdapterClear(virStoragePoolSourceAdap= terPtr adapter) =20 =20 int -virStoragePoolDefParseSourceAdapter(virStoragePoolSourcePtr source, - xmlNodePtr node, - xmlXPathContextPtr ctxt) +virStorageAdapterParseXML(virStoragePoolSourcePtr source, + xmlNodePtr node, + xmlXPathContextPtr ctxt) { int ret =3D -1; xmlNodePtr relnode =3D ctxt->node; @@ -177,7 +177,7 @@ virStoragePoolDefParseSourceAdapter(virStoragePoolSourc= ePtr source, =20 =20 int -virStoragePoolSourceAdapterParseValidate(virStoragePoolDefPtr ret) +virStorageAdapterParseValidate(virStoragePoolDefPtr ret) { if (!ret->source.adapter.type) { virReportError(VIR_ERR_XML_ERROR, "%s", @@ -245,8 +245,8 @@ virStoragePoolSourceAdapterParseValidate(virStoragePool= DefPtr ret) =20 =20 void -virStoragePoolSourceAdapterFormat(virBufferPtr buf, - virStoragePoolSourcePtr src) +virStorageAdapterFormat(virBufferPtr buf, + virStoragePoolSourcePtr src) { virBufferAsprintf(buf, "adapter= .type)); diff --git a/src/conf/storage_adapter_conf.h b/src/conf/storage_adapter_con= f.h index dec2f18..ec812a1 100644 --- a/src/conf/storage_adapter_conf.h +++ b/src/conf/storage_adapter_conf.h @@ -26,18 +26,18 @@ # include "storage_conf.h" =20 void -virStoragePoolSourceAdapterClear(virStoragePoolSourceAdapterPtr adapter); +virStorageAdapterClear(virStoragePoolSourceAdapterPtr adapter); =20 int -virStoragePoolDefParseSourceAdapter(virStoragePoolSourcePtr source, - xmlNodePtr node, - xmlXPathContextPtr ctxt); +virStorageAdapterParseXML(virStoragePoolSourcePtr source, + xmlNodePtr node, + xmlXPathContextPtr ctxt); =20 int -virStoragePoolSourceAdapterParseValidate(virStoragePoolDefPtr ret); +virStorageAdapterParseValidate(virStoragePoolDefPtr ret); =20 void -virStoragePoolSourceAdapterFormat(virBufferPtr buf, - virStoragePoolSourcePtr src); +virStorageAdapterFormat(virBufferPtr buf, + virStoragePoolSourcePtr src); =20 #endif /* __VIR_STORAGE_ADAPTER_CONF_H__ */ diff --git a/src/conf/storage_conf.c b/src/conf/storage_conf.c index 9314504..8709101 100644 --- a/src/conf/storage_conf.c +++ b/src/conf/storage_conf.c @@ -363,7 +363,7 @@ virStoragePoolSourceClear(virStoragePoolSourcePtr sourc= e) VIR_FREE(source->devices); VIR_FREE(source->dir); VIR_FREE(source->name); - virStoragePoolSourceAdapterClear(&source->adapter); + virStorageAdapterClear(&source->adapter); VIR_FREE(source->initiator.iqn); virStorageAuthDefFree(source->auth); VIR_FREE(source->vendor); @@ -565,7 +565,7 @@ virStoragePoolDefParseSource(xmlXPathContextPtr ctxt, goto cleanup; =20 if ((adapternode =3D virXPathNode("./adapter", ctxt))) { - if (virStoragePoolDefParseSourceAdapter(source, adapternode, ctxt)= < 0) + if (virStorageAdapterParseXML(source, adapternode, ctxt) < 0) goto cleanup; } =20 @@ -802,7 +802,7 @@ virStoragePoolDefParseXML(xmlXPathContextPtr ctxt) } =20 if ((options->flags & VIR_STORAGE_POOL_SOURCE_ADAPTER) && - (virStoragePoolSourceAdapterParseValidate(ret)) < 0) + (virStorageAdapterParseValidate(ret)) < 0) goto error; =20 /* If DEVICE is the only source type, then its required */ @@ -960,7 +960,7 @@ virStoragePoolSourceFormat(virBufferPtr buf, if ((options->flags & VIR_STORAGE_POOL_SOURCE_ADAPTER) && (src->adapter.type =3D=3D VIR_STORAGE_POOL_SOURCE_ADAPTER_TYPE_FC_= HOST || src->adapter.type =3D=3D VIR_STORAGE_POOL_SOURCE_ADAPTER_TYPE_SCS= I_HOST)) - virStoragePoolSourceAdapterFormat(buf, src); + virStorageAdapterFormat(buf, src); =20 if (options->flags & VIR_STORAGE_POOL_SOURCE_NAME) virBufferEscapeString(buf, "%s\n", src->name); diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index 76cf2ae..6a2bdf2 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -848,10 +848,10 @@ virDomainSnapshotUpdateRelations; =20 =20 # conf/storage_adapter_conf.h -virStoragePoolDefParseSourceAdapter; -virStoragePoolSourceAdapterClear; -virStoragePoolSourceAdapterFormat; -virStoragePoolSourceAdapterParseValidate; +virStorageAdapterClear; +virStorageAdapterFormat; +virStorageAdapterParseValidate; +virStorageAdapterParseXML; =20 =20 # conf/storage_conf.h --=20 2.9.3 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Fri May 3 01:20:00 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.37 as permitted sender) client-ip=209.132.183.37; envelope-from=libvir-list-bounces@redhat.com; helo=mx5-phx2.redhat.com; Authentication-Results: mx.zoho.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.37 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; Return-Path: Received: from mx5-phx2.redhat.com (mx5-phx2.redhat.com [209.132.183.37]) by mx.zohomail.com with SMTPS id 14891804774441002.5784952604589; Fri, 10 Mar 2017 13:14:37 -0800 (PST) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by mx5-phx2.redhat.com (8.14.4/8.14.4) with ESMTP id v2ALBSYf045077; Fri, 10 Mar 2017 16:11:28 -0500 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id v2ALAv3a023926 for ; Fri, 10 Mar 2017 16:10:57 -0500 Received: from localhost.localdomain.com (ovpn-117-9.phx2.redhat.com [10.3.117.9]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id v2ALArRn011410 for ; Fri, 10 Mar 2017 16:10:57 -0500 From: John Ferlan To: libvir-list@redhat.com Date: Fri, 10 Mar 2017 16:10:39 -0500 Message-Id: <20170310211050.27784-8-jferlan@redhat.com> In-Reply-To: <20170310211050.27784-1-jferlan@redhat.com> References: <20170310211050.27784-1-jferlan@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.24 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH v3 07/18] conf: Extract FCHost adapter type processing into their own helpers 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-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Rather than have lots of ugly inline code create helpers to try and make things more readable. While creating the helpers realign the code as necessary. Signed-off-by: John Ferlan --- src/conf/storage_adapter_conf.c | 194 +++++++++++++++++++++++-------------= ---- 1 file changed, 114 insertions(+), 80 deletions(-) diff --git a/src/conf/storage_adapter_conf.c b/src/conf/storage_adapter_con= f.c index 4f5b665..a2d4a3a 100644 --- a/src/conf/storage_adapter_conf.c +++ b/src/conf/storage_adapter_conf.c @@ -37,16 +37,23 @@ VIR_ENUM_IMPL(virStoragePoolSourceAdapter, "default", "scsi_host", "fc_host") =20 =20 +static void +virStorageAdapterFCHostClear(virStoragePoolSourceAdapterPtr adapter) +{ + VIR_FREE(adapter->data.fchost.wwnn); + VIR_FREE(adapter->data.fchost.wwpn); + VIR_FREE(adapter->data.fchost.parent); + VIR_FREE(adapter->data.fchost.parent_wwnn); + VIR_FREE(adapter->data.fchost.parent_wwpn); + VIR_FREE(adapter->data.fchost.parent_fabric_wwn); +} + + void virStorageAdapterClear(virStoragePoolSourceAdapterPtr adapter) { if (adapter->type =3D=3D VIR_STORAGE_POOL_SOURCE_ADAPTER_TYPE_FC_HOST)= { - VIR_FREE(adapter->data.fchost.wwnn); - VIR_FREE(adapter->data.fchost.wwpn); - VIR_FREE(adapter->data.fchost.parent); - VIR_FREE(adapter->data.fchost.parent_wwnn); - VIR_FREE(adapter->data.fchost.parent_wwpn); - VIR_FREE(adapter->data.fchost.parent_fabric_wwn); + virStorageAdapterFCHostClear(adapter); } else if (adapter->type =3D=3D VIR_STORAGE_POOL_SOURCE_ADAPTER_TYPE_SCSI_HOST) { VIR_FREE(adapter->data.scsi_host.name); @@ -54,6 +61,40 @@ virStorageAdapterClear(virStoragePoolSourceAdapterPtr ad= apter) } =20 =20 +static int +virStorageAdapterFCHostParseXML(xmlNodePtr node, + virStoragePoolSourcePtr source) +{ + char *managed =3D NULL; + + source->adapter.data.fchost.parent =3D virXMLPropString(node, "parent"= ); + if ((managed =3D virXMLPropString(node, "managed"))) { + source->adapter.data.fchost.managed =3D + virTristateBoolTypeFromString(managed); + if (source->adapter.data.fchost.managed < 0) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("unknown fc_host managed setting '%s'"), + managed); + VIR_FREE(managed); + return -1; + } + } + + source->adapter.data.fchost.parent_wwnn =3D + virXMLPropString(node, "parent_wwnn"); + source->adapter.data.fchost.parent_wwpn =3D + virXMLPropString(node, "parent_wwpn"); + source->adapter.data.fchost.parent_fabric_wwn =3D + virXMLPropString(node, "parent_fabric_wwn"); + + source->adapter.data.fchost.wwpn =3D virXMLPropString(node, "wwpn"); + source->adapter.data.fchost.wwnn =3D virXMLPropString(node, "wwnn"); + + VIR_FREE(managed); + return 0; +} + + int virStorageAdapterParseXML(virStoragePoolSourcePtr source, xmlNodePtr node, @@ -62,7 +103,6 @@ virStorageAdapterParseXML(virStoragePoolSourcePtr source, int ret =3D -1; xmlNodePtr relnode =3D ctxt->node; char *adapter_type =3D NULL; - char *managed =3D NULL; =20 ctxt->node =3D node; =20 @@ -77,29 +117,8 @@ virStorageAdapterParseXML(virStoragePoolSourcePtr sourc= e, =20 if (source->adapter.type =3D=3D VIR_STORAGE_POOL_SOURCE_ADAPTER_TYPE_FC_HOST) { - source->adapter.data.fchost.parent =3D - virXMLPropString(node, "parent"); - managed =3D virXMLPropString(node, "managed"); - if (managed) { - source->adapter.data.fchost.managed =3D - virTristateBoolTypeFromString(managed); - if (source->adapter.data.fchost.managed < 0) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, - _("unknown fc_host managed setting '%s'= "), - managed); - goto cleanup; - } - } - - source->adapter.data.fchost.parent_wwnn =3D - virXMLPropString(node, "parent_wwnn"); - source->adapter.data.fchost.parent_wwpn =3D - virXMLPropString(node, "parent_wwpn"); - source->adapter.data.fchost.parent_fabric_wwn =3D - virXMLPropString(node, "parent_fabric_wwn"); - - source->adapter.data.fchost.wwpn =3D virXMLPropString(node, "w= wpn"); - source->adapter.data.fchost.wwnn =3D virXMLPropString(node, "w= wnn"); + if (virStorageAdapterFCHostParseXML(node, source) < 0) + goto cleanup; } else if (source->adapter.type =3D=3D VIR_STORAGE_POOL_SOURCE_ADAPTER_TYPE_SCSI_HOST) { =20 @@ -171,56 +190,63 @@ virStorageAdapterParseXML(virStoragePoolSourcePtr sou= rce, cleanup: ctxt->node =3D relnode; VIR_FREE(adapter_type); - VIR_FREE(managed); return ret; } =20 =20 -int -virStorageAdapterParseValidate(virStoragePoolDefPtr ret) +static int +virStorageAdapterFCHostParseValidate(virStoragePoolDefPtr ret) { - if (!ret->source.adapter.type) { + if (!ret->source.adapter.data.fchost.wwnn || + !ret->source.adapter.data.fchost.wwpn) { virReportError(VIR_ERR_XML_ERROR, "%s", - _("missing storage pool source adapter")); + _("'wwnn' and 'wwpn' must be specified for adapter " + "type 'fchost'")); return -1; } =20 - if (ret->source.adapter.type =3D=3D - VIR_STORAGE_POOL_SOURCE_ADAPTER_TYPE_FC_HOST) { - if (!ret->source.adapter.data.fchost.wwnn || - !ret->source.adapter.data.fchost.wwpn) { - virReportError(VIR_ERR_XML_ERROR, "%s", - _("'wwnn' and 'wwpn' must be specified for adap= ter " - "type 'fchost'")); - return -1; - } + if (!virValidateWWN(ret->source.adapter.data.fchost.wwnn) || + !virValidateWWN(ret->source.adapter.data.fchost.wwpn)) + return -1; =20 - if (!virValidateWWN(ret->source.adapter.data.fchost.wwnn) || - !virValidateWWN(ret->source.adapter.data.fchost.wwpn)) - return -1; + if ((ret->source.adapter.data.fchost.parent_wwnn && + !ret->source.adapter.data.fchost.parent_wwpn) || + (!ret->source.adapter.data.fchost.parent_wwnn && + ret->source.adapter.data.fchost.parent_wwpn)) { + virReportError(VIR_ERR_XML_ERROR, "%s", + _("must supply both parent_wwnn and " + "parent_wwpn not just one or the other")); + return -1; + } =20 - if ((ret->source.adapter.data.fchost.parent_wwnn && - !ret->source.adapter.data.fchost.parent_wwpn) || - (!ret->source.adapter.data.fchost.parent_wwnn && - ret->source.adapter.data.fchost.parent_wwpn)) { - virReportError(VIR_ERR_XML_ERROR, "%s", - _("must supply both parent_wwnn and " - "parent_wwpn not just one or the other")); - return -1; - } + if (ret->source.adapter.data.fchost.parent_wwnn && + !virValidateWWN(ret->source.adapter.data.fchost.parent_wwnn)) + return -1; =20 - if (ret->source.adapter.data.fchost.parent_wwnn && - !virValidateWWN(ret->source.adapter.data.fchost.parent_wwnn)) - return -1; + if (ret->source.adapter.data.fchost.parent_wwpn && + !virValidateWWN(ret->source.adapter.data.fchost.parent_wwpn)) + return -1; =20 - if (ret->source.adapter.data.fchost.parent_wwpn && - !virValidateWWN(ret->source.adapter.data.fchost.parent_wwpn)) - return -1; + if (ret->source.adapter.data.fchost.parent_fabric_wwn && + !virValidateWWN(ret->source.adapter.data.fchost.parent_fabric_wwn)) + return -1; =20 - if (ret->source.adapter.data.fchost.parent_fabric_wwn && - !virValidateWWN(ret->source.adapter.data.fchost.parent_fabric_= wwn)) - return -1; + return 0; +} =20 + +int +virStorageAdapterParseValidate(virStoragePoolDefPtr ret) +{ + if (!ret->source.adapter.type) { + virReportError(VIR_ERR_XML_ERROR, "%s", + _("missing storage pool source adapter")); + return -1; + } + + if (ret->source.adapter.type =3D=3D + VIR_STORAGE_POOL_SOURCE_ADAPTER_TYPE_FC_HOST) { + return virStorageAdapterFCHostParseValidate(ret); } else if (ret->source.adapter.type =3D=3D VIR_STORAGE_POOL_SOURCE_ADAPTER_TYPE_SCSI_HOST) { if (!ret->source.adapter.data.scsi_host.name && @@ -244,6 +270,28 @@ virStorageAdapterParseValidate(virStoragePoolDefPtr re= t) } =20 =20 +static void +virStorageAdapterFCHostFormat(virBufferPtr buf, + virStoragePoolSourcePtr src) +{ + virBufferEscapeString(buf, " parent=3D'%s'", + src->adapter.data.fchost.parent); + if (src->adapter.data.fchost.managed) + virBufferAsprintf(buf, " managed=3D'%s'", + virTristateBoolTypeToString(src->adapter.data.fc= host.managed)); + virBufferEscapeString(buf, " parent_wwnn=3D'%s'", + src->adapter.data.fchost.parent_wwnn); + virBufferEscapeString(buf, " parent_wwpn=3D'%s'", + src->adapter.data.fchost.parent_wwpn); + virBufferEscapeString(buf, " parent_fabric_wwn=3D'%s'", + src->adapter.data.fchost.parent_fabric_wwn); + + virBufferAsprintf(buf, " wwnn=3D'%s' wwpn=3D'%s'/>\n", + src->adapter.data.fchost.wwnn, + src->adapter.data.fchost.wwpn); +} + + void virStorageAdapterFormat(virBufferPtr buf, virStoragePoolSourcePtr src) @@ -252,21 +300,7 @@ virStorageAdapterFormat(virBufferPtr buf, virStoragePoolSourceAdapterTypeToString(src->adapter= .type)); =20 if (src->adapter.type =3D=3D VIR_STORAGE_POOL_SOURCE_ADAPTER_TYPE_FC_H= OST) { - virBufferEscapeString(buf, " parent=3D'%s'", - src->adapter.data.fchost.parent); - if (src->adapter.data.fchost.managed) - virBufferAsprintf(buf, " managed=3D'%s'", - virTristateBoolTypeToString(src->adapter.dat= a.fchost.managed)); - virBufferEscapeString(buf, " parent_wwnn=3D'%s'", - src->adapter.data.fchost.parent_wwnn); - virBufferEscapeString(buf, " parent_wwpn=3D'%s'", - src->adapter.data.fchost.parent_wwpn); - virBufferEscapeString(buf, " parent_fabric_wwn=3D'%s'", - src->adapter.data.fchost.parent_fabric_wwn); - - virBufferAsprintf(buf, " wwnn=3D'%s' wwpn=3D'%s'/>\n", - src->adapter.data.fchost.wwnn, - src->adapter.data.fchost.wwpn); + virStorageAdapterFCHostFormat(buf, src); } else if (src->adapter.type =3D=3D VIR_STORAGE_POOL_SOURCE_ADAPTER_TYPE_SCSI_HOST) { if (src->adapter.data.scsi_host.name) { --=20 2.9.3 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Fri May 3 01:20:00 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.39 as permitted sender) client-ip=209.132.183.39; envelope-from=libvir-list-bounces@redhat.com; helo=mx6-phx2.redhat.com; Authentication-Results: mx.zoho.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.39 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; Return-Path: Received: from mx6-phx2.redhat.com (mx6-phx2.redhat.com [209.132.183.39]) by mx.zohomail.com with SMTPS id 1489180502650853.7566350110285; Fri, 10 Mar 2017 13:15:02 -0800 (PST) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by mx6-phx2.redhat.com (8.14.4/8.14.4) with ESMTP id v2ALBUMi051955; Fri, 10 Mar 2017 16:11:30 -0500 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id v2ALAwZv023931 for ; Fri, 10 Mar 2017 16:10:58 -0500 Received: from localhost.localdomain.com (ovpn-117-9.phx2.redhat.com [10.3.117.9]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id v2ALArRo011410 for ; Fri, 10 Mar 2017 16:10:57 -0500 From: John Ferlan To: libvir-list@redhat.com Date: Fri, 10 Mar 2017 16:10:40 -0500 Message-Id: <20170310211050.27784-9-jferlan@redhat.com> In-Reply-To: <20170310211050.27784-1-jferlan@redhat.com> References: <20170310211050.27784-1-jferlan@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.24 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH v3 08/18] conf: Extract SCSI adapter type processing into their own helpers 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-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Rather than have lots of ugly inline code create helpers to try and make things more readable. While creating the helpers realign the code as necessary. Signed-off-by: John Ferlan --- src/conf/storage_adapter_conf.c | 239 +++++++++++++++++++++++-------------= ---- 1 file changed, 138 insertions(+), 101 deletions(-) diff --git a/src/conf/storage_adapter_conf.c b/src/conf/storage_adapter_con= f.c index a2d4a3a..a361c34 100644 --- a/src/conf/storage_adapter_conf.c +++ b/src/conf/storage_adapter_conf.c @@ -52,12 +52,11 @@ virStorageAdapterFCHostClear(virStoragePoolSourceAdapte= rPtr adapter) void virStorageAdapterClear(virStoragePoolSourceAdapterPtr adapter) { - if (adapter->type =3D=3D VIR_STORAGE_POOL_SOURCE_ADAPTER_TYPE_FC_HOST)= { + if (adapter->type =3D=3D VIR_STORAGE_POOL_SOURCE_ADAPTER_TYPE_FC_HOST) virStorageAdapterFCHostClear(adapter); - } else if (adapter->type =3D=3D - VIR_STORAGE_POOL_SOURCE_ADAPTER_TYPE_SCSI_HOST) { + + if (adapter->type =3D=3D VIR_STORAGE_POOL_SOURCE_ADAPTER_TYPE_SCSI_HOS= T) VIR_FREE(adapter->data.scsi_host.name); - } } =20 =20 @@ -95,6 +94,83 @@ virStorageAdapterFCHostParseXML(xmlNodePtr node, } =20 =20 +static int +virStorageAdapterSCSIHostParseXML(xmlNodePtr node, + xmlXPathContextPtr ctxt, + virStoragePoolSourcePtr source) +{ + source->adapter.data.scsi_host.name =3D + virXMLPropString(node, "name"); + if (virXPathNode("./parentaddr", ctxt)) { + xmlNodePtr addrnode =3D virXPathNode("./parentaddr/address", ctxt); + virPCIDeviceAddressPtr addr =3D + &source->adapter.data.scsi_host.parentaddr; + + if (!addrnode) { + virReportError(VIR_ERR_XML_ERROR, "%s", + _("Missing scsi_host PCI address element")); + return -1; + } + source->adapter.data.scsi_host.has_parent =3D true; + if (virPCIDeviceAddressParseXML(addrnode, addr) < 0) + return -1; + if ((virXPathInt("string(./parentaddr/@unique_id)", + ctxt, + &source->adapter.data.scsi_host.unique_id) < 0) || + (source->adapter.data.scsi_host.unique_id < 0)) { + virReportError(VIR_ERR_XML_ERROR, "%s", + _("Missing or invalid scsi adapter " + "'unique_id' value")); + return -1; + } + } + + return 0; +} + + +static int +virStorageAdapterLegacyParseXML(xmlNodePtr node, + xmlXPathContextPtr ctxt, + virStoragePoolSourcePtr source) +{ + char *wwnn =3D virXMLPropString(node, "wwnn"); + char *wwpn =3D virXMLPropString(node, "wwpn"); + char *parent =3D virXMLPropString(node, "parent"); + + /* "type" was not specified in the XML, so we must verify that + * "wwnn", "wwpn", "parent", or "parentaddr" are also not in the + * XML. If any are found, then we cannot just use "name" alone". + */ + if (wwnn || wwpn || parent) { + VIR_FREE(wwnn); + VIR_FREE(wwpn); + VIR_FREE(parent); + virReportError(VIR_ERR_XML_ERROR, "%s", + _("Use of 'wwnn', 'wwpn', and 'parent' attributes " + "requires use of the adapter 'type'")); + return -1; + } + + if (virXPathNode("./parentaddr", ctxt)) { + virReportError(VIR_ERR_XML_ERROR, "%s", + _("Use of 'parent' element requires use " + "of the adapter 'type'")); + return -1; + } + + /* To keep back-compat, 'type' is not required to specify + * for scsi_host adapter. + */ + if ((source->adapter.data.scsi_host.name =3D + virXMLPropString(node, "name"))) + source->adapter.type =3D + VIR_STORAGE_POOL_SOURCE_ADAPTER_TYPE_SCSI_HOST; + + return 0; +} + + int virStorageAdapterParseXML(virStoragePoolSourcePtr source, xmlNodePtr node, @@ -121,68 +197,13 @@ virStorageAdapterParseXML(virStoragePoolSourcePtr sou= rce, goto cleanup; } else if (source->adapter.type =3D=3D VIR_STORAGE_POOL_SOURCE_ADAPTER_TYPE_SCSI_HOST) { + if (virStorageAdapterSCSIHostParseXML(node, ctxt, source) < 0) + goto cleanup; =20 - source->adapter.data.scsi_host.name =3D - virXMLPropString(node, "name"); - if (virXPathNode("./parentaddr", ctxt)) { - xmlNodePtr addrnode =3D virXPathNode("./parentaddr/address= ", - ctxt); - virPCIDeviceAddressPtr addr =3D - &source->adapter.data.scsi_host.parentaddr; - - if (!addrnode) { - virReportError(VIR_ERR_XML_ERROR, "%s", - _("Missing scsi_host PCI address elemen= t")); - goto cleanup; - } - source->adapter.data.scsi_host.has_parent =3D true; - if (virPCIDeviceAddressParseXML(addrnode, addr) < 0) - goto cleanup; - if ((virXPathInt("string(./parentaddr/@unique_id)", - ctxt, - &source->adapter.data.scsi_host.unique_id= ) < 0) || - (source->adapter.data.scsi_host.unique_id < 0)) { - virReportError(VIR_ERR_XML_ERROR, "%s", - _("Missing or invalid scsi adapter " - "'unique_id' value")); - goto cleanup; - } - } } } else { - char *wwnn =3D virXMLPropString(node, "wwnn"); - char *wwpn =3D virXMLPropString(node, "wwpn"); - char *parent =3D virXMLPropString(node, "parent"); - - /* "type" was not specified in the XML, so we must verify that - * "wwnn", "wwpn", "parent", or "parentaddr" are also not in the - * XML. If any are found, then we cannot just use "name" alone". - */ - - if (wwnn || wwpn || parent) { - VIR_FREE(wwnn); - VIR_FREE(wwpn); - VIR_FREE(parent); - virReportError(VIR_ERR_XML_ERROR, "%s", - _("Use of 'wwnn', 'wwpn', and 'parent' attribut= es " - "requires use of the adapter 'type'")); + if (virStorageAdapterLegacyParseXML(node, ctxt, source) < 0) goto cleanup; - } - - if (virXPathNode("./parentaddr", ctxt)) { - virReportError(VIR_ERR_XML_ERROR, "%s", - _("Use of 'parent' element requires use " - "of the adapter 'type'")); - goto cleanup; - } - - /* To keep back-compat, 'type' is not required to specify - * for scsi_host adapter. - */ - if ((source->adapter.data.scsi_host.name =3D - virXMLPropString(node, "name"))) - source->adapter.type =3D - VIR_STORAGE_POOL_SOURCE_ADAPTER_TYPE_SCSI_HOST; } =20 ret =3D 0; @@ -235,6 +256,29 @@ virStorageAdapterFCHostParseValidate(virStoragePoolDef= Ptr ret) } =20 =20 +static int +virStorageAdapterSCSIHostParseValidate(virStoragePoolDefPtr ret) +{ + if (!ret->source.adapter.data.scsi_host.name && + !ret->source.adapter.data.scsi_host.has_parent) { + virReportError(VIR_ERR_XML_ERROR, "%s", + _("Either 'name' or 'parent' must be specified " + "for the 'scsi_host' adapter")); + return -1; + } + + if (ret->source.adapter.data.scsi_host.name && + ret->source.adapter.data.scsi_host.has_parent) { + virReportError(VIR_ERR_XML_ERROR, "%s", + _("Both 'name' and 'parent' cannot be specified " + "for the 'scsi_host' adapter")); + return -1; + } + + return 0; +} + + int virStorageAdapterParseValidate(virStoragePoolDefPtr ret) { @@ -245,26 +289,12 @@ virStorageAdapterParseValidate(virStoragePoolDefPtr r= et) } =20 if (ret->source.adapter.type =3D=3D - VIR_STORAGE_POOL_SOURCE_ADAPTER_TYPE_FC_HOST) { + VIR_STORAGE_POOL_SOURCE_ADAPTER_TYPE_FC_HOST) return virStorageAdapterFCHostParseValidate(ret); - } else if (ret->source.adapter.type =3D=3D - VIR_STORAGE_POOL_SOURCE_ADAPTER_TYPE_SCSI_HOST) { - if (!ret->source.adapter.data.scsi_host.name && - !ret->source.adapter.data.scsi_host.has_parent) { - virReportError(VIR_ERR_XML_ERROR, "%s", - _("Either 'name' or 'parent' must be specified " - "for the 'scsi_host' adapter")); - return -1; - } =20 - if (ret->source.adapter.data.scsi_host.name && - ret->source.adapter.data.scsi_host.has_parent) { - virReportError(VIR_ERR_XML_ERROR, "%s", - _("Both 'name' and 'parent' cannot be specified= " - "for the 'scsi_host' adapter")); - return -1; - } - } + if (ret->source.adapter.type =3D=3D + VIR_STORAGE_POOL_SOURCE_ADAPTER_TYPE_SCSI_HOST) + return virStorageAdapterSCSIHostParseValidate(ret); =20 return 0; } @@ -292,6 +322,30 @@ virStorageAdapterFCHostFormat(virBufferPtr buf, } =20 =20 +static void +virStorageAdapterSCSIHostFormat(virBufferPtr buf, + virStoragePoolSourcePtr src) +{ + if (src->adapter.data.scsi_host.name) { + virBufferAsprintf(buf, " name=3D'%s'/>\n", + src->adapter.data.scsi_host.name); + } else { + virPCIDeviceAddress addr; + virBufferAddLit(buf, ">\n"); + virBufferAdjustIndent(buf, 2); + virBufferAsprintf(buf, "\n", + src->adapter.data.scsi_host.unique_id); + virBufferAdjustIndent(buf, 2); + addr =3D src->adapter.data.scsi_host.parentaddr; + ignore_value(virPCIDeviceAddressFormat(buf, addr, false)); + virBufferAdjustIndent(buf, -2); + virBufferAddLit(buf, "\n"); + virBufferAdjustIndent(buf, -2); + virBufferAddLit(buf, "\n"); + } +} + + void virStorageAdapterFormat(virBufferPtr buf, virStoragePoolSourcePtr src) @@ -299,26 +353,9 @@ virStorageAdapterFormat(virBufferPtr buf, virBufferAsprintf(buf, "adapter= .type)); =20 - if (src->adapter.type =3D=3D VIR_STORAGE_POOL_SOURCE_ADAPTER_TYPE_FC_H= OST) { + if (src->adapter.type =3D=3D VIR_STORAGE_POOL_SOURCE_ADAPTER_TYPE_FC_H= OST) virStorageAdapterFCHostFormat(buf, src); - } else if (src->adapter.type =3D=3D - VIR_STORAGE_POOL_SOURCE_ADAPTER_TYPE_SCSI_HOST) { - if (src->adapter.data.scsi_host.name) { - virBufferAsprintf(buf, " name=3D'%s'/>\n", - src->adapter.data.scsi_host.name); - } else { - virPCIDeviceAddress addr; - virBufferAddLit(buf, ">\n"); - virBufferAdjustIndent(buf, 2); - virBufferAsprintf(buf, "\n", - src->adapter.data.scsi_host.unique_id); - virBufferAdjustIndent(buf, 2); - addr =3D src->adapter.data.scsi_host.parentaddr; - ignore_value(virPCIDeviceAddressFormat(buf, addr, false)); - virBufferAdjustIndent(buf, -2); - virBufferAddLit(buf, "\n"); - virBufferAdjustIndent(buf, -2); - virBufferAddLit(buf, "\n"); - } - } + + if (src->adapter.type =3D=3D VIR_STORAGE_POOL_SOURCE_ADAPTER_TYPE_SCSI= _HOST) + virStorageAdapterSCSIHostFormat(buf, src); } --=20 2.9.3 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Fri May 3 01:20:00 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.24 as permitted sender) client-ip=209.132.183.24; envelope-from=libvir-list-bounces@redhat.com; helo=mx3-phx2.redhat.com; Authentication-Results: mx.zoho.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.24 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; Return-Path: Received: from mx3-phx2.redhat.com (mx3-phx2.redhat.com [209.132.183.24]) by mx.zohomail.com with SMTPS id 1489180495264725.2080235873142; Fri, 10 Mar 2017 13:14:55 -0800 (PST) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by mx3-phx2.redhat.com (8.13.8/8.13.8) with ESMTP id v2ALBVj7006722; Fri, 10 Mar 2017 16:11:31 -0500 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id v2ALAwNE023955 for ; Fri, 10 Mar 2017 16:10:58 -0500 Received: from localhost.localdomain.com (ovpn-117-9.phx2.redhat.com [10.3.117.9]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id v2ALArRp011410 for ; Fri, 10 Mar 2017 16:10:58 -0500 From: John Ferlan To: libvir-list@redhat.com Date: Fri, 10 Mar 2017 16:10:41 -0500 Message-Id: <20170310211050.27784-10-jferlan@redhat.com> In-Reply-To: <20170310211050.27784-1-jferlan@redhat.com> References: <20170310211050.27784-1-jferlan@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.24 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH v3 09/18] conf: Split up virStoragePoolSourceAdapter 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-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Create typedef'd substructures and rework typedef to utilize. Signed-off-by: John Ferlan --- src/conf/storage_conf.h | 38 +++++++++++++++++++++++--------------- 1 file changed, 23 insertions(+), 15 deletions(-) diff --git a/src/conf/storage_conf.h b/src/conf/storage_conf.h index 1723afc..1012e74 100644 --- a/src/conf/storage_conf.h +++ b/src/conf/storage_conf.h @@ -179,27 +179,35 @@ typedef enum { } virStoragePoolSourceAdapterType; VIR_ENUM_DECL(virStoragePoolSourceAdapter) =20 +typedef struct _virStorageAdapterSCSIHost virStorageAdapterSCSIHost; +typedef virStorageAdapterSCSIHost *virStorageAdapterSCSIHostPtr; +struct _virStorageAdapterSCSIHost { + char *name; + virPCIDeviceAddress parentaddr; /* host address */ + int unique_id; + bool has_parent; +}; + +typedef struct _virStorageAdapterFCHost virStorageAdapterFCHost; +typedef virStorageAdapterFCHost *virStorageAdapterFCHostPtr; +struct _virStorageAdapterFCHost { + char *parent; + char *parent_wwnn; + char *parent_wwpn; + char *parent_fabric_wwn; + char *wwnn; + char *wwpn; + int managed; /* enum virTristateSwitch */ +}; + typedef struct _virStoragePoolSourceAdapter virStoragePoolSourceAdapter; typedef virStoragePoolSourceAdapter *virStoragePoolSourceAdapterPtr; struct _virStoragePoolSourceAdapter { int type; /* virStoragePoolSourceAdapterType */ =20 union { - struct { - char *name; - virPCIDeviceAddress parentaddr; /* host address */ - int unique_id; - bool has_parent; - } scsi_host; - struct { - char *parent; - char *parent_wwnn; - char *parent_wwpn; - char *parent_fabric_wwn; - char *wwnn; - char *wwpn; - int managed; /* enum virTristateSwitch */ - } fchost; + virStorageAdapterSCSIHost scsi_host; + virStorageAdapterFCHost fchost; } data; }; =20 --=20 2.9.3 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Fri May 3 01:20:00 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.39 as permitted sender) client-ip=209.132.183.39; envelope-from=libvir-list-bounces@redhat.com; helo=mx6-phx2.redhat.com; Authentication-Results: mx.zoho.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.39 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; Return-Path: Received: from mx6-phx2.redhat.com (mx6-phx2.redhat.com [209.132.183.39]) by mx.zohomail.com with SMTPS id 1489180471922486.9565657085842; Fri, 10 Mar 2017 13:14:31 -0800 (PST) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by mx6-phx2.redhat.com (8.14.4/8.14.4) with ESMTP id v2ALBSLO051944; Fri, 10 Mar 2017 16:11:28 -0500 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id v2ALAx5e023963 for ; Fri, 10 Mar 2017 16:10:59 -0500 Received: from localhost.localdomain.com (ovpn-117-9.phx2.redhat.com [10.3.117.9]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id v2ALArRq011410 for ; Fri, 10 Mar 2017 16:10:58 -0500 From: John Ferlan To: libvir-list@redhat.com Date: Fri, 10 Mar 2017 16:10:42 -0500 Message-Id: <20170310211050.27784-11-jferlan@redhat.com> In-Reply-To: <20170310211050.27784-1-jferlan@redhat.com> References: <20170310211050.27784-1-jferlan@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.24 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH v3 10/18] conf: Rework storage_adapter_conf to use adapter specific typedefs 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-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Rework the helpers/APIs to use the FCHost and SCSIHost adapter types. Continue to realign the code for shorter lines. Signed-off-by: John Ferlan --- src/conf/storage_adapter_conf.c | 140 ++++++++++++++++--------------------= ---- 1 file changed, 57 insertions(+), 83 deletions(-) diff --git a/src/conf/storage_adapter_conf.c b/src/conf/storage_adapter_con= f.c index a361c34..6efe5ae 100644 --- a/src/conf/storage_adapter_conf.c +++ b/src/conf/storage_adapter_conf.c @@ -38,14 +38,14 @@ VIR_ENUM_IMPL(virStoragePoolSourceAdapter, =20 =20 static void -virStorageAdapterFCHostClear(virStoragePoolSourceAdapterPtr adapter) +virStorageAdapterFCHostClear(virStorageAdapterFCHostPtr fchost) { - VIR_FREE(adapter->data.fchost.wwnn); - VIR_FREE(adapter->data.fchost.wwpn); - VIR_FREE(adapter->data.fchost.parent); - VIR_FREE(adapter->data.fchost.parent_wwnn); - VIR_FREE(adapter->data.fchost.parent_wwpn); - VIR_FREE(adapter->data.fchost.parent_fabric_wwn); + VIR_FREE(fchost->wwnn); + VIR_FREE(fchost->wwpn); + VIR_FREE(fchost->parent); + VIR_FREE(fchost->parent_wwnn); + VIR_FREE(fchost->parent_wwpn); + VIR_FREE(fchost->parent_fabric_wwn); } =20 =20 @@ -53,7 +53,7 @@ void virStorageAdapterClear(virStoragePoolSourceAdapterPtr adapter) { if (adapter->type =3D=3D VIR_STORAGE_POOL_SOURCE_ADAPTER_TYPE_FC_HOST) - virStorageAdapterFCHostClear(adapter); + virStorageAdapterFCHostClear(&adapter->data.fchost); =20 if (adapter->type =3D=3D VIR_STORAGE_POOL_SOURCE_ADAPTER_TYPE_SCSI_HOS= T) VIR_FREE(adapter->data.scsi_host.name); @@ -62,15 +62,13 @@ virStorageAdapterClear(virStoragePoolSourceAdapterPtr a= dapter) =20 static int virStorageAdapterFCHostParseXML(xmlNodePtr node, - virStoragePoolSourcePtr source) + virStorageAdapterFCHostPtr fchost) { char *managed =3D NULL; =20 - source->adapter.data.fchost.parent =3D virXMLPropString(node, "parent"= ); + fchost->parent =3D virXMLPropString(node, "parent"); if ((managed =3D virXMLPropString(node, "managed"))) { - source->adapter.data.fchost.managed =3D - virTristateBoolTypeFromString(managed); - if (source->adapter.data.fchost.managed < 0) { + if ((fchost->managed =3D virTristateBoolTypeFromString(managed)) <= 0) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, _("unknown fc_host managed setting '%s'"), managed); @@ -79,15 +77,11 @@ virStorageAdapterFCHostParseXML(xmlNodePtr node, } } =20 - source->adapter.data.fchost.parent_wwnn =3D - virXMLPropString(node, "parent_wwnn"); - source->adapter.data.fchost.parent_wwpn =3D - virXMLPropString(node, "parent_wwpn"); - source->adapter.data.fchost.parent_fabric_wwn =3D - virXMLPropString(node, "parent_fabric_wwn"); - - source->adapter.data.fchost.wwpn =3D virXMLPropString(node, "wwpn"); - source->adapter.data.fchost.wwnn =3D virXMLPropString(node, "wwnn"); + fchost->parent_wwnn =3D virXMLPropString(node, "parent_wwnn"); + fchost->parent_wwpn =3D virXMLPropString(node, "parent_wwpn"); + fchost->parent_fabric_wwn =3D virXMLPropString(node, "parent_fabric_ww= n"); + fchost->wwpn =3D virXMLPropString(node, "wwpn"); + fchost->wwnn =3D virXMLPropString(node, "wwnn"); =20 VIR_FREE(managed); return 0; @@ -97,27 +91,24 @@ virStorageAdapterFCHostParseXML(xmlNodePtr node, static int virStorageAdapterSCSIHostParseXML(xmlNodePtr node, xmlXPathContextPtr ctxt, - virStoragePoolSourcePtr source) + virStorageAdapterSCSIHostPtr scsi_host) { - source->adapter.data.scsi_host.name =3D - virXMLPropString(node, "name"); + scsi_host->name =3D virXMLPropString(node, "name"); if (virXPathNode("./parentaddr", ctxt)) { xmlNodePtr addrnode =3D virXPathNode("./parentaddr/address", ctxt); - virPCIDeviceAddressPtr addr =3D - &source->adapter.data.scsi_host.parentaddr; =20 if (!addrnode) { virReportError(VIR_ERR_XML_ERROR, "%s", _("Missing scsi_host PCI address element")); return -1; } - source->adapter.data.scsi_host.has_parent =3D true; - if (virPCIDeviceAddressParseXML(addrnode, addr) < 0) + scsi_host->has_parent =3D true; + if (virPCIDeviceAddressParseXML(addrnode, &scsi_host->parentaddr) = < 0) return -1; if ((virXPathInt("string(./parentaddr/@unique_id)", ctxt, - &source->adapter.data.scsi_host.unique_id) < 0) || - (source->adapter.data.scsi_host.unique_id < 0)) { + &scsi_host->unique_id) < 0) || + (scsi_host->unique_id < 0)) { virReportError(VIR_ERR_XML_ERROR, "%s", _("Missing or invalid scsi adapter " "'unique_id' value")); @@ -132,7 +123,7 @@ virStorageAdapterSCSIHostParseXML(xmlNodePtr node, static int virStorageAdapterLegacyParseXML(xmlNodePtr node, xmlXPathContextPtr ctxt, - virStoragePoolSourcePtr source) + virStoragePoolSourceAdapterPtr adapter) { char *wwnn =3D virXMLPropString(node, "wwnn"); char *wwpn =3D virXMLPropString(node, "wwpn"); @@ -162,10 +153,8 @@ virStorageAdapterLegacyParseXML(xmlNodePtr node, /* To keep back-compat, 'type' is not required to specify * for scsi_host adapter. */ - if ((source->adapter.data.scsi_host.name =3D - virXMLPropString(node, "name"))) - source->adapter.type =3D - VIR_STORAGE_POOL_SOURCE_ADAPTER_TYPE_SCSI_HOST; + if ((adapter->data.scsi_host.name =3D virXMLPropString(node, "name"))) + adapter->type =3D VIR_STORAGE_POOL_SOURCE_ADAPTER_TYPE_SCSI_HOST; =20 return 0; } @@ -193,16 +182,16 @@ virStorageAdapterParseXML(virStoragePoolSourcePtr sou= rce, =20 if (source->adapter.type =3D=3D VIR_STORAGE_POOL_SOURCE_ADAPTER_TYPE_FC_HOST) { - if (virStorageAdapterFCHostParseXML(node, source) < 0) + if (virStorageAdapterFCHostParseXML(node, &source->adapter.dat= a.fchost) < 0) goto cleanup; } else if (source->adapter.type =3D=3D VIR_STORAGE_POOL_SOURCE_ADAPTER_TYPE_SCSI_HOST) { - if (virStorageAdapterSCSIHostParseXML(node, ctxt, source) < 0) + if (virStorageAdapterSCSIHostParseXML(node, ctxt, &source->ada= pter.data.scsi_host) < 0) goto cleanup; =20 } } else { - if (virStorageAdapterLegacyParseXML(node, ctxt, source) < 0) + if (virStorageAdapterLegacyParseXML(node, ctxt, &source->adapter) = < 0) goto cleanup; } =20 @@ -216,40 +205,33 @@ virStorageAdapterParseXML(virStoragePoolSourcePtr sou= rce, =20 =20 static int -virStorageAdapterFCHostParseValidate(virStoragePoolDefPtr ret) +virStorageAdapterFCHostParseValidate(virStorageAdapterFCHostPtr fchost) { - if (!ret->source.adapter.data.fchost.wwnn || - !ret->source.adapter.data.fchost.wwpn) { + if (!fchost->wwnn || !fchost->wwpn) { virReportError(VIR_ERR_XML_ERROR, "%s", _("'wwnn' and 'wwpn' must be specified for adapter " "type 'fchost'")); return -1; } =20 - if (!virValidateWWN(ret->source.adapter.data.fchost.wwnn) || - !virValidateWWN(ret->source.adapter.data.fchost.wwpn)) + if (!virValidateWWN(fchost->wwnn) || !virValidateWWN(fchost->wwpn)) return -1; =20 - if ((ret->source.adapter.data.fchost.parent_wwnn && - !ret->source.adapter.data.fchost.parent_wwpn) || - (!ret->source.adapter.data.fchost.parent_wwnn && - ret->source.adapter.data.fchost.parent_wwpn)) { + if ((fchost->parent_wwnn && !fchost->parent_wwpn) || + (!fchost->parent_wwnn && fchost->parent_wwpn)) { virReportError(VIR_ERR_XML_ERROR, "%s", _("must supply both parent_wwnn and " "parent_wwpn not just one or the other")); return -1; } =20 - if (ret->source.adapter.data.fchost.parent_wwnn && - !virValidateWWN(ret->source.adapter.data.fchost.parent_wwnn)) + if (fchost->parent_wwnn && !virValidateWWN(fchost->parent_wwnn)) return -1; =20 - if (ret->source.adapter.data.fchost.parent_wwpn && - !virValidateWWN(ret->source.adapter.data.fchost.parent_wwpn)) + if (fchost->parent_wwpn && !virValidateWWN(fchost->parent_wwpn)) return -1; =20 - if (ret->source.adapter.data.fchost.parent_fabric_wwn && - !virValidateWWN(ret->source.adapter.data.fchost.parent_fabric_wwn)) + if (fchost->parent_fabric_wwn && !virValidateWWN(fchost->parent_fabric= _wwn)) return -1; =20 return 0; @@ -257,18 +239,16 @@ virStorageAdapterFCHostParseValidate(virStoragePoolDe= fPtr ret) =20 =20 static int -virStorageAdapterSCSIHostParseValidate(virStoragePoolDefPtr ret) +virStorageAdapterSCSIHostParseValidate(virStorageAdapterSCSIHostPtr scsi_h= ost) { - if (!ret->source.adapter.data.scsi_host.name && - !ret->source.adapter.data.scsi_host.has_parent) { + if (!scsi_host->name && !scsi_host->has_parent) { virReportError(VIR_ERR_XML_ERROR, "%s", _("Either 'name' or 'parent' must be specified " "for the 'scsi_host' adapter")); return -1; } =20 - if (ret->source.adapter.data.scsi_host.name && - ret->source.adapter.data.scsi_host.has_parent) { + if (scsi_host->name && scsi_host->has_parent) { virReportError(VIR_ERR_XML_ERROR, "%s", _("Both 'name' and 'parent' cannot be specified " "for the 'scsi_host' adapter")); @@ -290,11 +270,11 @@ virStorageAdapterParseValidate(virStoragePoolDefPtr r= et) =20 if (ret->source.adapter.type =3D=3D VIR_STORAGE_POOL_SOURCE_ADAPTER_TYPE_FC_HOST) - return virStorageAdapterFCHostParseValidate(ret); + return virStorageAdapterFCHostParseValidate(&ret->source.adapter.d= ata.fchost); =20 if (ret->source.adapter.type =3D=3D VIR_STORAGE_POOL_SOURCE_ADAPTER_TYPE_SCSI_HOST) - return virStorageAdapterSCSIHostParseValidate(ret); + return virStorageAdapterSCSIHostParseValidate(&ret->source.adapter= .data.scsi_host); =20 return 0; } @@ -302,42 +282,36 @@ virStorageAdapterParseValidate(virStoragePoolDefPtr r= et) =20 static void virStorageAdapterFCHostFormat(virBufferPtr buf, - virStoragePoolSourcePtr src) + virStorageAdapterFCHostPtr fchost) { - virBufferEscapeString(buf, " parent=3D'%s'", - src->adapter.data.fchost.parent); - if (src->adapter.data.fchost.managed) + virBufferEscapeString(buf, " parent=3D'%s'", fchost->parent); + if (fchost->managed) virBufferAsprintf(buf, " managed=3D'%s'", - virTristateBoolTypeToString(src->adapter.data.fc= host.managed)); - virBufferEscapeString(buf, " parent_wwnn=3D'%s'", - src->adapter.data.fchost.parent_wwnn); - virBufferEscapeString(buf, " parent_wwpn=3D'%s'", - src->adapter.data.fchost.parent_wwpn); + virTristateBoolTypeToString(fchost->managed)); + virBufferEscapeString(buf, " parent_wwnn=3D'%s'", fchost->parent_wwnn); + virBufferEscapeString(buf, " parent_wwpn=3D'%s'", fchost->parent_wwpn); virBufferEscapeString(buf, " parent_fabric_wwn=3D'%s'", - src->adapter.data.fchost.parent_fabric_wwn); + fchost->parent_fabric_wwn); =20 virBufferAsprintf(buf, " wwnn=3D'%s' wwpn=3D'%s'/>\n", - src->adapter.data.fchost.wwnn, - src->adapter.data.fchost.wwpn); + fchost->wwnn, fchost->wwpn); } =20 =20 static void virStorageAdapterSCSIHostFormat(virBufferPtr buf, - virStoragePoolSourcePtr src) + virStorageAdapterSCSIHostPtr scsi_host) { - if (src->adapter.data.scsi_host.name) { - virBufferAsprintf(buf, " name=3D'%s'/>\n", - src->adapter.data.scsi_host.name); + if (scsi_host->name) { + virBufferAsprintf(buf, " name=3D'%s'/>\n", scsi_host->name); } else { - virPCIDeviceAddress addr; virBufferAddLit(buf, ">\n"); virBufferAdjustIndent(buf, 2); virBufferAsprintf(buf, "\n", - src->adapter.data.scsi_host.unique_id); + scsi_host->unique_id); virBufferAdjustIndent(buf, 2); - addr =3D src->adapter.data.scsi_host.parentaddr; - ignore_value(virPCIDeviceAddressFormat(buf, addr, false)); + ignore_value(virPCIDeviceAddressFormat(buf, scsi_host->parentaddr, + false)); virBufferAdjustIndent(buf, -2); virBufferAddLit(buf, "\n"); virBufferAdjustIndent(buf, -2); @@ -354,8 +328,8 @@ virStorageAdapterFormat(virBufferPtr buf, virStoragePoolSourceAdapterTypeToString(src->adapter= .type)); =20 if (src->adapter.type =3D=3D VIR_STORAGE_POOL_SOURCE_ADAPTER_TYPE_FC_H= OST) - virStorageAdapterFCHostFormat(buf, src); + virStorageAdapterFCHostFormat(buf, &src->adapter.data.fchost); =20 if (src->adapter.type =3D=3D VIR_STORAGE_POOL_SOURCE_ADAPTER_TYPE_SCSI= _HOST) - virStorageAdapterSCSIHostFormat(buf, src); + virStorageAdapterSCSIHostFormat(buf, &src->adapter.data.scsi_host); } --=20 2.9.3 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Fri May 3 01:20:00 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.25 as permitted sender) client-ip=209.132.183.25; envelope-from=libvir-list-bounces@redhat.com; helo=mx4-phx2.redhat.com; Authentication-Results: mx.zoho.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.25 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; Return-Path: Received: from mx4-phx2.redhat.com (mx4-phx2.redhat.com [209.132.183.25]) by mx.zohomail.com with SMTPS id 1489180485178979.9834590897486; Fri, 10 Mar 2017 13:14:45 -0800 (PST) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by mx4-phx2.redhat.com (8.13.8/8.13.8) with ESMTP id v2ALBV1W009195; Fri, 10 Mar 2017 16:11:31 -0500 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id v2ALAxVI023971 for ; Fri, 10 Mar 2017 16:10:59 -0500 Received: from localhost.localdomain.com (ovpn-117-9.phx2.redhat.com [10.3.117.9]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id v2ALArRr011410 for ; Fri, 10 Mar 2017 16:10:59 -0500 From: John Ferlan To: libvir-list@redhat.com Date: Fri, 10 Mar 2017 16:10:43 -0500 Message-Id: <20170310211050.27784-12-jferlan@redhat.com> In-Reply-To: <20170310211050.27784-1-jferlan@redhat.com> References: <20170310211050.27784-1-jferlan@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.24 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH v3 11/18] conf: Rework storage_conf to use adapter specific typedefs 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-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Rework the helpers/APIs to use the FCHost and SCSIHost adapter types. Continue to realign the code for shorter lines. Signed-off-by: John Ferlan --- src/conf/storage_conf.c | 112 ++++++++++++++++++++++++++------------------= ---- 1 file changed, 61 insertions(+), 51 deletions(-) diff --git a/src/conf/storage_conf.c b/src/conf/storage_conf.c index 8709101..45dc860 100644 --- a/src/conf/storage_conf.c +++ b/src/conf/storage_conf.c @@ -2085,16 +2085,16 @@ virStoragePoolObjIsDuplicate(virStoragePoolObjListP= tr pools, =20 =20 static int -getSCSIHostNumber(virStoragePoolSourceAdapter adapter, +getSCSIHostNumber(virStorageAdapterSCSIHostPtr scsi_host, unsigned int *hostnum) { int ret =3D -1; unsigned int num; char *name =3D NULL; =20 - if (adapter.data.scsi_host.has_parent) { - virPCIDeviceAddress addr =3D adapter.data.scsi_host.parentaddr; - unsigned int unique_id =3D adapter.data.scsi_host.unique_id; + if (scsi_host->has_parent) { + virPCIDeviceAddress addr =3D scsi_host->parentaddr; + unsigned int unique_id =3D scsi_host->unique_id; =20 if (!(name =3D virSCSIHostGetNameByParentaddr(addr.domain, addr.bus, @@ -2105,7 +2105,7 @@ getSCSIHostNumber(virStoragePoolSourceAdapter adapter, if (virSCSIHostGetNumber(name, &num) < 0) goto cleanup; } else { - if (virSCSIHostGetNumber(adapter.data.scsi_host.name, &num) < 0) + if (virSCSIHostGetNumber(scsi_host->name, &num) < 0) goto cleanup; } =20 @@ -2136,7 +2136,7 @@ virStorageIsSameHostnum(const char *name, * matchFCHostToSCSIHost: * * @conn: Connection pointer - * @fc_adapter: fc_host adapter (either def or pool->def) + * @fchost: fc_host adapter ptr (either def or pool->def) * @scsi_hostnum: Already determined "scsi_pool" hostnum * * Returns true/false whether there is a match between the incoming @@ -2144,7 +2144,7 @@ virStorageIsSameHostnum(const char *name, */ static bool matchFCHostToSCSIHost(virConnectPtr conn, - virStoragePoolSourceAdapter fc_adapter, + virStorageAdapterFCHostPtr fchost, unsigned int scsi_hostnum) { bool ret =3D false; @@ -2155,15 +2155,14 @@ matchFCHostToSCSIHost(virConnectPtr conn, /* If we have a parent defined, get its hostnum, and compare to the * scsi_hostnum. If they are the same, then we have a match */ - if (fc_adapter.data.fchost.parent && - virStorageIsSameHostnum(fc_adapter.data.fchost.parent, scsi_hostnu= m)) + if (fchost->parent && + virStorageIsSameHostnum(fchost->parent, scsi_hostnum)) return true; =20 - /* If we find an fc_adapter name, then either libvirt created a vHBA + /* If we find an fc adapter name, then either libvirt created a vHBA * for this fc_host or a 'virsh nodedev-create' generated a vHBA. */ - if ((name =3D virVHBAGetHostByWWN(NULL, fc_adapter.data.fchost.wwnn, - fc_adapter.data.fchost.wwpn))) { + if ((name =3D virVHBAGetHostByWWN(NULL, fchost->wwnn, fchost->wwpn))) { =20 /* Get the scsi_hostN for the vHBA in order to see if it * matches our scsi_hostnum @@ -2178,7 +2177,7 @@ matchFCHostToSCSIHost(virConnectPtr conn, * If the parent fc_hostnum is the same as the scsi_hostnum, we * have a match. */ - if (conn && !fc_adapter.data.fchost.parent) { + if (conn && !fchost->parent) { if (virAsprintf(&scsi_host_name, "scsi_%s", name) < 0) goto cleanup; if ((parent_name =3D virNodeDeviceGetParentName(conn, @@ -2210,25 +2209,21 @@ matchFCHostToSCSIHost(virConnectPtr conn, return ret; } =20 + static bool -matchSCSIAdapterParent(virStoragePoolObjPtr pool, - virStoragePoolDefPtr def) +matchSCSIAdapterParent(virStorageAdapterSCSIHostPtr pool_scsi_host, + virStorageAdapterSCSIHostPtr def_scsi_host) { - virPCIDeviceAddressPtr pooladdr =3D - &pool->def->source.adapter.data.scsi_host.parentaddr; - virPCIDeviceAddressPtr defaddr =3D - &def->source.adapter.data.scsi_host.parentaddr; - int pool_unique_id =3D - pool->def->source.adapter.data.scsi_host.unique_id; - int def_unique_id =3D - def->source.adapter.data.scsi_host.unique_id; + virPCIDeviceAddressPtr pooladdr =3D &pool_scsi_host->parentaddr; + virPCIDeviceAddressPtr defaddr =3D &def_scsi_host->parentaddr; + if (pooladdr->domain =3D=3D defaddr->domain && pooladdr->bus =3D=3D defaddr->bus && pooladdr->slot =3D=3D defaddr->slot && pooladdr->function =3D=3D defaddr->function && - pool_unique_id =3D=3D def_unique_id) { + pool_scsi_host->unique_id =3D=3D def_scsi_host->unique_id) return true; - } + return false; } =20 @@ -2271,6 +2266,8 @@ virStoragePoolSourceFindDuplicate(virConnectPtr conn, int ret =3D 1; virStoragePoolObjPtr pool =3D NULL; virStoragePoolObjPtr matchpool =3D NULL; + virStoragePoolSourceAdapterPtr pool_adapter; + virStoragePoolSourceAdapterPtr def_adapter; =20 /* Check the pool list for duplicate underlying storage */ for (i =3D 0; i < pools->count; i++) { @@ -2306,63 +2303,76 @@ virStoragePoolSourceFindDuplicate(virConnectPtr con= n, break; =20 case VIR_STORAGE_POOL_SCSI: - if (pool->def->source.adapter.type =3D=3D + pool_adapter =3D &pool->def->source.adapter; + def_adapter =3D &def->source.adapter; + + if (pool_adapter->type =3D=3D VIR_STORAGE_POOL_SOURCE_ADAPTER_TYPE_FC_HOST && - def->source.adapter.type =3D=3D + def_adapter->type =3D=3D VIR_STORAGE_POOL_SOURCE_ADAPTER_TYPE_FC_HOST) { - if (STREQ(pool->def->source.adapter.data.fchost.wwnn, - def->source.adapter.data.fchost.wwnn) && - STREQ(pool->def->source.adapter.data.fchost.wwpn, - def->source.adapter.data.fchost.wwpn)) + virStorageAdapterFCHostPtr pool_fchost =3D + &pool_adapter->data.fchost; + virStorageAdapterFCHostPtr def_fchost =3D + &def_adapter->data.fchost; + + if (STREQ(pool_fchost->wwnn, def_fchost->wwnn) && + STREQ(pool_fchost->wwpn, def_fchost->wwpn)) matchpool =3D pool; - } else if (pool->def->source.adapter.type =3D=3D + } else if (pool_adapter->type =3D=3D VIR_STORAGE_POOL_SOURCE_ADAPTER_TYPE_SCSI_HOST && - def->source.adapter.type =3D=3D + def_adapter->type =3D=3D VIR_STORAGE_POOL_SOURCE_ADAPTER_TYPE_SCSI_HOST) { + virStorageAdapterSCSIHostPtr pool_scsi_host =3D + &pool_adapter->data.scsi_host; + virStorageAdapterSCSIHostPtr def_scsi_host =3D + &def_adapter->data.scsi_host; unsigned int pool_hostnum, def_hostnum; =20 - if (pool->def->source.adapter.data.scsi_host.has_parent && - def->source.adapter.data.scsi_host.has_parent && - matchSCSIAdapterParent(pool, def)) { + if (pool_scsi_host->has_parent && + def_scsi_host->has_parent && + matchSCSIAdapterParent(pool_scsi_host, def_scsi_host))= { matchpool =3D pool; break; } =20 - if (getSCSIHostNumber(pool->def->source.adapter, - &pool_hostnum) < 0 || - getSCSIHostNumber(def->source.adapter, &def_hostnum) <= 0) + if (getSCSIHostNumber(pool_scsi_host, &pool_hostnum) < 0 || + getSCSIHostNumber(def_scsi_host, &def_hostnum) < 0) break; if (pool_hostnum =3D=3D def_hostnum) matchpool =3D pool; - } else if (pool->def->source.adapter.type =3D=3D + } else if (pool_adapter->type =3D=3D VIR_STORAGE_POOL_SOURCE_ADAPTER_TYPE_FC_HOST && - def->source.adapter.type =3D=3D + def_adapter->type =3D=3D VIR_STORAGE_POOL_SOURCE_ADAPTER_TYPE_SCSI_HOST) { + virStorageAdapterFCHostPtr pool_fchost =3D + &pool_adapter->data.fchost; + virStorageAdapterSCSIHostPtr def_scsi_host =3D + &def_adapter->data.scsi_host; unsigned int scsi_hostnum; =20 /* Get the scsi_hostN for the scsi_host source adapter def= */ - if (getSCSIHostNumber(def->source.adapter, - &scsi_hostnum) < 0) + if (getSCSIHostNumber(def_scsi_host, &scsi_hostnum) < 0) break; =20 - if (matchFCHostToSCSIHost(conn, pool->def->source.adapter, - scsi_hostnum)) { + if (matchFCHostToSCSIHost(conn, pool_fchost, scsi_hostnum)= ) { matchpool =3D pool; break; } =20 - } else if (pool->def->source.adapter.type =3D=3D + } else if (pool_adapter->type =3D=3D VIR_STORAGE_POOL_SOURCE_ADAPTER_TYPE_SCSI_HOST && - def->source.adapter.type =3D=3D + def_adapter->type =3D=3D VIR_STORAGE_POOL_SOURCE_ADAPTER_TYPE_FC_HOST) { + virStorageAdapterSCSIHostPtr pool_scsi_host =3D + &pool_adapter->data.scsi_host; + virStorageAdapterFCHostPtr def_fchost =3D + &def_adapter->data.fchost; unsigned int scsi_hostnum; =20 - if (getSCSIHostNumber(pool->def->source.adapter, - &scsi_hostnum) < 0) + if (getSCSIHostNumber(pool_scsi_host, &scsi_hostnum) < 0) break; =20 - if (matchFCHostToSCSIHost(conn, def->source.adapter, - scsi_hostnum)) { + if (matchFCHostToSCSIHost(conn, def_fchost, scsi_hostnum))= { matchpool =3D pool; break; } --=20 2.9.3 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Fri May 3 01:20:00 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.24 as permitted sender) client-ip=209.132.183.24; envelope-from=libvir-list-bounces@redhat.com; helo=mx3-phx2.redhat.com; Authentication-Results: mx.zoho.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.24 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; Return-Path: Received: from mx3-phx2.redhat.com (mx3-phx2.redhat.com [209.132.183.24]) by mx.zohomail.com with SMTPS id 148918048373353.05597205796721; Fri, 10 Mar 2017 13:14:43 -0800 (PST) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by mx3-phx2.redhat.com (8.13.8/8.13.8) with ESMTP id v2ALBU7f006711; Fri, 10 Mar 2017 16:11:30 -0500 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id v2ALAx30023981 for ; Fri, 10 Mar 2017 16:10:59 -0500 Received: from localhost.localdomain.com (ovpn-117-9.phx2.redhat.com [10.3.117.9]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id v2ALArRs011410 for ; Fri, 10 Mar 2017 16:10:59 -0500 From: John Ferlan To: libvir-list@redhat.com Date: Fri, 10 Mar 2017 16:10:44 -0500 Message-Id: <20170310211050.27784-13-jferlan@redhat.com> In-Reply-To: <20170310211050.27784-1-jferlan@redhat.com> References: <20170310211050.27784-1-jferlan@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.24 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH v3 12/18] storage: Rework getAdapterName to use adapter specific typedefs 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-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Use the FCHost and SCSIHost adapter specific typedefs Signed-off-by: John Ferlan --- src/storage/storage_backend_scsi.c | 29 +++++++++++++++-------------- 1 file changed, 15 insertions(+), 14 deletions(-) diff --git a/src/storage/storage_backend_scsi.c b/src/storage/storage_backe= nd_scsi.c index 642e795..6c8875c 100644 --- a/src/storage/storage_backend_scsi.c +++ b/src/storage/storage_backend_scsi.c @@ -176,15 +176,17 @@ virStoragePoolFCRefreshThread(void *opaque) } =20 static char * -getAdapterName(virStoragePoolSourceAdapter adapter) +getAdapterName(virStoragePoolSourceAdapterPtr adapter) { char *name =3D NULL; char *parentaddr =3D NULL; =20 - if (adapter.type =3D=3D VIR_STORAGE_POOL_SOURCE_ADAPTER_TYPE_SCSI_HOST= ) { - if (adapter.data.scsi_host.has_parent) { - virPCIDeviceAddress addr =3D adapter.data.scsi_host.parentaddr; - unsigned int unique_id =3D adapter.data.scsi_host.unique_id; + if (adapter->type =3D=3D VIR_STORAGE_POOL_SOURCE_ADAPTER_TYPE_SCSI_HOS= T) { + virStorageAdapterSCSIHostPtr scsi_host =3D &adapter->data.scsi_hos= t; + + if (scsi_host->has_parent) { + virPCIDeviceAddress addr =3D scsi_host->parentaddr; + unsigned int unique_id =3D scsi_host->unique_id; =20 if (!(name =3D virSCSIHostGetNameByParentaddr(addr.domain, addr.bus, @@ -193,16 +195,15 @@ getAdapterName(virStoragePoolSourceAdapter adapter) unique_id))) goto cleanup; } else { - ignore_value(VIR_STRDUP(name, adapter.data.scsi_host.name)); + ignore_value(VIR_STRDUP(name, scsi_host->name)); } - } else if (adapter.type =3D=3D VIR_STORAGE_POOL_SOURCE_ADAPTER_TYPE_FC= _HOST) { - if (!(name =3D virVHBAGetHostByWWN(NULL, - adapter.data.fchost.wwnn, - adapter.data.fchost.wwpn))) { + } else if (adapter->type =3D=3D VIR_STORAGE_POOL_SOURCE_ADAPTER_TYPE_F= C_HOST) { + virStorageAdapterFCHostPtr fchost =3D &adapter->data.fchost; + + if (!(name =3D virVHBAGetHostByWWN(NULL, fchost->wwnn, fchost->wwp= n))) { virReportError(VIR_ERR_XML_ERROR, _("Failed to find SCSI host with wwnn=3D'%s', " - "wwpn=3D'%s'"), adapter.data.fchost.wwnn, - adapter.data.fchost.wwpn); + "wwpn=3D'%s'"), fchost->wwnn, fchost->wwpn); } } =20 @@ -458,7 +459,7 @@ virStorageBackendSCSICheckPool(virStoragePoolObjPtr poo= l, =20 *isActive =3D false; =20 - if (!(name =3D getAdapterName(pool->def->source.adapter))) { + if (!(name =3D getAdapterName(&pool->def->source.adapter))) { /* It's normal for the pool with "fc_host" type source * adapter fails to get the adapter name, since the vHBA * the adapter based on might be not created yet. @@ -498,7 +499,7 @@ virStorageBackendSCSIRefreshPool(virConnectPtr conn ATT= RIBUTE_UNUSED, =20 pool->def->allocation =3D pool->def->capacity =3D pool->def->available= =3D 0; =20 - if (!(name =3D getAdapterName(pool->def->source.adapter))) + if (!(name =3D getAdapterName(&pool->def->source.adapter))) return -1; =20 if (virSCSIHostGetNumber(name, &host) < 0) --=20 2.9.3 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Fri May 3 01:20:00 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.39 as permitted sender) client-ip=209.132.183.39; envelope-from=libvir-list-bounces@redhat.com; helo=mx6-phx2.redhat.com; Authentication-Results: mx.zoho.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.39 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; Return-Path: Received: from mx6-phx2.redhat.com (mx6-phx2.redhat.com [209.132.183.39]) by mx.zohomail.com with SMTPS id 1489180477978788.190841771131; Fri, 10 Mar 2017 13:14:37 -0800 (PST) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by mx6-phx2.redhat.com (8.14.4/8.14.4) with ESMTP id v2ALBXFP051967; Fri, 10 Mar 2017 16:11:33 -0500 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id v2ALB06I023991 for ; Fri, 10 Mar 2017 16:11:00 -0500 Received: from localhost.localdomain.com (ovpn-117-9.phx2.redhat.com [10.3.117.9]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id v2ALArRt011410 for ; Fri, 10 Mar 2017 16:11:00 -0500 From: John Ferlan To: libvir-list@redhat.com Date: Fri, 10 Mar 2017 16:10:45 -0500 Message-Id: <20170310211050.27784-14-jferlan@redhat.com> In-Reply-To: <20170310211050.27784-1-jferlan@redhat.com> References: <20170310211050.27784-1-jferlan@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.24 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH v3 13/18] storage: Rework createVport and deleteVport 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-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Rework the code to use the new FCHost specific adapter structures. Also rework the parameters to only pass what's need and leave logic in the caller for the adapter type and the need to call the helpers. Signed-off-by: John Ferlan --- src/storage/storage_backend_scsi.c | 96 ++++++++++++++++++----------------= ---- 1 file changed, 45 insertions(+), 51 deletions(-) diff --git a/src/storage/storage_backend_scsi.c b/src/storage/storage_backe= nd_scsi.c index 6c8875c..77a51ff 100644 --- a/src/storage/storage_backend_scsi.c +++ b/src/storage/storage_backend_scsi.c @@ -255,10 +255,10 @@ checkParent(virConnectPtr conn, =20 static int createVport(virConnectPtr conn, - virStoragePoolObjPtr pool) + virStoragePoolDefPtr def, + const char *configFile, + virStorageAdapterFCHostPtr fchost) { - const char *configFile =3D pool->configFile; - virStoragePoolSourceAdapterPtr adapter =3D &pool->def->source.adapter; unsigned int parent_host; char *name =3D NULL; char *parent_hoststr =3D NULL; @@ -267,45 +267,37 @@ createVport(virConnectPtr conn, virThread thread; int ret =3D -1; =20 - if (adapter->type !=3D VIR_STORAGE_POOL_SOURCE_ADAPTER_TYPE_FC_HOST) - return 0; - VIR_DEBUG("conn=3D%p, configFile=3D'%s' parent=3D'%s', wwnn=3D'%s' wwp= n=3D'%s'", - conn, NULLSTR(configFile), NULLSTR(adapter->data.fchost.pare= nt), - adapter->data.fchost.wwnn, adapter->data.fchost.wwpn); + 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, adapter->data.fchost.wwnn, - adapter->data.fchost.wwpn))) { + 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 (adapter->data.fchost.parent && - checkParent(conn, name, adapter->data.fchost.parent)) + if (fchost->parent && checkParent(conn, name, fchost->parent)) ret =3D 0; =20 goto cleanup; } =20 - if (adapter->data.fchost.parent) { - if (VIR_STRDUP(parent_hoststr, adapter->data.fchost.parent) < 0) + if (fchost->parent) { + if (VIR_STRDUP(parent_hoststr, fchost->parent) < 0) goto cleanup; - } else if (adapter->data.fchost.parent_wwnn && - adapter->data.fchost.parent_wwpn) { - if (!(parent_hoststr =3D - virVHBAGetHostByWWN(NULL, adapter->data.fchost.parent_wwnn, - adapter->data.fchost.parent_wwpn))) { + } else if (fchost->parent_wwnn && fchost->parent_wwpn) { + if (!(parent_hoststr =3D virVHBAGetHostByWWN(NULL, fchost->parent_= wwnn, + fchost->parent_wwpn))) { virReportError(VIR_ERR_XML_ERROR, "%s", _("cannot find parent using provided wwnn/wwpn"= )); goto cleanup; } - } else if (adapter->data.fchost.parent_fabric_wwn) { + } else if (fchost->parent_fabric_wwn) { if (!(parent_hoststr =3D - virVHBAGetHostByFabricWWN(NULL, - adapter->data.fchost.parent_fabric= _wwn))) { + virVHBAGetHostByFabricWWN(NULL, fchost->parent_fabric_wwn)))= { virReportError(VIR_ERR_XML_ERROR, "%s", _("cannot find parent using provided fabric_wwn= ")); goto cleanup; @@ -324,8 +316,8 @@ createVport(virConnectPtr conn, goto cleanup; =20 /* NOTE: - * We do not save the parent_hoststr in adapter->data.fchost.parent - * since we could be writing out the 'def' to the saved XML config. + * We do not save the parent_hoststr in fchost->parent since + * we could be writing out the 'def' to the saved XML config. * If we wrote out the name in the XML, then future starts would * always use the same parent rather than finding the "best available" * parent. Besides we have a way to determine the parent based on @@ -343,16 +335,16 @@ createVport(virConnectPtr conn, * restart, we need to save the persistent configuration. So if not * already defined as YES, then force the issue. */ - if (adapter->data.fchost.managed !=3D VIR_TRISTATE_BOOL_YES) { - adapter->data.fchost.managed =3D VIR_TRISTATE_BOOL_YES; + if (fchost->managed !=3D VIR_TRISTATE_BOOL_YES) { + fchost->managed =3D VIR_TRISTATE_BOOL_YES; if (configFile) { - if (virStoragePoolSaveConfig(configFile, pool->def) < 0) + if (virStoragePoolSaveConfig(configFile, def) < 0) goto cleanup; } } =20 - if (virVHBAManageVport(parent_host, adapter->data.fchost.wwpn, - adapter->data.fchost.wwnn, VPORT_CREATE) < 0) + if (virVHBAManageVport(parent_host, fchost->wwpn, fchost->wwnn, + VPORT_CREATE) < 0) goto cleanup; =20 virFileWaitForDevices(); @@ -362,10 +354,9 @@ createVport(virConnectPtr conn, * retry logic set to true. If the thread isn't created, then no big * deal since it's still possible to refresh the pool later. */ - if ((name =3D virVHBAGetHostByWWN(NULL, adapter->data.fchost.wwnn, - adapter->data.fchost.wwpn))) { + if ((name =3D virVHBAGetHostByWWN(NULL, fchost->wwnn, fchost->wwpn))) { if (VIR_ALLOC(cbdata) =3D=3D 0) { - memcpy(cbdata->pool_uuid, pool->def->uuid, VIR_UUID_BUFLEN); + memcpy(cbdata->pool_uuid, def->uuid, VIR_UUID_BUFLEN); VIR_STEAL_PTR(cbdata->fchost_name, name); =20 if (virThreadCreate(&thread, false, virStoragePoolFCRefreshThr= ead, @@ -385,9 +376,10 @@ createVport(virConnectPtr conn, return ret; } =20 + static int deleteVport(virConnectPtr conn, - virStoragePoolSourceAdapter adapter) + virStorageAdapterFCHostPtr fchost) { unsigned int parent_host; char *name =3D NULL; @@ -395,25 +387,19 @@ deleteVport(virConnectPtr conn, char *vhba_parent =3D NULL; int ret =3D -1; =20 - if (adapter.type !=3D VIR_STORAGE_POOL_SOURCE_ADAPTER_TYPE_FC_HOST) - return 0; - VIR_DEBUG("conn=3D%p parent=3D'%s', managed=3D'%d' wwnn=3D'%s' wwpn=3D= '%s'", - conn, NULLSTR(adapter.data.fchost.parent), - adapter.data.fchost.managed, - adapter.data.fchost.wwnn, - adapter.data.fchost.wwpn); + conn, NULLSTR(fchost->parent), fchost->managed, + fchost->wwnn, fchost->wwpn); =20 /* If we're not managing the deletion of the vHBA, then just return */ - if (adapter.data.fchost.managed !=3D VIR_TRISTATE_BOOL_YES) + if (fchost->managed !=3D VIR_TRISTATE_BOOL_YES) return 0; =20 /* Find our vHBA by searching the fc_host sysfs tree for our wwnn/wwpn= */ - if (!(name =3D virVHBAGetHostByWWN(NULL, adapter.data.fchost.wwnn, - adapter.data.fchost.wwpn))) { + if (!(name =3D virVHBAGetHostByWWN(NULL, fchost->wwnn, fchost->wwpn)))= { virReportError(VIR_ERR_INTERNAL_ERROR, _("Failed to find fc_host for wwnn=3D'%s' and wwpn= =3D'%s'"), - adapter.data.fchost.wwnn, adapter.data.fchost.wwpn); + fchost->wwnn, fchost->wwpn); goto cleanup; } =20 @@ -421,8 +407,8 @@ deleteVport(virConnectPtr conn, * get the parent_host value; otherwise, we have to determine * the parent scsi_host which we did not save at startup time */ - if (adapter.data.fchost.parent) { - if (virSCSIHostGetNumber(adapter.data.fchost.parent, &parent_host)= < 0) + if (fchost->parent) { + if (virSCSIHostGetNumber(fchost->parent, &parent_host) < 0) goto cleanup; } else { if (virAsprintf(&scsi_host_name, "scsi_%s", name) < 0) @@ -435,8 +421,8 @@ deleteVport(virConnectPtr conn, goto cleanup; } =20 - if (virVHBAManageVport(parent_host, adapter.data.fchost.wwpn, - adapter.data.fchost.wwnn, VPORT_DELETE) < 0) + if (virVHBAManageVport(parent_host, fchost->wwpn, fchost->wwnn, + VPORT_DELETE) < 0) goto cleanup; =20 ret =3D 0; @@ -523,15 +509,23 @@ static int virStorageBackendSCSIStartPool(virConnectPtr conn, virStoragePoolObjPtr pool) { - return createVport(conn, pool); + if (pool->def->source.adapter.type =3D=3D + VIR_STORAGE_POOL_SOURCE_ADAPTER_TYPE_FC_HOST) + return createVport(conn, pool->def, pool->configFile, + &pool->def->source.adapter.data.fchost); + + return 0; } =20 static int virStorageBackendSCSIStopPool(virConnectPtr conn, virStoragePoolObjPtr pool) { - virStoragePoolSourceAdapter adapter =3D pool->def->source.adapter; - return deleteVport(conn, adapter); + if (pool->def->source.adapter.type =3D=3D + VIR_STORAGE_POOL_SOURCE_ADAPTER_TYPE_FC_HOST) + return deleteVport(conn, &pool->def->source.adapter.data.fchost); + + return 0; } =20 virStorageBackend virStorageBackendSCSI =3D { --=20 2.9.3 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Fri May 3 01:20:00 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.25 as permitted sender) client-ip=209.132.183.25; envelope-from=libvir-list-bounces@redhat.com; helo=mx4-phx2.redhat.com; Authentication-Results: mx.zoho.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.25 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; Return-Path: Received: from mx4-phx2.redhat.com (mx4-phx2.redhat.com [209.132.183.25]) by mx.zohomail.com with SMTPS id 1489180499548861.1085251034223; Fri, 10 Mar 2017 13:14:59 -0800 (PST) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by mx4-phx2.redhat.com (8.13.8/8.13.8) with ESMTP id v2ALBVJj009196; Fri, 10 Mar 2017 16:11:31 -0500 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id v2ALB0K5024001 for ; Fri, 10 Mar 2017 16:11:00 -0500 Received: from localhost.localdomain.com (ovpn-117-9.phx2.redhat.com [10.3.117.9]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id v2ALArRu011410 for ; Fri, 10 Mar 2017 16:11:00 -0500 From: John Ferlan To: libvir-list@redhat.com Date: Fri, 10 Mar 2017 16:10:46 -0500 Message-Id: <20170310211050.27784-15-jferlan@redhat.com> In-Reply-To: <20170310211050.27784-1-jferlan@redhat.com> References: <20170310211050.27784-1-jferlan@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.24 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH v3 14/18] conf: Convert virStoragePoolSourceAdapter to virStorageAdapter 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-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Move the virStoragePoolSourceAdapter from storage_conf.h and rename to virStorageAdapter. Continue with code realignment for brevity and flow. Signed-off-by: John Ferlan --- src/conf/storage_adapter_conf.c | 71 ++++++++++++++++++----------------= ---- src/conf/storage_adapter_conf.h | 51 ++++++++++++++++++++++++--- src/conf/storage_conf.c | 32 ++++++++--------- src/conf/storage_conf.h | 44 ++--------------------- src/libvirt_private.syms | 2 -- src/phyp/phyp_driver.c | 3 +- src/storage/storage_backend_scsi.c | 18 +++++----- src/test/test_driver.c | 5 ++- 8 files changed, 109 insertions(+), 117 deletions(-) diff --git a/src/conf/storage_adapter_conf.c b/src/conf/storage_adapter_con= f.c index 6efe5ae..53c07c7 100644 --- a/src/conf/storage_adapter_conf.c +++ b/src/conf/storage_adapter_conf.c @@ -19,7 +19,7 @@ =20 #include =20 -#include "storage_adapter_conf.h" +#include "storage_conf.h" =20 #include "viralloc.h" #include "virerror.h" @@ -32,11 +32,10 @@ =20 VIR_LOG_INIT("conf.storage_adapter_conf"); =20 -VIR_ENUM_IMPL(virStoragePoolSourceAdapter, - VIR_STORAGE_POOL_SOURCE_ADAPTER_TYPE_LAST, +VIR_ENUM_IMPL(virStorageAdapter, + VIR_STORAGE_ADAPTER_TYPE_LAST, "default", "scsi_host", "fc_host") =20 - static void virStorageAdapterFCHostClear(virStorageAdapterFCHostPtr fchost) { @@ -50,12 +49,12 @@ virStorageAdapterFCHostClear(virStorageAdapterFCHostPtr= fchost) =20 =20 void -virStorageAdapterClear(virStoragePoolSourceAdapterPtr adapter) +virStorageAdapterClear(virStorageAdapterPtr adapter) { - if (adapter->type =3D=3D VIR_STORAGE_POOL_SOURCE_ADAPTER_TYPE_FC_HOST) + if (adapter->type =3D=3D VIR_STORAGE_ADAPTER_TYPE_FC_HOST) virStorageAdapterFCHostClear(&adapter->data.fchost); =20 - if (adapter->type =3D=3D VIR_STORAGE_POOL_SOURCE_ADAPTER_TYPE_SCSI_HOS= T) + if (adapter->type =3D=3D VIR_STORAGE_ADAPTER_TYPE_SCSI_HOST) VIR_FREE(adapter->data.scsi_host.name); } =20 @@ -123,7 +122,7 @@ virStorageAdapterSCSIHostParseXML(xmlNodePtr node, static int virStorageAdapterLegacyParseXML(xmlNodePtr node, xmlXPathContextPtr ctxt, - virStoragePoolSourceAdapterPtr adapter) + virStorageAdapterPtr adapter) { char *wwnn =3D virXMLPropString(node, "wwnn"); char *wwpn =3D virXMLPropString(node, "wwpn"); @@ -154,14 +153,14 @@ virStorageAdapterLegacyParseXML(xmlNodePtr node, * for scsi_host adapter. */ if ((adapter->data.scsi_host.name =3D virXMLPropString(node, "name"))) - adapter->type =3D VIR_STORAGE_POOL_SOURCE_ADAPTER_TYPE_SCSI_HOST; + adapter->type =3D VIR_STORAGE_ADAPTER_TYPE_SCSI_HOST; =20 return 0; } =20 =20 int -virStorageAdapterParseXML(virStoragePoolSourcePtr source, +virStorageAdapterParseXML(virStorageAdapterPtr adapter, xmlNodePtr node, xmlXPathContextPtr ctxt) { @@ -172,26 +171,24 @@ virStorageAdapterParseXML(virStoragePoolSourcePtr sou= rce, ctxt->node =3D node; =20 if ((adapter_type =3D virXMLPropString(node, "type"))) { - if ((source->adapter.type =3D - virStoragePoolSourceAdapterTypeFromString(adapter_type)) <=3D= 0) { + if ((adapter->type =3D + virStorageAdapterTypeFromString(adapter_type)) <=3D 0) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, _("Unknown pool adapter type '%s'"), adapter_type); goto cleanup; } =20 - if (source->adapter.type =3D=3D - VIR_STORAGE_POOL_SOURCE_ADAPTER_TYPE_FC_HOST) { - if (virStorageAdapterFCHostParseXML(node, &source->adapter.dat= a.fchost) < 0) - goto cleanup; - } else if (source->adapter.type =3D=3D - VIR_STORAGE_POOL_SOURCE_ADAPTER_TYPE_SCSI_HOST) { - if (virStorageAdapterSCSIHostParseXML(node, ctxt, &source->ada= pter.data.scsi_host) < 0) + if ((adapter->type =3D=3D VIR_STORAGE_ADAPTER_TYPE_FC_HOST) && + (virStorageAdapterFCHostParseXML(node, &adapter->data.fchost))= < 0) goto cleanup; =20 - } + if ((adapter->type =3D=3D VIR_STORAGE_ADAPTER_TYPE_SCSI_HOST) && + (virStorageAdapterSCSIHostParseXML(node, ctxt, + &adapter->data.scsi_host)) = < 0) + goto cleanup; } else { - if (virStorageAdapterLegacyParseXML(node, ctxt, &source->adapter) = < 0) + if (virStorageAdapterLegacyParseXML(node, ctxt, adapter) < 0) goto cleanup; } =20 @@ -260,21 +257,19 @@ virStorageAdapterSCSIHostParseValidate(virStorageAdap= terSCSIHostPtr scsi_host) =20 =20 int -virStorageAdapterParseValidate(virStoragePoolDefPtr ret) +virStorageAdapterParseValidate(virStorageAdapterPtr adapter) { - if (!ret->source.adapter.type) { + if (!adapter->type) { virReportError(VIR_ERR_XML_ERROR, "%s", _("missing storage pool source adapter")); return -1; } =20 - if (ret->source.adapter.type =3D=3D - VIR_STORAGE_POOL_SOURCE_ADAPTER_TYPE_FC_HOST) - return virStorageAdapterFCHostParseValidate(&ret->source.adapter.d= ata.fchost); + if (adapter->type =3D=3D VIR_STORAGE_ADAPTER_TYPE_FC_HOST) + return virStorageAdapterFCHostParseValidate(&adapter->data.fchost); =20 - if (ret->source.adapter.type =3D=3D - VIR_STORAGE_POOL_SOURCE_ADAPTER_TYPE_SCSI_HOST) - return virStorageAdapterSCSIHostParseValidate(&ret->source.adapter= .data.scsi_host); + if (adapter->type =3D=3D VIR_STORAGE_ADAPTER_TYPE_SCSI_HOST) + return virStorageAdapterSCSIHostParseValidate(&adapter->data.scsi_= host); =20 return 0; } @@ -285,13 +280,13 @@ virStorageAdapterFCHostFormat(virBufferPtr buf, virStorageAdapterFCHostPtr fchost) { virBufferEscapeString(buf, " parent=3D'%s'", fchost->parent); - if (fchost->managed) - virBufferAsprintf(buf, " managed=3D'%s'", - virTristateBoolTypeToString(fchost->managed)); virBufferEscapeString(buf, " parent_wwnn=3D'%s'", fchost->parent_wwnn); virBufferEscapeString(buf, " parent_wwpn=3D'%s'", fchost->parent_wwpn); virBufferEscapeString(buf, " parent_fabric_wwn=3D'%s'", fchost->parent_fabric_wwn); + if (fchost->managed !=3D VIR_TRISTATE_BOOL_ABSENT) + virBufferAsprintf(buf, " managed=3D'%s'", + virTristateBoolTypeToString(fchost->managed)); =20 virBufferAsprintf(buf, " wwnn=3D'%s' wwpn=3D'%s'/>\n", fchost->wwnn, fchost->wwpn); @@ -322,14 +317,14 @@ virStorageAdapterSCSIHostFormat(virBufferPtr buf, =20 void virStorageAdapterFormat(virBufferPtr buf, - virStoragePoolSourcePtr src) + virStorageAdapterPtr adapter) { virBufferAsprintf(buf, "adapter= .type)); + virStorageAdapterTypeToString(adapter->type)); =20 - if (src->adapter.type =3D=3D VIR_STORAGE_POOL_SOURCE_ADAPTER_TYPE_FC_H= OST) - virStorageAdapterFCHostFormat(buf, &src->adapter.data.fchost); + if (adapter->type =3D=3D VIR_STORAGE_ADAPTER_TYPE_FC_HOST) + virStorageAdapterFCHostFormat(buf, &adapter->data.fchost); =20 - if (src->adapter.type =3D=3D VIR_STORAGE_POOL_SOURCE_ADAPTER_TYPE_SCSI= _HOST) - virStorageAdapterSCSIHostFormat(buf, &src->adapter.data.scsi_host); + if (adapter->type =3D=3D VIR_STORAGE_ADAPTER_TYPE_SCSI_HOST) + virStorageAdapterSCSIHostFormat(buf, &adapter->data.scsi_host); } diff --git a/src/conf/storage_adapter_conf.h b/src/conf/storage_adapter_con= f.h index ec812a1..730a3ca 100644 --- a/src/conf/storage_adapter_conf.h +++ b/src/conf/storage_adapter_conf.h @@ -23,21 +23,62 @@ # include "virpci.h" # include "virxml.h" =20 -# include "storage_conf.h" + +typedef enum { + VIR_STORAGE_ADAPTER_TYPE_DEFAULT =3D 0, + VIR_STORAGE_ADAPTER_TYPE_SCSI_HOST, + VIR_STORAGE_ADAPTER_TYPE_FC_HOST, + + VIR_STORAGE_ADAPTER_TYPE_LAST, +} virStorageAdapterType; +VIR_ENUM_DECL(virStorageAdapter) + +typedef struct _virStorageAdapterSCSIHost virStorageAdapterSCSIHost; +typedef virStorageAdapterSCSIHost *virStorageAdapterSCSIHostPtr; +struct _virStorageAdapterSCSIHost { + char *name; + virPCIDeviceAddress parentaddr; /* host address */ + int unique_id; + bool has_parent; +}; + +typedef struct _virStorageAdapterFCHost virStorageAdapterFCHost; +typedef virStorageAdapterFCHost *virStorageAdapterFCHostPtr; +struct _virStorageAdapterFCHost { + char *parent; + char *parent_wwnn; + char *parent_wwpn; + char *parent_fabric_wwn; + char *wwnn; + char *wwpn; + int managed; /* enum virTristateSwitch */ +}; + +typedef struct _virStorageAdapter virStorageAdapter; +typedef virStorageAdapter *virStorageAdapterPtr; +struct _virStorageAdapter { + int type; /* virStorageAdapterType */ + + union { + virStorageAdapterSCSIHost scsi_host; + virStorageAdapterFCHost fchost; + } data; +}; + =20 void -virStorageAdapterClear(virStoragePoolSourceAdapterPtr adapter); +virStorageAdapterClear(virStorageAdapterPtr adapter); =20 int -virStorageAdapterParseXML(virStoragePoolSourcePtr source, +virStorageAdapterParseXML(virStorageAdapterPtr adapter, xmlNodePtr node, xmlXPathContextPtr ctxt); =20 int -virStorageAdapterParseValidate(virStoragePoolDefPtr ret); +virStorageAdapterParseValidate(virStorageAdapterPtr adapter); =20 void virStorageAdapterFormat(virBufferPtr buf, - virStoragePoolSourcePtr src); + virStorageAdapterPtr adapter); =20 #endif /* __VIR_STORAGE_ADAPTER_CONF_H__ */ diff --git a/src/conf/storage_conf.c b/src/conf/storage_conf.c index 45dc860..7207605 100644 --- a/src/conf/storage_conf.c +++ b/src/conf/storage_conf.c @@ -565,7 +565,7 @@ virStoragePoolDefParseSource(xmlXPathContextPtr ctxt, goto cleanup; =20 if ((adapternode =3D virXPathNode("./adapter", ctxt))) { - if (virStorageAdapterParseXML(source, adapternode, ctxt) < 0) + if (virStorageAdapterParseXML(&source->adapter, adapternode, ctxt)= < 0) goto cleanup; } =20 @@ -802,7 +802,7 @@ virStoragePoolDefParseXML(xmlXPathContextPtr ctxt) } =20 if ((options->flags & VIR_STORAGE_POOL_SOURCE_ADAPTER) && - (virStorageAdapterParseValidate(ret)) < 0) + (virStorageAdapterParseValidate(&ret->source.adapter)) < 0) goto error; =20 /* If DEVICE is the only source type, then its required */ @@ -958,9 +958,9 @@ virStoragePoolSourceFormat(virBufferPtr buf, virBufferEscapeString(buf, "\n", src->dir); =20 if ((options->flags & VIR_STORAGE_POOL_SOURCE_ADAPTER) && - (src->adapter.type =3D=3D VIR_STORAGE_POOL_SOURCE_ADAPTER_TYPE_FC_= HOST || - src->adapter.type =3D=3D VIR_STORAGE_POOL_SOURCE_ADAPTER_TYPE_SCS= I_HOST)) - virStorageAdapterFormat(buf, src); + (src->adapter.type =3D=3D VIR_STORAGE_ADAPTER_TYPE_FC_HOST || + src->adapter.type =3D=3D VIR_STORAGE_ADAPTER_TYPE_SCSI_HOST)) + virStorageAdapterFormat(buf, &src->adapter); =20 if (options->flags & VIR_STORAGE_POOL_SOURCE_NAME) virBufferEscapeString(buf, "%s\n", src->name); @@ -2266,8 +2266,8 @@ virStoragePoolSourceFindDuplicate(virConnectPtr conn, int ret =3D 1; virStoragePoolObjPtr pool =3D NULL; virStoragePoolObjPtr matchpool =3D NULL; - virStoragePoolSourceAdapterPtr pool_adapter; - virStoragePoolSourceAdapterPtr def_adapter; + virStorageAdapterPtr pool_adapter; + virStorageAdapterPtr def_adapter; =20 /* Check the pool list for duplicate underlying storage */ for (i =3D 0; i < pools->count; i++) { @@ -2306,10 +2306,8 @@ virStoragePoolSourceFindDuplicate(virConnectPtr conn, pool_adapter =3D &pool->def->source.adapter; def_adapter =3D &def->source.adapter; =20 - if (pool_adapter->type =3D=3D - VIR_STORAGE_POOL_SOURCE_ADAPTER_TYPE_FC_HOST && - def_adapter->type =3D=3D - VIR_STORAGE_POOL_SOURCE_ADAPTER_TYPE_FC_HOST) { + if (pool_adapter->type =3D=3D VIR_STORAGE_ADAPTER_TYPE_FC_HOST= && + def_adapter->type =3D=3D VIR_STORAGE_ADAPTER_TYPE_FC_HOST)= { virStorageAdapterFCHostPtr pool_fchost =3D &pool_adapter->data.fchost; virStorageAdapterFCHostPtr def_fchost =3D @@ -2319,9 +2317,9 @@ virStoragePoolSourceFindDuplicate(virConnectPtr conn, STREQ(pool_fchost->wwpn, def_fchost->wwpn)) matchpool =3D pool; } else if (pool_adapter->type =3D=3D - VIR_STORAGE_POOL_SOURCE_ADAPTER_TYPE_SCSI_HOST && + VIR_STORAGE_ADAPTER_TYPE_SCSI_HOST && def_adapter->type =3D=3D - VIR_STORAGE_POOL_SOURCE_ADAPTER_TYPE_SCSI_HOST) { + VIR_STORAGE_ADAPTER_TYPE_SCSI_HOST) { virStorageAdapterSCSIHostPtr pool_scsi_host =3D &pool_adapter->data.scsi_host; virStorageAdapterSCSIHostPtr def_scsi_host =3D @@ -2341,9 +2339,9 @@ virStoragePoolSourceFindDuplicate(virConnectPtr conn, if (pool_hostnum =3D=3D def_hostnum) matchpool =3D pool; } else if (pool_adapter->type =3D=3D - VIR_STORAGE_POOL_SOURCE_ADAPTER_TYPE_FC_HOST && + VIR_STORAGE_ADAPTER_TYPE_FC_HOST && def_adapter->type =3D=3D - VIR_STORAGE_POOL_SOURCE_ADAPTER_TYPE_SCSI_HOST) { + VIR_STORAGE_ADAPTER_TYPE_SCSI_HOST) { virStorageAdapterFCHostPtr pool_fchost =3D &pool_adapter->data.fchost; virStorageAdapterSCSIHostPtr def_scsi_host =3D @@ -2360,9 +2358,9 @@ virStoragePoolSourceFindDuplicate(virConnectPtr conn, } =20 } else if (pool_adapter->type =3D=3D - VIR_STORAGE_POOL_SOURCE_ADAPTER_TYPE_SCSI_HOST && + VIR_STORAGE_ADAPTER_TYPE_SCSI_HOST && def_adapter->type =3D=3D - VIR_STORAGE_POOL_SOURCE_ADAPTER_TYPE_FC_HOST) { + VIR_STORAGE_ADAPTER_TYPE_FC_HOST) { virStorageAdapterSCSIHostPtr pool_scsi_host =3D &pool_adapter->data.scsi_host; virStorageAdapterFCHostPtr def_fchost =3D diff --git a/src/conf/storage_conf.h b/src/conf/storage_conf.h index 1012e74..6f20111 100644 --- a/src/conf/storage_conf.h +++ b/src/conf/storage_conf.h @@ -31,6 +31,7 @@ # include "virthread.h" # include "device_conf.h" # include "object_event.h" +# include "storage_adapter_conf.h" =20 # include =20 @@ -170,47 +171,6 @@ struct _virStoragePoolSourceDevice { } geometry; }; =20 -typedef enum { - VIR_STORAGE_POOL_SOURCE_ADAPTER_TYPE_DEFAULT =3D 0, - VIR_STORAGE_POOL_SOURCE_ADAPTER_TYPE_SCSI_HOST, - VIR_STORAGE_POOL_SOURCE_ADAPTER_TYPE_FC_HOST, - - VIR_STORAGE_POOL_SOURCE_ADAPTER_TYPE_LAST, -} virStoragePoolSourceAdapterType; -VIR_ENUM_DECL(virStoragePoolSourceAdapter) - -typedef struct _virStorageAdapterSCSIHost virStorageAdapterSCSIHost; -typedef virStorageAdapterSCSIHost *virStorageAdapterSCSIHostPtr; -struct _virStorageAdapterSCSIHost { - char *name; - virPCIDeviceAddress parentaddr; /* host address */ - int unique_id; - bool has_parent; -}; - -typedef struct _virStorageAdapterFCHost virStorageAdapterFCHost; -typedef virStorageAdapterFCHost *virStorageAdapterFCHostPtr; -struct _virStorageAdapterFCHost { - char *parent; - char *parent_wwnn; - char *parent_wwpn; - char *parent_fabric_wwn; - char *wwnn; - char *wwpn; - int managed; /* enum virTristateSwitch */ -}; - -typedef struct _virStoragePoolSourceAdapter virStoragePoolSourceAdapter; -typedef virStoragePoolSourceAdapter *virStoragePoolSourceAdapterPtr; -struct _virStoragePoolSourceAdapter { - int type; /* virStoragePoolSourceAdapterType */ - - union { - virStorageAdapterSCSIHost scsi_host; - virStorageAdapterFCHost fchost; - } data; -}; - typedef struct _virStoragePoolSource virStoragePoolSource; typedef virStoragePoolSource *virStoragePoolSourcePtr; struct _virStoragePoolSource { @@ -226,7 +186,7 @@ struct _virStoragePoolSource { char *dir; =20 /* Or an adapter */ - virStoragePoolSourceAdapter adapter; + virStorageAdapter adapter; =20 /* Or a name */ char *name; diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index 6a2bdf2..8a9e71b 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -883,8 +883,6 @@ virStoragePoolObjSaveDef; virStoragePoolObjUnlock; virStoragePoolSaveConfig; virStoragePoolSaveState; -virStoragePoolSourceAdapterTypeFromString; -virStoragePoolSourceAdapterTypeToString; virStoragePoolSourceClear; virStoragePoolSourceDeviceClear; virStoragePoolSourceFindDuplicate; diff --git a/src/phyp/phyp_driver.c b/src/phyp/phyp_driver.c index 7a5df3f..39fa026 100644 --- a/src/phyp/phyp_driver.c +++ b/src/phyp/phyp_driver.c @@ -2467,8 +2467,7 @@ phypBuildStoragePool(virConnectPtr conn, virStoragePo= olDefPtr def) int exit_status =3D 0; virBuffer buf =3D VIR_BUFFER_INITIALIZER; =20 - if (source.adapter.type !=3D - VIR_STORAGE_POOL_SOURCE_ADAPTER_TYPE_SCSI_HOST) { + if (source.adapter.type !=3D VIR_STORAGE_ADAPTER_TYPE_SCSI_HOST) { virReportError(VIR_ERR_XML_ERROR, "%s", _("Only 'scsi_host' adapter is supported")); goto cleanup; diff --git a/src/storage/storage_backend_scsi.c b/src/storage/storage_backe= nd_scsi.c index 77a51ff..ff17409 100644 --- a/src/storage/storage_backend_scsi.c +++ b/src/storage/storage_backend_scsi.c @@ -176,12 +176,12 @@ virStoragePoolFCRefreshThread(void *opaque) } =20 static char * -getAdapterName(virStoragePoolSourceAdapterPtr adapter) +getAdapterName(virStorageAdapterPtr adapter) { char *name =3D NULL; char *parentaddr =3D NULL; =20 - if (adapter->type =3D=3D VIR_STORAGE_POOL_SOURCE_ADAPTER_TYPE_SCSI_HOS= T) { + if (adapter->type =3D=3D VIR_STORAGE_ADAPTER_TYPE_SCSI_HOST) { virStorageAdapterSCSIHostPtr scsi_host =3D &adapter->data.scsi_hos= t; =20 if (scsi_host->has_parent) { @@ -197,7 +197,9 @@ getAdapterName(virStoragePoolSourceAdapterPtr adapter) } else { ignore_value(VIR_STRDUP(name, scsi_host->name)); } - } else if (adapter->type =3D=3D VIR_STORAGE_POOL_SOURCE_ADAPTER_TYPE_F= C_HOST) { + } + + if (adapter->type =3D=3D VIR_STORAGE_ADAPTER_TYPE_FC_HOST) { virStorageAdapterFCHostPtr fchost =3D &adapter->data.fchost; =20 if (!(name =3D virVHBAGetHostByWWN(NULL, fchost->wwnn, fchost->wwp= n))) { @@ -451,7 +453,7 @@ virStorageBackendSCSICheckPool(virStoragePoolObjPtr poo= l, * the adapter based on might be not created yet. */ if (pool->def->source.adapter.type =3D=3D - VIR_STORAGE_POOL_SOURCE_ADAPTER_TYPE_FC_HOST) { + VIR_STORAGE_ADAPTER_TYPE_FC_HOST) { virResetLastError(); return 0; } else { @@ -505,24 +507,24 @@ virStorageBackendSCSIRefreshPool(virConnectPtr conn A= TTRIBUTE_UNUSED, return ret; } =20 + static int virStorageBackendSCSIStartPool(virConnectPtr conn, virStoragePoolObjPtr pool) { - if (pool->def->source.adapter.type =3D=3D - VIR_STORAGE_POOL_SOURCE_ADAPTER_TYPE_FC_HOST) + if (pool->def->source.adapter.type =3D=3D VIR_STORAGE_ADAPTER_TYPE_FC_= HOST) return createVport(conn, pool->def, pool->configFile, &pool->def->source.adapter.data.fchost); =20 return 0; } =20 + static int virStorageBackendSCSIStopPool(virConnectPtr conn, virStoragePoolObjPtr pool) { - if (pool->def->source.adapter.type =3D=3D - VIR_STORAGE_POOL_SOURCE_ADAPTER_TYPE_FC_HOST) + if (pool->def->source.adapter.type =3D=3D VIR_STORAGE_ADAPTER_TYPE_FC_= HOST) return deleteVport(conn, &pool->def->source.adapter.data.fchost); =20 return 0; diff --git a/src/test/test_driver.c b/src/test/test_driver.c index cf7820a..18792bc 100644 --- a/src/test/test_driver.c +++ b/src/test/test_driver.c @@ -4420,8 +4420,7 @@ testStoragePoolCreateXML(virConnectPtr conn, goto cleanup; def =3D NULL; =20 - if (pool->def->source.adapter.type =3D=3D - VIR_STORAGE_POOL_SOURCE_ADAPTER_TYPE_FC_HOST) { + if (pool->def->source.adapter.type =3D=3D VIR_STORAGE_ADAPTER_TYPE_FC_= HOST) { /* In the real code, we'd call virVHBAManageVport followed by * find_new_device, but we cannot do that here since we're not * mocking udev. The mock routine will copy an existing vHBA and @@ -4623,7 +4622,7 @@ testStoragePoolDestroy(virStoragePoolPtr pool) privpool->active =3D 0; =20 if (privpool->def->source.adapter.type =3D=3D - VIR_STORAGE_POOL_SOURCE_ADAPTER_TYPE_FC_HOST) { + VIR_STORAGE_ADAPTER_TYPE_FC_HOST) { if (testDestroyVport(privconn, privpool->def->source.adapter.data.fchost.wwn= n, privpool->def->source.adapter.data.fchost.wwp= n) < 0) --=20 2.9.3 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Fri May 3 01:20:00 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.24 as permitted sender) client-ip=209.132.183.24; envelope-from=libvir-list-bounces@redhat.com; helo=mx3-phx2.redhat.com; Authentication-Results: mx.zoho.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.24 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; Return-Path: Received: from mx3-phx2.redhat.com (mx3-phx2.redhat.com [209.132.183.24]) by mx.zohomail.com with SMTPS id 148918048225921.48354432366625; Fri, 10 Mar 2017 13:14:42 -0800 (PST) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by mx3-phx2.redhat.com (8.13.8/8.13.8) with ESMTP id v2ALBX3k006738; Fri, 10 Mar 2017 16:11:33 -0500 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id v2ALB1nd024008 for ; Fri, 10 Mar 2017 16:11:01 -0500 Received: from localhost.localdomain.com (ovpn-117-9.phx2.redhat.com [10.3.117.9]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id v2ALArRv011410 for ; Fri, 10 Mar 2017 16:11:00 -0500 From: John Ferlan To: libvir-list@redhat.com Date: Fri, 10 Mar 2017 16:10:47 -0500 Message-Id: <20170310211050.27784-16-jferlan@redhat.com> In-Reply-To: <20170310211050.27784-1-jferlan@redhat.com> References: <20170310211050.27784-1-jferlan@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.24 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH v3 15/18] util: Rename virFileWaitForDevices 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-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" The function is actually in virutil.c, but prototyped in virfile.h. This patch fixes that by renaming the function to virWaitForDevices, adding the prototype in virutil.h and libvirt_private.syms, and then changing the callers to use the new name. Signed-off-by: John Ferlan --- src/libvirt_private.syms | 2 +- src/node_device/node_device_driver.c | 2 +- src/storage/storage_backend_disk.c | 6 +++--- src/storage/storage_backend_iscsi.c | 2 +- src/storage/storage_backend_logical.c | 4 ++-- src/storage/storage_backend_mpath.c | 2 +- src/storage/storage_backend_scsi.c | 2 +- src/storage/storage_util.c | 2 +- src/util/virfile.h | 2 -- src/util/virutil.c | 4 ++-- src/util/virutil.h | 2 ++ 11 files changed, 15 insertions(+), 15 deletions(-) diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index 8a9e71b..7bdcde7 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -1648,7 +1648,6 @@ virFileStripSuffix; virFileTouch; virFileUnlock; virFileUpdatePerm; -virFileWaitForDevices; virFileWrapperFdClose; virFileWrapperFdFree; virFileWrapperFdNew; @@ -2758,6 +2757,7 @@ virTristateSwitchTypeFromString; virTristateSwitchTypeToString; virUpdateSelfLastChanged; virValidateWWN; +virWaitForDevices; =20 =20 # util/viruuid.h diff --git a/src/node_device/node_device_driver.c b/src/node_device/node_de= vice_driver.c index 39fd438..99f7bc5 100644 --- a/src/node_device/node_device_driver.c +++ b/src/node_device/node_device_driver.c @@ -548,7 +548,7 @@ find_new_device(virConnectPtr conn, const char *wwnn, c= onst char *wwpn) =20 while ((now - start) < LINUX_NEW_DEVICE_WAIT_TIME) { =20 - virFileWaitForDevices(); + virWaitForDevices(); =20 dev =3D nodeDeviceLookupSCSIHostByWWN(conn, wwnn, wwpn, 0); =20 diff --git a/src/storage/storage_backend_disk.c b/src/storage/storage_backe= nd_disk.c index 50bdd36..39371f2 100644 --- a/src/storage/storage_backend_disk.c +++ b/src/storage/storage_backend_disk.c @@ -426,7 +426,7 @@ virStorageBackendDiskRefreshPool(virConnectPtr conn ATT= RIBUTE_UNUSED, VIR_FREE(pool->def->source.devices[0].freeExtents); pool->def->source.devices[0].nfreeExtent =3D 0; =20 - virFileWaitForDevices(); + virWaitForDevices(); =20 if (!virFileExists(pool->def->source.devices[0].path)) { virReportError(VIR_ERR_INVALID_ARG, @@ -450,7 +450,7 @@ virStorageBackendDiskStartPool(virConnectPtr conn ATTRI= BUTE_UNUSED, virStoragePoolFormatDiskTypeToString(pool->def->source.format); const char *path =3D pool->def->source.devices[0].path; =20 - virFileWaitForDevices(); + virWaitForDevices(); =20 if (!virFileExists(path)) { virReportError(VIR_ERR_INVALID_ARG, @@ -859,7 +859,7 @@ virStorageBackendDiskCreateVol(virConnectPtr conn, goto cleanup; =20 /* wait for device node to show up */ - virFileWaitForDevices(); + virWaitForDevices(); =20 /* Blow away free extent info, as we're about to re-populate it */ VIR_FREE(pool->def->source.devices[0].freeExtents); diff --git a/src/storage/storage_backend_iscsi.c b/src/storage/storage_back= end_iscsi.c index 866fa74..14f3e09 100644 --- a/src/storage/storage_backend_iscsi.c +++ b/src/storage/storage_backend_iscsi.c @@ -98,7 +98,7 @@ virStorageBackendISCSIGetHostNumber(const char *sysfs_pat= h, =20 VIR_DEBUG("Finding host number from '%s'", sysfs_path); =20 - virFileWaitForDevices(); + virWaitForDevices(); =20 if (virDirOpen(&sysdir, sysfs_path) < 0) goto cleanup; diff --git a/src/storage/storage_backend_logical.c b/src/storage/storage_ba= ckend_logical.c index 756c62e..29d63b1 100644 --- a/src/storage/storage_backend_logical.c +++ b/src/storage/storage_backend_logical.c @@ -831,7 +831,7 @@ virStorageBackendLogicalRefreshPool(virConnectPtr conn = ATTRIBUTE_UNUSED, virCommandPtr cmd =3D NULL; int ret =3D -1; =20 - virFileWaitForDevices(); + virWaitForDevices(); =20 /* Get list of all logical volumes */ if (virStorageBackendLogicalFindLVs(pool, NULL) < 0) @@ -925,7 +925,7 @@ virStorageBackendLogicalDeleteVol(virConnectPtr conn AT= TRIBUTE_UNUSED, =20 virCheckFlags(0, -1); =20 - virFileWaitForDevices(); + virWaitForDevices(); =20 lvchange_cmd =3D virCommandNewArgList(LVCHANGE, "-aln", vol->target.pa= th, NULL); lvremove_cmd =3D virCommandNewArgList(LVREMOVE, "-f", vol->target.path= , NULL); diff --git a/src/storage/storage_backend_mpath.c b/src/storage/storage_back= end_mpath.c index 4bb38bb..606b399 100644 --- a/src/storage/storage_backend_mpath.c +++ b/src/storage/storage_backend_mpath.c @@ -262,7 +262,7 @@ virStorageBackendMpathRefreshPool(virConnectPtr conn AT= TRIBUTE_UNUSED, =20 pool->def->allocation =3D pool->def->capacity =3D pool->def->available= =3D 0; =20 - virFileWaitForDevices(); + virWaitForDevices(); =20 virStorageBackendGetMaps(pool); =20 diff --git a/src/storage/storage_backend_scsi.c b/src/storage/storage_backe= nd_scsi.c index ff17409..abbd38d 100644 --- a/src/storage/storage_backend_scsi.c +++ b/src/storage/storage_backend_scsi.c @@ -349,7 +349,7 @@ createVport(virConnectPtr conn, VPORT_CREATE) < 0) goto cleanup; =20 - virFileWaitForDevices(); + virWaitForDevices(); =20 /* Creating our own VPORT didn't leave enough time to find any LUN's, * so, let's create a thread whose job it is to call the FindLU's with diff --git a/src/storage/storage_util.c b/src/storage/storage_util.c index bf6f0b3..38d373e 100644 --- a/src/storage/storage_util.c +++ b/src/storage/storage_util.c @@ -4017,7 +4017,7 @@ virStorageBackendSCSIFindLUs(virStoragePoolObjPtr poo= l, =20 VIR_DEBUG("Discovering LUs on host %u", scanhost); =20 - virFileWaitForDevices(); + virWaitForDevices(); =20 if (virDirOpen(&devicedir, device_path) < 0) return -1; diff --git a/src/util/virfile.h b/src/util/virfile.h index f2a3faa..b29feee 100644 --- a/src/util/virfile.h +++ b/src/util/virfile.h @@ -292,8 +292,6 @@ int virFileOpenTty(int *ttymaster, =20 char *virFileFindMountPoint(const char *type); =20 -void virFileWaitForDevices(void); - /* NB: this should be combined with virFileBuildPath */ # define virBuildPath(path, ...) \ virBuildPathInternal(path, __VA_ARGS__, NULL) diff --git a/src/util/virutil.c b/src/util/virutil.c index bb0f2d2..79db1d8 100644 --- a/src/util/virutil.c +++ b/src/util/virutil.c @@ -1582,7 +1582,7 @@ virSetUIDGIDWithCaps(uid_t uid, gid_t gid, gid_t *gro= ups, int ngroups, =20 =20 #if defined(UDEVADM) || defined(UDEVSETTLE) -void virFileWaitForDevices(void) +void virWaitForDevices(void) { # ifdef UDEVADM const char *const settleprog[] =3D { UDEVADM, "settle", NULL }; @@ -1603,7 +1603,7 @@ void virFileWaitForDevices(void) ignore_value(virRun(settleprog, &exitstatus)); } #else -void virFileWaitForDevices(void) +void virWaitForDevices(void) {} #endif =20 diff --git a/src/util/virutil.h b/src/util/virutil.h index 877207c..e097b77 100644 --- a/src/util/virutil.h +++ b/src/util/virutil.h @@ -51,6 +51,8 @@ int virSetUIDGIDWithCaps(uid_t uid, gid_t gid, gid_t *gro= ups, int ngroups, unsigned long long capBits, bool clearExistingCaps); =20 +void virWaitForDevices(void); + int virScaleInteger(unsigned long long *value, const char *suffix, unsigned long long scale, unsigned long long limit) ATTRIBUTE_NONNULL(1) ATTRIBUTE_RETURN_CHECK; --=20 2.9.3 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Fri May 3 01:20:00 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.25 as permitted sender) client-ip=209.132.183.25; envelope-from=libvir-list-bounces@redhat.com; helo=mx4-phx2.redhat.com; Authentication-Results: mx.zoho.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.25 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; Return-Path: Received: from mx4-phx2.redhat.com (mx4-phx2.redhat.com [209.132.183.25]) by mx.zohomail.com with SMTPS id 1489180501262347.9096203214185; Fri, 10 Mar 2017 13:15:01 -0800 (PST) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by mx4-phx2.redhat.com (8.13.8/8.13.8) with ESMTP id v2ALBZuW009227; Fri, 10 Mar 2017 16:11:35 -0500 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id v2ALB1Xq024013 for ; Fri, 10 Mar 2017 16:11:01 -0500 Received: from localhost.localdomain.com (ovpn-117-9.phx2.redhat.com [10.3.117.9]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id v2ALArRw011410 for ; Fri, 10 Mar 2017 16:11:01 -0500 From: John Ferlan To: libvir-list@redhat.com Date: Fri, 10 Mar 2017 16:10:48 -0500 Message-Id: <20170310211050.27784-17-jferlan@redhat.com> In-Reply-To: <20170310211050.27784-1-jferlan@redhat.com> References: <20170310211050.27784-1-jferlan@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.24 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH v3 16/18] conf: Move/rename createVport and deleteVport 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-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Move the bulk of the code to the node_device_conf and rename to virNodeDevice{Create|Delete}Vport. Alter the create algorithm slightly in order to return the name of the scsi_host vHBA that was created. The existing code would fetch the name and if it exists would start a thread looking for the LUNs; however, in no way did it validate the device was created for the storage pool even though it would be used thereafter. This slight change allows the code that checks if the node device by wwnn/wwpn already exists and return that name. This fixes a second yet seen issue that if the nodedev was present, but the parent by name wasn't provided (perhaps parent by wwnn/wwpn or by fabric_name), then a failure would be returned. For this path it shouldn't be an error - we should just be happy that something else is managing the device and we don't have to create/delete it. The end result is that the startVport code can now just start the thread once it gets a non NULL name back. Signed-off-by: John Ferlan --- src/conf/node_device_conf.c | 211 +++++++++++++++++++++++++++++++++= ++++ src/conf/node_device_conf.h | 9 ++ src/libvirt_private.syms | 2 + src/storage/storage_backend_scsi.c | 192 +++------------------------------ 4 files changed, 235 insertions(+), 179 deletions(-) diff --git a/src/conf/node_device_conf.c b/src/conf/node_device_conf.c index 3565aec..66cb78d 100644 --- a/src/conf/node_device_conf.c +++ b/src/conf/node_device_conf.c @@ -1870,3 +1870,214 @@ virNodeDeviceGetParentName(virConnectPtr conn, =20 return parent; } + + +/* + * 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 +nodeDeviceCheckParent(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 + * + * Create a vHBA for Storage. This code accomplishes this via searching + * through the sysfs for scsi_host/fc_host in order to first ensure some + * vHBA doesn't already exist for the requested wwnn/wwpn (e.g. an unmanag= ed + * vHBA) and to search for the parent vport capable scsi_host by name, + * wwnn/wwpn, or fabric_wwn (if provided). If no parent is provided, then + * a vport capable scsi_host will be selected. + * + * Returns vHBA name on success, NULL on failure with an error message set + */ +char * +virNodeDeviceCreateVport(virConnectPtr conn, + virStorageAdapterFCHostPtr fchost) +{ + unsigned int parent_host; + char *name =3D NULL; + char *parent_hoststr =3D NULL; + bool skip_capable_check =3D false; + + VIR_DEBUG("conn=3D%p, parent=3D'%s', wwnn=3D'%s' wwpn=3D'%s'", + conn, NULLSTR(fchost->parent), fchost->wwnn, fchost->wwpn); + + /* 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 && nodeDeviceCheckParent(conn, name, fchost->pa= rent)) + VIR_FREE(name); + + return name; + } + + if (fchost->parent) { + if (VIR_STRDUP(parent_hoststr, fchost->parent) < 0) + goto cleanup; + } else if (fchost->parent_wwnn && fchost->parent_wwpn) { + if (!(parent_hoststr =3D virVHBAGetHostByWWN(NULL, fchost->parent_= wwnn, + fchost->parent_wwpn))) { + virReportError(VIR_ERR_XML_ERROR, "%s", + _("cannot find parent using provided wwnn/wwpn"= )); + goto cleanup; + } + } else if (fchost->parent_fabric_wwn) { + if (!(parent_hoststr =3D + virVHBAGetHostByFabricWWN(NULL, fchost->parent_fabric_wwn)))= { + virReportError(VIR_ERR_XML_ERROR, "%s", + _("cannot find parent using provided fabric_wwn= ")); + goto cleanup; + } + } else { + if (!(parent_hoststr =3D virVHBAFindVportHost(NULL))) { + virReportError(VIR_ERR_XML_ERROR, "%s", + _("'parent' for vHBA not specified, and " + "cannot find one on this host")); + goto cleanup; + } + skip_capable_check =3D true; + } + + if (virSCSIHostGetNumber(parent_hoststr, &parent_host) < 0) + goto cleanup; + + /* NOTE: + * We do not save the parent_hoststr in fchost->parent since + * we could be writing out the 'def' to the saved XML config. + * If we wrote out the name in the XML, then future starts would + * always use the same parent rather than finding the "best available" + * parent. Besides we have a way to determine the parent based on + * the 'name' field. + */ + if (!skip_capable_check && !virVHBAPathExists(NULL, parent_host)) { + virReportError(VIR_ERR_XML_ERROR, + _("parent '%s' specified for vHBA does not exist"), + parent_hoststr); + goto cleanup; + } + + if (virVHBAManageVport(parent_host, fchost->wwpn, fchost->wwnn, + VPORT_CREATE) < 0) + goto cleanup; + + /* Let's ensure the device was created */ + virWaitForDevices(); + if (!(name =3D virVHBAGetHostByWWN(NULL, fchost->wwnn, fchost->wwpn)))= { + ignore_value(virVHBAManageVport(parent_host, fchost->wwpn, fchost-= >wwnn, + VPORT_DELETE)); + goto cleanup; + } + + cleanup: + VIR_FREE(parent_hoststr); + return name; +} + + +/** + * @conn: Connection pointer + * @fchost: Pointer to vHBA adapter + * + * As long as the vHBA is being managed, search for the scsi_host via the + * provided wwnn/wwpn and then find the corresponding parent scsi_host in + * order to send the delete request. + * + * Returns 0 on success, -1 on failure + */ +int +virNodeDeviceDeleteVport(virConnectPtr conn, + virStorageAdapterFCHostPtr fchost) +{ + char *name =3D NULL; + char *scsi_host_name =3D NULL; + unsigned int parent_host; + char *vhba_parent =3D NULL; + int ret =3D -1; + + VIR_DEBUG("conn=3D%p parent=3D'%s', managed=3D'%d' wwnn=3D'%s' wwpn=3D= '%s'", + conn, NULLSTR(fchost->parent), fchost->managed, + fchost->wwnn, fchost->wwpn); + + /* If we're not managing the deletion of the vHBA, then just return */ + if (fchost->managed !=3D VIR_TRISTATE_BOOL_YES) + return 0; + + /* Find our vHBA by searching the fc_host sysfs tree for our wwnn/wwpn= */ + if (!(name =3D virVHBAGetHostByWWN(NULL, fchost->wwnn, fchost->wwpn)))= { + virReportError(VIR_ERR_INTERNAL_ERROR, + _("Failed to find fc_host for wwnn=3D'%s' and wwpn= =3D'%s'"), + fchost->wwnn, fchost->wwpn); + goto cleanup; + } + + /* If at startup time we provided a parent, then use that to + * get the parent_host value; otherwise, we have to determine + * the parent scsi_host which we did not save at startup time + */ + if (fchost->parent) { + if (virSCSIHostGetNumber(fchost->parent, &parent_host) < 0) + goto cleanup; + } else { + if (virAsprintf(&scsi_host_name, "scsi_%s", name) < 0) + goto cleanup; + + if (!(vhba_parent =3D virNodeDeviceGetParentName(conn, scsi_host_n= ame))) + goto cleanup; + + if (virSCSIHostGetNumber(vhba_parent, &parent_host) < 0) + goto cleanup; + } + + if (virVHBAManageVport(parent_host, fchost->wwpn, fchost->wwnn, + VPORT_DELETE) < 0) + goto cleanup; + + ret =3D 0; + + cleanup: + VIR_FREE(name); + VIR_FREE(vhba_parent); + VIR_FREE(scsi_host_name); + return ret; +} diff --git a/src/conf/node_device_conf.h b/src/conf/node_device_conf.h index cf51c69..15e2eac 100644 --- a/src/conf/node_device_conf.h +++ b/src/conf/node_device_conf.h @@ -28,8 +28,11 @@ # include "internal.h" # include "virbitmap.h" # include "virutil.h" +# include "virscsihost.h" # include "virpci.h" +# include "virvhba.h" # include "device_conf.h" +# include "storage_adapter_conf.h" =20 # include =20 @@ -354,4 +357,10 @@ char * virNodeDeviceGetParentName(virConnectPtr conn, const char *nodedev_name); =20 +char *virNodeDeviceCreateVport(virConnectPtr conn, + virStorageAdapterFCHostPtr fchost); + +int virNodeDeviceDeleteVport(virConnectPtr conn, + virStorageAdapterFCHostPtr fchost); + #endif /* __VIR_NODE_DEVICE_CONF_H__ */ diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index 7bdcde7..cacc7aa 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -686,11 +686,13 @@ virNetDevIPRouteParseXML; virNodeDevCapsDefFree; virNodeDevCapTypeFromString; virNodeDevCapTypeToString; +virNodeDeviceCreateVport; virNodeDeviceDefFormat; virNodeDeviceDefFree; virNodeDeviceDefParseFile; virNodeDeviceDefParseNode; virNodeDeviceDefParseString; +virNodeDeviceDeleteVport; virNodeDeviceGetParentName; virNodeDeviceGetWWNs; =20 diff --git a/src/storage/storage_backend_scsi.c b/src/storage/storage_backe= nd_scsi.c index abbd38d..666e473 100644 --- a/src/storage/storage_backend_scsi.c +++ b/src/storage/storage_backend_scsi.c @@ -33,9 +33,7 @@ #include "virlog.h" #include "virfile.h" #include "vircommand.h" -#include "virscsihost.h" #include "virstring.h" -#include "virvhba.h" #include "storage_util.h" #include "node_device_conf.h" =20 @@ -214,57 +212,13 @@ getAdapterName(virStorageAdapterPtr adapter) return name; } =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, const char *configFile, virStorageAdapterFCHostPtr fchost) { - unsigned int parent_host; char *name =3D NULL; - char *parent_hoststr =3D NULL; - bool skip_capable_check =3D false; virStoragePoolFCRefreshInfoPtr cbdata =3D NULL; virThread thread; int ret =3D -1; @@ -273,66 +227,11 @@ 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 (fchost->parent && checkParent(conn, name, fchost->parent)) - ret =3D 0; =20 + if (!(name =3D virNodeDeviceCreateVport(conn, fchost))) goto cleanup; - } =20 - if (fchost->parent) { - if (VIR_STRDUP(parent_hoststr, fchost->parent) < 0) - goto cleanup; - } else if (fchost->parent_wwnn && fchost->parent_wwpn) { - if (!(parent_hoststr =3D virVHBAGetHostByWWN(NULL, fchost->parent_= wwnn, - fchost->parent_wwpn))) { - virReportError(VIR_ERR_XML_ERROR, "%s", - _("cannot find parent using provided wwnn/wwpn"= )); - goto cleanup; - } - } else if (fchost->parent_fabric_wwn) { - if (!(parent_hoststr =3D - virVHBAGetHostByFabricWWN(NULL, fchost->parent_fabric_wwn)))= { - virReportError(VIR_ERR_XML_ERROR, "%s", - _("cannot find parent using provided fabric_wwn= ")); - goto cleanup; - } - } else { - if (!(parent_hoststr =3D virVHBAFindVportHost(NULL))) { - virReportError(VIR_ERR_XML_ERROR, "%s", - _("'parent' for vHBA not specified, and " - "cannot find one on this host")); - goto cleanup; - } - skip_capable_check =3D true; - } - - if (virSCSIHostGetNumber(parent_hoststr, &parent_host) < 0) - goto cleanup; - - /* NOTE: - * We do not save the parent_hoststr in fchost->parent since - * we could be writing out the 'def' to the saved XML config. - * If we wrote out the name in the XML, then future starts would - * always use the same parent rather than finding the "best available" - * parent. Besides we have a way to determine the parent based on - * the 'name' field. - */ - if (!skip_capable_check && !virVHBAPathExists(NULL, parent_host)) { - virReportError(VIR_ERR_XML_ERROR, - _("parent '%s' specified for vHBA does not exist"), - parent_hoststr); - goto cleanup; - } - - /* Since we're creating the vHBA, then we need to manage removing it + /* Since we've created the vHBA, then we 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. @@ -345,28 +244,20 @@ createVport(virConnectPtr conn, } } =20 - if (virVHBAManageVport(parent_host, fchost->wwpn, fchost->wwnn, - VPORT_CREATE) < 0) - goto cleanup; - - virWaitForDevices(); - /* Creating our own VPORT didn't leave enough time to find any LUN's, * so, let's create a thread whose job it is to call the FindLU's with * retry logic set to true. If the thread isn't created, then no big * deal since it's still possible to refresh the pool later. */ - if ((name =3D virVHBAGetHostByWWN(NULL, fchost->wwnn, fchost->wwpn))) { - if (VIR_ALLOC(cbdata) =3D=3D 0) { - memcpy(cbdata->pool_uuid, def->uuid, VIR_UUID_BUFLEN); - VIR_STEAL_PTR(cbdata->fchost_name, name); - - if (virThreadCreate(&thread, false, virStoragePoolFCRefreshThr= ead, - cbdata) < 0) { - /* Oh well - at least someone can still refresh afterwards= */ - VIR_DEBUG("Failed to create FC Pool Refresh Thread"); - virStoragePoolFCRefreshDataFree(cbdata); - } + if (VIR_ALLOC(cbdata) =3D=3D 0) { + memcpy(cbdata->pool_uuid, def->uuid, VIR_UUID_BUFLEN); + VIR_STEAL_PTR(cbdata->fchost_name, name); + + if (virThreadCreate(&thread, false, virStoragePoolFCRefreshThread, + cbdata) < 0) { + /* Oh well - at least someone can still refresh afterwards */ + VIR_DEBUG("Failed to create FC Pool Refresh Thread"); + virStoragePoolFCRefreshDataFree(cbdata); } } =20 @@ -374,64 +265,6 @@ createVport(virConnectPtr conn, =20 cleanup: VIR_FREE(name); - VIR_FREE(parent_hoststr); - return ret; -} - - -static int -deleteVport(virConnectPtr conn, - virStorageAdapterFCHostPtr fchost) -{ - unsigned int parent_host; - char *name =3D NULL; - char *scsi_host_name =3D NULL; - char *vhba_parent =3D NULL; - int ret =3D -1; - - VIR_DEBUG("conn=3D%p parent=3D'%s', managed=3D'%d' wwnn=3D'%s' wwpn=3D= '%s'", - conn, NULLSTR(fchost->parent), fchost->managed, - fchost->wwnn, fchost->wwpn); - - /* If we're not managing the deletion of the vHBA, then just return */ - if (fchost->managed !=3D VIR_TRISTATE_BOOL_YES) - return 0; - - /* Find our vHBA by searching the fc_host sysfs tree for our wwnn/wwpn= */ - if (!(name =3D virVHBAGetHostByWWN(NULL, fchost->wwnn, fchost->wwpn)))= { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("Failed to find fc_host for wwnn=3D'%s' and wwpn= =3D'%s'"), - fchost->wwnn, fchost->wwpn); - goto cleanup; - } - - /* If at startup time we provided a parent, then use that to - * get the parent_host value; otherwise, we have to determine - * the parent scsi_host which we did not save at startup time - */ - if (fchost->parent) { - if (virSCSIHostGetNumber(fchost->parent, &parent_host) < 0) - goto cleanup; - } else { - if (virAsprintf(&scsi_host_name, "scsi_%s", name) < 0) - goto cleanup; - - if (!(vhba_parent =3D virNodeDeviceGetParentName(conn, scsi_host_n= ame))) - goto cleanup; - - if (virSCSIHostGetNumber(vhba_parent, &parent_host) < 0) - goto cleanup; - } - - if (virVHBAManageVport(parent_host, fchost->wwpn, fchost->wwnn, - VPORT_DELETE) < 0) - goto cleanup; - - ret =3D 0; - cleanup: - VIR_FREE(name); - VIR_FREE(vhba_parent); - VIR_FREE(scsi_host_name); return ret; } =20 @@ -525,7 +358,8 @@ virStorageBackendSCSIStopPool(virConnectPtr conn, virStoragePoolObjPtr pool) { if (pool->def->source.adapter.type =3D=3D VIR_STORAGE_ADAPTER_TYPE_FC_= HOST) - return deleteVport(conn, &pool->def->source.adapter.data.fchost); + return virNodeDeviceDeleteVport(conn, + &pool->def->source.adapter.data.fc= host); =20 return 0; } --=20 2.9.3 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Fri May 3 01:20:00 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.37 as permitted sender) client-ip=209.132.183.37; envelope-from=libvir-list-bounces@redhat.com; helo=mx5-phx2.redhat.com; Authentication-Results: mx.zoho.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.37 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; Return-Path: Received: from mx5-phx2.redhat.com (mx5-phx2.redhat.com [209.132.183.37]) by mx.zohomail.com with SMTPS id 1489180500160476.98080930099127; Fri, 10 Mar 2017 13:15:00 -0800 (PST) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by mx5-phx2.redhat.com (8.14.4/8.14.4) with ESMTP id v2ALBYiq045100; Fri, 10 Mar 2017 16:11:34 -0500 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id v2ALB2aj024018 for ; Fri, 10 Mar 2017 16:11:02 -0500 Received: from localhost.localdomain.com (ovpn-117-9.phx2.redhat.com [10.3.117.9]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id v2ALArRx011410 for ; Fri, 10 Mar 2017 16:11:01 -0500 From: John Ferlan To: libvir-list@redhat.com Date: Fri, 10 Mar 2017 16:10:49 -0500 Message-Id: <20170310211050.27784-18-jferlan@redhat.com> In-Reply-To: <20170310211050.27784-1-jferlan@redhat.com> References: <20170310211050.27784-1-jferlan@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.24 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH v3 17/18] util: Alter virNodeDevice{Create|Delete}Vport to use nodedev APIs 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-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" If we have a connection pointer there's no sense walking through the sysfs in order to create/destroy the vHBA. Instead, let's make use of the node device create/destroy API's. Since we don't have to rewrite all the various parent options for the test driver in order to test whether the storage pool creation works as the node device creation has been tested already, let's just use the altered API to test the storage pool paths. Fix a "bug" in the storage pool test driver code which "assumed" testStoragePoolObjSetDefaults should fill in the configFile for both the Define/Create (persistent) and CreateXML (transient) pools by just VIR_FREE() of the pool during CreateXML. Because the configFile was filled in, during Destroy, the pool wouldn't be free causing a test using the same name pool to fail. Signed-off-by: John Ferlan --- src/conf/node_device_conf.c | 121 ++++++++++++++++++++++++++++++++++++++++= ++++ src/test/test_driver.c | 6 +++ tests/fchosttest.c | 15 ++++++ 3 files changed, 142 insertions(+) diff --git a/src/conf/node_device_conf.c b/src/conf/node_device_conf.c index 66cb78d..0c25f58 100644 --- a/src/conf/node_device_conf.c +++ b/src/conf/node_device_conf.c @@ -1916,6 +1916,82 @@ nodeDeviceCheckParent(virConnectPtr conn, =20 /** * @conn: Connection pointer + * @fchost: Pointer to the vHBA adapter + * + * If we have a valid connection, then use the node device create + * XML API rather than traversing through the sysfs to create the vHBA. + * Generate the Node Device XML using the Storage vHBA Adapter providing + * either the parent name, parent wwnn/wwpn, or parent fabric_name if + * available to the Node Device code. Since the Storage XML processing + * requires the wwnn/wwpn to be used for the vHBA to be provided (and + * not generated), we can use that as the fc_host wwnn/wwpn. This will + * allow for easier search later when we need it. + * + * Returns vHBA name on success, NULL on failure with an error message set + */ +static char * +nodeDeviceCreateNodeDeviceVport(virConnectPtr conn, + virStorageAdapterFCHostPtr fchost) +{ + virBuffer buf =3D VIR_BUFFER_INITIALIZER; + char *vhbaStr =3D NULL; + virNodeDevicePtr dev =3D NULL; + char *name; + bool created =3D false; + + /* If the nodedev already knows about this vHBA, then we're not + * managing it - we'll just use it. */ + if ((dev =3D virNodeDeviceLookupSCSIHostByWWN(conn, fchost->wwnn, + fchost->wwpn, 0))) + goto skip_create; + + virBufferAddLit(&buf, "\n"); + virBufferAdjustIndent(&buf, 2); + if (fchost->parent) + virBufferEscapeString(&buf, "%s\n", + fchost->parent); + else if (fchost->parent_wwnn && fchost->parent_wwpn) + virBufferAsprintf(&buf, "\n", + fchost->parent_wwnn, fchost->parent_wwpn); + else if (fchost->parent_fabric_wwn) + virBufferAsprintf(&buf, "\n", + fchost->parent_fabric_wwn); + virBufferAddLit(&buf, "\n"); + virBufferAdjustIndent(&buf, 2); + virBufferAsprintf(&buf, "\n", + fchost->wwnn, fchost->wwpn); + virBufferAddLit(&buf, "\n"); + virBufferAdjustIndent(&buf, -2); + virBufferAddLit(&buf, "\n"); + virBufferAdjustIndent(&buf, -2); + virBufferAddLit(&buf, "\n"); + + if (!(vhbaStr =3D virBufferContentAndReset(&buf))) { + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("unable to create node device XML")); + goto cleanup; + } + + if (!(dev =3D virNodeDeviceCreateXML(conn, vhbaStr, 0))) + goto cleanup; + created =3D true; + + skip_create: + if (VIR_STRDUP(name, virNodeDeviceGetName(dev)) < 0) { + /* If we created, then destroy it */ + if (created) + ignore_value(virNodeDeviceDestroy(dev)); + } + + cleanup: + VIR_FREE(vhbaStr); + virObjectUnref(dev); + return name; +} + + +/** + * @conn: Connection pointer * @fchost: Pointer to vHBA adapter * * Create a vHBA for Storage. This code accomplishes this via searching @@ -1939,6 +2015,11 @@ 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 have a connection, bypass sysfs searching and use the + * NodeDevice API's in order to perform our delete */ + if (conn) + return nodeDeviceCreateNodeDeviceVport(conn, fchost); + /* 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 @@ -2019,6 +2100,41 @@ virNodeDeviceCreateVport(virConnectPtr conn, * @conn: Connection pointer * @fchost: Pointer to vHBA adapter * + * Search for the vHBA SCSI_HOST by the wwnn/wwpn provided at creation + * and use the node device driver to destroy. + * + * Returns 0 on success, -1 on failure w/ error message. + */ +static int +nodeDeviceDeleteNodeDeviceVport(virConnectPtr conn, + virStorageAdapterFCHostPtr fchost) +{ + int ret =3D -1; + virNodeDevicePtr dev; + + if (!(dev =3D virNodeDeviceLookupSCSIHostByWWN(conn, fchost->wwnn, + fchost->wwpn, 0))) { + virReportError(VIR_ERR_INTERNAL_ERROR, + _("Failed to find fc_host for wwnn=3D'%s' and wwpn= =3D'%s'"), + fchost->wwnn, fchost->wwpn); + return -1; + } + + if (virNodeDeviceDestroy(dev) < 0) + goto cleanup; + + ret =3D 0; + + cleanup: + virObjectUnref(dev); + return ret; +} + + +/** + * @conn: Connection pointer + * @fchost: Pointer to vHBA adapter + * * As long as the vHBA is being managed, search for the scsi_host via the * provided wwnn/wwpn and then find the corresponding parent scsi_host in * order to send the delete request. @@ -2043,6 +2159,11 @@ virNodeDeviceDeleteVport(virConnectPtr conn, if (fchost->managed !=3D VIR_TRISTATE_BOOL_YES) return 0; =20 + /* If we have a connection, bypass sysfs searching and use the + * NodeDevice API's in order to perform our delete */ + if (conn) + return nodeDeviceDeleteNodeDeviceVport(conn, fchost); + /* Find our vHBA by searching the fc_host sysfs tree for our wwnn/wwpn= */ if (!(name =3D virVHBAGetHostByWWN(NULL, fchost->wwnn, fchost->wwpn)))= { virReportError(VIR_ERR_INTERNAL_ERROR, diff --git a/src/test/test_driver.c b/src/test/test_driver.c index 18792bc..1023956 100644 --- a/src/test/test_driver.c +++ b/src/test/test_driver.c @@ -4439,6 +4439,12 @@ testStoragePoolCreateXML(virConnectPtr conn, pool =3D NULL; goto cleanup; } + + /* *SetDefaults fills this in for the persistent pools, but this + * would be a transient pool so remove it; otherwise, the Destroy + * code will not Remove the pool */ + VIR_FREE(pool->configFile); + pool->active =3D 1; =20 event =3D virStoragePoolEventLifecycleNew(pool->def->name, pool->def->= uuid, diff --git a/tests/fchosttest.c b/tests/fchosttest.c index dc6b9af..c024ae5 100644 --- a/tests/fchosttest.c +++ b/tests/fchosttest.c @@ -87,6 +87,18 @@ static const char test11_xml[] =3D " " ""; =20 +/* virStoragePoolCreateXML without any parent to find the vport capable HB= A */ +static const char test12_xml[] =3D +"" +" vhba_pool" +" " +" " +" " +" " +" /dev/disk/by-path" +" " +""; + =20 /* Test virIsVHBACapable */ static int @@ -374,6 +386,9 @@ mymain(void) if (virTestRun("manageVHBAByStoragePool-by-parent", manageVHBAByStorag= ePool, test11_xml) < 0) ret =3D -1; + if (virTestRun("manageVHBAByStoragePool-no-parent", manageVHBAByStorag= ePool, + test12_xml) < 0) + ret =3D -1; =20 cleanup: VIR_FREE(fchost_prefix); --=20 2.9.3 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Fri May 3 01:20:00 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.39 as permitted sender) client-ip=209.132.183.39; envelope-from=libvir-list-bounces@redhat.com; helo=mx6-phx2.redhat.com; Authentication-Results: mx.zoho.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.39 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; Return-Path: Received: from mx6-phx2.redhat.com (mx6-phx2.redhat.com [209.132.183.39]) by mx.zohomail.com with SMTPS id 1489180481017571.2976749384989; Fri, 10 Mar 2017 13:14:41 -0800 (PST) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by mx6-phx2.redhat.com (8.14.4/8.14.4) with ESMTP id v2ALBaYV051980; Fri, 10 Mar 2017 16:11:36 -0500 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id v2ALB2QY024026 for ; Fri, 10 Mar 2017 16:11:02 -0500 Received: from localhost.localdomain.com (ovpn-117-9.phx2.redhat.com [10.3.117.9]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id v2ALArS0011410 for ; Fri, 10 Mar 2017 16:11:02 -0500 From: John Ferlan To: libvir-list@redhat.com Date: Fri, 10 Mar 2017 16:10:50 -0500 Message-Id: <20170310211050.27784-19-jferlan@redhat.com> In-Reply-To: <20170310211050.27784-1-jferlan@redhat.com> References: <20170310211050.27784-1-jferlan@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.24 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH v3 18/18] tests: Add more storage pool vHBA tests 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-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Add the parent wwnn/wwpn and fabric_wwn tests for the storage pool now that we have the capability to use the node device driver to handle the searches via a connection. Signed-off-by: John Ferlan --- tests/fchosttest.c | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/tests/fchosttest.c b/tests/fchosttest.c index c024ae5..c080c9b 100644 --- a/tests/fchosttest.c +++ b/tests/fchosttest.c @@ -100,6 +100,30 @@ static const char test12_xml[] =3D ""; =20 =20 +/* virStoragePoolCreateXML parent wwnn/wwpn to find the vport capable HBA = */ +static const char test13_xml[] =3D +"" +" vhba_pool" +" " +" " +" " +" " +" /dev/disk/by-path" +" " +""; + +/* virStoragePoolCreateXML parent fabric_wwn to find the vport capable HBA= */ +static const char test14_xml[] =3D +"" +" vhba_pool" +" " +" " +" " +" " +" /dev/disk/by-path" +" " +""; + /* Test virIsVHBACapable */ static int test1(const void *data ATTRIBUTE_UNUSED) @@ -389,6 +413,14 @@ mymain(void) if (virTestRun("manageVHBAByStoragePool-no-parent", manageVHBAByStorag= ePool, test12_xml) < 0) ret =3D -1; + if (virTestRun("manageVHBAByStoragePool-parent-wwn", + manageVHBAByStoragePool, + test13_xml) < 0) + ret =3D -1; + if (virTestRun("manageVHBAByStoragePool-parent-fabric-wwn", + manageVHBAByStoragePool, + test14_xml) < 0) + ret =3D -1; =20 cleanup: VIR_FREE(fchost_prefix); --=20 2.9.3 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list