From nobody Mon Feb 9 09:10:11 2026 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 1488414705602317.34755151321303; Wed, 1 Mar 2017 16:31:45 -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 v220SEke062273; Wed, 1 Mar 2017 19:28:14 -0500 Received: from smtp.corp.redhat.com (int-mx16.intmail.prod.int.phx2.redhat.com [10.5.11.28]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id v220RK76010008 for ; Wed, 1 Mar 2017 19:27:20 -0500 Received: by smtp.corp.redhat.com (Postfix) id 6D2BB72380; Thu, 2 Mar 2017 00:27:20 +0000 (UTC) Received: from localhost.localdomain.com (ovpn-116-78.phx2.redhat.com [10.3.116.78]) by smtp.corp.redhat.com (Postfix) with ESMTP id 176A72D655 for ; Thu, 2 Mar 2017 00:27:20 +0000 (UTC) From: John Ferlan To: libvir-list@redhat.com Date: Wed, 1 Mar 2017 19:27:15 -0500 Message-Id: <20170302002716.21337-3-jferlan@redhat.com> In-Reply-To: <20170302002716.21337-1-jferlan@redhat.com> References: <20170302002716.21337-1-jferlan@redhat.com> X-Scanned-By: MIMEDefang 2.74 on 10.5.11.28 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 2/3] conf: Clean up nodedev code 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" Alter the static functions from virNodeDev* to just nodeDev* as a visual cue to determine which are local or not when reading code. Cleanup spacing between functions, function defs, etc. to match more modern techniques used in libvirt Signed-off-by: John Ferlan --- src/conf/node_device_conf.c | 476 +++++++++++++++++++++++-----------------= ---- src/conf/virnodedeviceobj.c | 128 ++++++------ 2 files changed, 322 insertions(+), 282 deletions(-) diff --git a/src/conf/node_device_conf.c b/src/conf/node_device_conf.c index bc36527..09e815a 100644 --- a/src/conf/node_device_conf.c +++ b/src/conf/node_device_conf.c @@ -72,9 +72,9 @@ VIR_ENUM_IMPL(virNodeDevDRM, VIR_NODE_DEV_DRM_LAST, "render") =20 static int -virNodeDevCapsDefParseString(const char *xpath, - xmlXPathContextPtr ctxt, - char **string) +nodeDevCapsDefParseString(const char *xpath, + xmlXPathContextPtr ctxt, + char **string) { char *s; =20 @@ -86,7 +86,8 @@ virNodeDevCapsDefParseString(const char *xpath, } =20 =20 -void virNodeDeviceDefFree(virNodeDeviceDefPtr def) +void +virNodeDeviceDefFree(virNodeDeviceDefPtr def) { virNodeDevCapsDefPtr caps; =20 @@ -116,9 +117,9 @@ void virNodeDeviceDefFree(virNodeDeviceDefPtr def) =20 =20 static void -virPCIELinkFormat(virBufferPtr buf, - virPCIELinkPtr lnk, - const char *attrib) +nodeDevPCIELinkFormat(virBufferPtr buf, + virPCIELinkPtr lnk, + const char *attrib) { if (!lnk) return; @@ -133,9 +134,10 @@ virPCIELinkFormat(virBufferPtr buf, virBufferAddLit(buf, "/>\n"); } =20 + static void -virPCIEDeviceInfoFormat(virBufferPtr buf, - virPCIEDeviceInfoPtr info) +nodeDevPCIEDeviceInfoFormat(virBufferPtr buf, + virPCIEDeviceInfoPtr info) { if (!info->link_cap && !info->link_sta) { virBufferAddLit(buf, "\n"); @@ -145,14 +147,16 @@ virPCIEDeviceInfoFormat(virBufferPtr buf, virBufferAddLit(buf, "\n"); virBufferAdjustIndent(buf, 2); =20 - virPCIELinkFormat(buf, info->link_cap, "cap"); - virPCIELinkFormat(buf, info->link_sta, "sta"); + nodeDevPCIELinkFormat(buf, info->link_cap, "cap"); + nodeDevPCIELinkFormat(buf, info->link_sta, "sta"); =20 virBufferAdjustIndent(buf, -2); virBufferAddLit(buf, "\n"); } =20 -char *virNodeDeviceDefFormat(const virNodeDeviceDef *def) + +char * +virNodeDeviceDefFormat(const virNodeDeviceDef *def) { virBuffer buf =3D VIR_BUFFER_INITIALIZER; virNodeDevCapsDefPtr caps; @@ -305,7 +309,7 @@ char *virNodeDeviceDefFormat(const virNodeDeviceDef *de= f) data->pci_dev.numa_node); =20 if (data->pci_dev.flags & VIR_NODE_DEV_CAP_FLAG_PCIE) - virPCIEDeviceInfoFormat(&buf, data->pci_dev.pci_express); + nodeDevPCIEDeviceInfoFormat(&buf, data->pci_dev.pci_expres= s); break; case VIR_NODE_DEV_CAP_USB_DEV: virBufferAsprintf(&buf, "%d\n", data->usb_dev.bus); @@ -489,8 +493,9 @@ char *virNodeDeviceDefFormat(const virNodeDeviceDef *de= f) return virBufferContentAndReset(&buf); } =20 + /** - * virNodeDevCapsDefParseIntOptional: + * nodeDevCapsDefParseIntOptional: * @xpath: XPath to evaluate * @ctxt: Context * @value: Where to store parsed value @@ -502,11 +507,11 @@ char *virNodeDeviceDefFormat(const virNodeDeviceDef *= def) * 1 on success */ static int -virNodeDevCapsDefParseIntOptional(const char *xpath, - xmlXPathContextPtr ctxt, - int *value, - virNodeDeviceDefPtr def, - const char *invalid_error_fmt) +nodeDevCapsDefParseIntOptional(const char *xpath, + xmlXPathContextPtr ctxt, + int *value, + virNodeDeviceDefPtr def, + const char *invalid_error_fmt) { int ret; int val; @@ -524,13 +529,14 @@ virNodeDevCapsDefParseIntOptional(const char *xpath, return 1; } =20 + static int -virNodeDevCapsDefParseULong(const char *xpath, - xmlXPathContextPtr ctxt, - unsigned *value, - virNodeDeviceDefPtr def, - const char *missing_error_fmt, - const char *invalid_error_fmt) +nodeDevCapsDefParseULong(const char *xpath, + xmlXPathContextPtr ctxt, + unsigned *value, + virNodeDeviceDefPtr def, + const char *missing_error_fmt, + const char *invalid_error_fmt) { int ret; unsigned long val; @@ -547,13 +553,14 @@ virNodeDevCapsDefParseULong(const char *xpath, return 0; } =20 + static int -virNodeDevCapsDefParseULongLong(const char *xpath, - xmlXPathContextPtr ctxt, - unsigned long long *value, - virNodeDeviceDefPtr def, - const char *missing_error_fmt, - const char *invalid_error_fmt) +nodeDevCapsDefParseULongLong(const char *xpath, + xmlXPathContextPtr ctxt, + unsigned long long *value, + virNodeDeviceDefPtr def, + const char *missing_error_fmt, + const char *invalid_error_fmt) { int ret; unsigned long long val; @@ -570,11 +577,12 @@ virNodeDevCapsDefParseULongLong(const char *xpath, return 0; } =20 + static int -virNodeDevCapDRMParseXML(xmlXPathContextPtr ctxt, - virNodeDeviceDefPtr def, - xmlNodePtr node, - virNodeDevCapDataPtr data) +nodeDevCapDRMParseXML(xmlXPathContextPtr ctxt, + virNodeDeviceDefPtr def, + xmlNodePtr node, + virNodeDevCapDataPtr data) { xmlNodePtr orignode; int ret =3D -1, val; @@ -600,11 +608,12 @@ virNodeDevCapDRMParseXML(xmlXPathContextPtr ctxt, return ret; } =20 + static int -virNodeDevCapStorageParseXML(xmlXPathContextPtr ctxt, - virNodeDeviceDefPtr def, - xmlNodePtr node, - virNodeDevCapDataPtr data) +nodeDevCapStorageParseXML(xmlXPathContextPtr ctxt, + virNodeDeviceDefPtr def, + xmlNodePtr node, + virNodeDevCapDataPtr data) { xmlNodePtr orignode, *nodes =3D NULL; size_t i; @@ -657,9 +666,9 @@ virNodeDevCapStorageParseXML(xmlXPathContextPtr ctxt, data->storage.media_label =3D virXPathString("string(./media_l= abel[1])", ctxt); =20 val =3D 0; - if (virNodeDevCapsDefParseULongLong("number(./media_size[1])",= ctxt, &val, def, - _("no removable media size= supplied for '%s'"), - _("invalid removable media= size supplied for '%s'")) < 0) { + if (nodeDevCapsDefParseULongLong("number(./media_size[1])", ct= xt, &val, def, + _("no removable media size su= pplied for '%s'"), + _("invalid removable media si= ze supplied for '%s'")) < 0) { ctxt->node =3D orignode2; VIR_FREE(type); goto out; @@ -680,9 +689,9 @@ virNodeDevCapStorageParseXML(xmlXPathContextPtr ctxt, =20 if (!(data->storage.flags & VIR_NODE_DEV_CAP_STORAGE_REMOVABLE)) { val =3D 0; - if (virNodeDevCapsDefParseULongLong("number(./size[1])", ctxt, &va= l, def, - _("no size supplied for '%s'"), - _("invalid size supplied for '= %s'")) < 0) + if (nodeDevCapsDefParseULongLong("number(./size[1])", ctxt, &val, = def, + _("no size supplied for '%s'"), + _("invalid size supplied for '%s'= ")) < 0) goto out; data->storage.size =3D val; } @@ -694,11 +703,12 @@ virNodeDevCapStorageParseXML(xmlXPathContextPtr ctxt, return ret; } =20 + static int -virNodeDevCapSCSIParseXML(xmlXPathContextPtr ctxt, - virNodeDeviceDefPtr def, - xmlNodePtr node, - virNodeDevCapDataPtr data) +nodeDevCapSCSIParseXML(xmlXPathContextPtr ctxt, + virNodeDeviceDefPtr def, + xmlNodePtr node, + virNodeDevCapDataPtr data) { xmlNodePtr orignode; int ret =3D -1; @@ -706,28 +716,28 @@ virNodeDevCapSCSIParseXML(xmlXPathContextPtr ctxt, orignode =3D ctxt->node; ctxt->node =3D node; =20 - if (virNodeDevCapsDefParseULong("number(./host[1])", ctxt, - &data->scsi.host, def, - _("no SCSI host ID supplied for '%s'"), - _("invalid SCSI host ID supplied for '= %s'")) < 0) + if (nodeDevCapsDefParseULong("number(./host[1])", ctxt, + &data->scsi.host, def, + _("no SCSI host ID supplied for '%s'"), + _("invalid SCSI host ID supplied for '%s'= ")) < 0) goto out; =20 - if (virNodeDevCapsDefParseULong("number(./bus[1])", ctxt, - &data->scsi.bus, def, - _("no SCSI bus ID supplied for '%s'"), - _("invalid SCSI bus ID supplied for '%= s'")) < 0) + if (nodeDevCapsDefParseULong("number(./bus[1])", ctxt, + &data->scsi.bus, def, + _("no SCSI bus ID supplied for '%s'"), + _("invalid SCSI bus ID supplied for '%s'"= )) < 0) goto out; =20 - if (virNodeDevCapsDefParseULong("number(./target[1])", ctxt, - &data->scsi.target, def, - _("no SCSI target ID supplied for '%s'= "), + if (nodeDevCapsDefParseULong("number(./target[1])", ctxt, + &data->scsi.target, def, + _("no SCSI target ID supplied for '%s'"), _("invalid SCSI target ID supplied for= '%s'")) < 0) goto out; =20 - if (virNodeDevCapsDefParseULong("number(./lun[1])", ctxt, - &data->scsi.lun, def, - _("no SCSI LUN ID supplied for '%s'"), - _("invalid SCSI LUN ID supplied for '%= s'")) < 0) + if (nodeDevCapsDefParseULong("number(./lun[1])", ctxt, + &data->scsi.lun, def, + _("no SCSI LUN ID supplied for '%s'"), + _("invalid SCSI LUN ID supplied for '%s'"= )) < 0) goto out; =20 data->scsi.type =3D virXPathString("string(./type[1])", ctxt); @@ -740,10 +750,10 @@ virNodeDevCapSCSIParseXML(xmlXPathContextPtr ctxt, =20 =20 static int -virNodeDevCapSCSITargetParseXML(xmlXPathContextPtr ctxt, - virNodeDeviceDefPtr def, - xmlNodePtr node, - virNodeDevCapDataPtr data) +nodeDevCapSCSITargetParseXML(xmlXPathContextPtr ctxt, + virNodeDeviceDefPtr def, + xmlNodePtr node, + virNodeDevCapDataPtr data) { xmlNodePtr orignode; int ret =3D -1; @@ -768,12 +778,12 @@ virNodeDevCapSCSITargetParseXML(xmlXPathContextPtr ct= xt, =20 =20 static int -virNodeDevCapSCSIHostParseXML(xmlXPathContextPtr ctxt, - virNodeDeviceDefPtr def, - xmlNodePtr node, - virNodeDevCapDataPtr data, - int create, - const char *virt_type) +nodeDevCapSCSIHostParseXML(xmlXPathContextPtr ctxt, + virNodeDeviceDefPtr def, + xmlNodePtr node, + virNodeDevCapDataPtr data, + int create, + const char *virt_type) { xmlNodePtr orignode, *nodes =3D NULL; int ret =3D -1, n =3D 0; @@ -784,17 +794,17 @@ virNodeDevCapSCSIHostParseXML(xmlXPathContextPtr ctxt, ctxt->node =3D node; =20 if (create =3D=3D EXISTING_DEVICE) { - if (virNodeDevCapsDefParseULong("number(./host[1])", ctxt, - &data->scsi_host.host, def, - _("no SCSI host ID supplied for '%= s'"), - _("invalid SCSI host ID supplied f= or '%s'")) < 0) { + if (nodeDevCapsDefParseULong("number(./host[1])", ctxt, + &data->scsi_host.host, def, + _("no SCSI host ID supplied for '%s'"= ), + _("invalid SCSI host ID supplied for = '%s'")) < 0) { goto out; } /* Optional unique_id value */ data->scsi_host.unique_id =3D -1; - if (virNodeDevCapsDefParseIntOptional("number(./unique_id[1])", ct= xt, - &data->scsi_host.unique_id, = def, - _("invalid unique_id supplie= d for '%s'")) < 0) { + if (nodeDevCapsDefParseIntOptional("number(./unique_id[1])", ctxt, + &data->scsi_host.unique_id, def, + _("invalid unique_id supplied f= or '%s'")) < 0) { goto out; } } @@ -825,9 +835,9 @@ virNodeDevCapSCSIHostParseXML(xmlXPathContextPtr ctxt, orignode2 =3D ctxt->node; ctxt->node =3D nodes[i]; =20 - if (virNodeDevCapsDefParseString("string(./wwnn[1])", - ctxt, - &data->scsi_host.wwnn) < 0) { + if (nodeDevCapsDefParseString("string(./wwnn[1])", + ctxt, + &data->scsi_host.wwnn) < 0) { if (virRandomGenerateWWN(&data->scsi_host.wwnn, virt_type)= < 0) { virReportError(VIR_ERR_INTERNAL_ERROR, _("no WWNN supplied for '%s', and " @@ -837,9 +847,9 @@ virNodeDevCapSCSIHostParseXML(xmlXPathContextPtr ctxt, } } =20 - if (virNodeDevCapsDefParseString("string(./wwpn[1])", - ctxt, - &data->scsi_host.wwpn) < 0) { + if (nodeDevCapsDefParseString("string(./wwpn[1])", + ctxt, + &data->scsi_host.wwpn) < 0) { if (virRandomGenerateWWN(&data->scsi_host.wwpn, virt_type)= < 0) { virReportError(VIR_ERR_INTERNAL_ERROR, _("no WWPN supplied for '%s', and " @@ -849,9 +859,9 @@ virNodeDevCapSCSIHostParseXML(xmlXPathContextPtr ctxt, } } =20 - if (virNodeDevCapsDefParseString("string(./fabric_wwn[1])", - ctxt, - &data->scsi_host.fabric_wwn) = < 0) + if (nodeDevCapsDefParseString("string(./fabric_wwn[1])", + ctxt, + &data->scsi_host.fabric_wwn) < 0) VIR_DEBUG("No fabric_wwn defined for '%s'", def->name); =20 ctxt->node =3D orignode2; @@ -877,10 +887,10 @@ virNodeDevCapSCSIHostParseXML(xmlXPathContextPtr ctxt, =20 =20 static int -virNodeDevCapNetParseXML(xmlXPathContextPtr ctxt, - virNodeDeviceDefPtr def, - xmlNodePtr node, - virNodeDevCapDataPtr data) +nodeDevCapNetParseXML(xmlXPathContextPtr ctxt, + virNodeDeviceDefPtr def, + xmlNodePtr node, + virNodeDevCapDataPtr data) { xmlNodePtr orignode, lnk; size_t i =3D -1; @@ -954,11 +964,12 @@ virNodeDevCapNetParseXML(xmlXPathContextPtr ctxt, return ret; } =20 + static int -virNodeDevCapUSBInterfaceParseXML(xmlXPathContextPtr ctxt, - virNodeDeviceDefPtr def, - xmlNodePtr node, - virNodeDevCapDataPtr data) +nodeDevCapUSBInterfaceParseXML(xmlXPathContextPtr ctxt, + virNodeDeviceDefPtr def, + xmlNodePtr node, + virNodeDevCapDataPtr data) { xmlNodePtr orignode; int ret =3D -1; @@ -966,27 +977,27 @@ virNodeDevCapUSBInterfaceParseXML(xmlXPathContextPtr = ctxt, orignode =3D ctxt->node; ctxt->node =3D node; =20 - if (virNodeDevCapsDefParseULong("number(./number[1])", ctxt, - &data->usb_if.number, def, - _("no USB interface number supplied fo= r '%s'"), - _("invalid USB interface number suppli= ed for '%s'")) < 0) + if (nodeDevCapsDefParseULong("number(./number[1])", ctxt, + &data->usb_if.number, def, + _("no USB interface number supplied for '= %s'"), + _("invalid USB interface number supplied = for '%s'")) < 0) goto out; =20 - if (virNodeDevCapsDefParseULong("number(./class[1])", ctxt, - &data->usb_if._class, def, - _("no USB interface class supplied for= '%s'"), - _("invalid USB interface class supplie= d for '%s'")) < 0) + if (nodeDevCapsDefParseULong("number(./class[1])", ctxt, + &data->usb_if._class, def, + _("no USB interface class supplied for '%= s'"), + _("invalid USB interface class supplied f= or '%s'")) < 0) goto out; =20 - if (virNodeDevCapsDefParseULong("number(./subclass[1])", ctxt, - &data->usb_if.subclass, def, - _("no USB interface subclass supplied = for '%s'"), - _("invalid USB interface subclass supp= lied for '%s'")) < 0) + if (nodeDevCapsDefParseULong("number(./subclass[1])", ctxt, + &data->usb_if.subclass, def, + _("no USB interface subclass supplied for= '%s'"), + _("invalid USB interface subclass supplie= d for '%s'")) < 0) goto out; =20 - if (virNodeDevCapsDefParseULong("number(./protocol[1])", ctxt, - &data->usb_if.protocol, def, - _("no USB interface protocol supplied = for '%s'"), + if (nodeDevCapsDefParseULong("number(./protocol[1])", ctxt, + &data->usb_if.protocol, def, + _("no USB interface protocol supplied for= '%s'"), _("invalid USB interface protocol supp= lied for '%s'")) < 0) goto out; =20 @@ -998,13 +1009,14 @@ virNodeDevCapUSBInterfaceParseXML(xmlXPathContextPtr= ctxt, return ret; } =20 + static int -virNodeDevCapsDefParseHexId(const char *xpath, - xmlXPathContextPtr ctxt, - unsigned *value, - virNodeDeviceDefPtr def, - const char *missing_error_fmt, - const char *invalid_error_fmt) +nodeDevCapsDefParseHexId(const char *xpath, + xmlXPathContextPtr ctxt, + unsigned *value, + virNodeDeviceDefPtr def, + const char *missing_error_fmt, + const char *invalid_error_fmt) { int ret; unsigned long val; @@ -1021,11 +1033,12 @@ virNodeDevCapsDefParseHexId(const char *xpath, return 0; } =20 + static int -virNodeDevCapUSBDevParseXML(xmlXPathContextPtr ctxt, - virNodeDeviceDefPtr def, - xmlNodePtr node, - virNodeDevCapDataPtr data) +nodeDevCapUSBDevParseXML(xmlXPathContextPtr ctxt, + virNodeDeviceDefPtr def, + xmlNodePtr node, + virNodeDevCapDataPtr data) { xmlNodePtr orignode; int ret =3D -1; @@ -1033,28 +1046,28 @@ virNodeDevCapUSBDevParseXML(xmlXPathContextPtr ctxt, orignode =3D ctxt->node; ctxt->node =3D node; =20 - if (virNodeDevCapsDefParseULong("number(./bus[1])", ctxt, - &data->usb_dev.bus, def, - _("no USB bus number supplied for '%s'= "), - _("invalid USB bus number supplied for= '%s'")) < 0) + if (nodeDevCapsDefParseULong("number(./bus[1])", ctxt, + &data->usb_dev.bus, def, + _("no USB bus number supplied for '%s'"), + _("invalid USB bus number supplied for '%= s'")) < 0) goto out; =20 - if (virNodeDevCapsDefParseULong("number(./device[1])", ctxt, - &data->usb_dev.device, def, - _("no USB device number supplied for '= %s'"), - _("invalid USB device number supplied = for '%s'")) < 0) + if (nodeDevCapsDefParseULong("number(./device[1])", ctxt, + &data->usb_dev.device, def, + _("no USB device number supplied for '%s'= "), + _("invalid USB device number supplied for= '%s'")) < 0) goto out; =20 - if (virNodeDevCapsDefParseHexId("string(./vendor[1]/@id)", ctxt, - &data->usb_dev.vendor, def, - _("no USB vendor ID supplied for '%s'"= ), - _("invalid USB vendor ID supplied for = '%s'")) < 0) + if (nodeDevCapsDefParseHexId("string(./vendor[1]/@id)", ctxt, + &data->usb_dev.vendor, def, + _("no USB vendor ID supplied for '%s'"), + _("invalid USB vendor ID supplied for '%s= '")) < 0) goto out; =20 - if (virNodeDevCapsDefParseHexId("string(./product[1]/@id)", ctxt, - &data->usb_dev.product, def, - _("no USB product ID supplied for '%s'= "), - _("invalid USB product ID supplied for= '%s'")) < 0) + if (nodeDevCapsDefParseHexId("string(./product[1]/@id)", ctxt, + &data->usb_dev.product, def, + _("no USB product ID supplied for '%s'"), + _("invalid USB product ID supplied for '%= s'")) < 0) goto out; =20 data->usb_dev.vendor_name =3D virXPathString("string(./vendor[1])", c= txt); @@ -1066,10 +1079,11 @@ virNodeDevCapUSBDevParseXML(xmlXPathContextPtr ctxt, return ret; } =20 + static int -virNodeDevCapPCIDevIommuGroupParseXML(xmlXPathContextPtr ctxt, - xmlNodePtr iommuGroupNode, - virNodeDevCapDataPtr data) +nodeDevCapPCIDevIommuGroupParseXML(xmlXPathContextPtr ctxt, + xmlNodePtr iommuGroupNode, + virNodeDevCapDataPtr data) { xmlNodePtr origNode =3D ctxt->node; xmlNodePtr *addrNodes =3D NULL; @@ -1122,10 +1136,11 @@ virNodeDevCapPCIDevIommuGroupParseXML(xmlXPathConte= xtPtr ctxt, return ret; } =20 + static int -virPCIEDeviceInfoLinkParseXML(xmlXPathContextPtr ctxt, - xmlNodePtr linkNode, - virPCIELinkPtr lnk) +nodeDevPCIEDeviceInfoLinkParseXML(xmlXPathContextPtr ctxt, + xmlNodePtr linkNode, + virPCIELinkPtr lnk) { xmlNodePtr origNode =3D ctxt->node; int ret =3D -1, speed; @@ -1168,10 +1183,11 @@ virPCIEDeviceInfoLinkParseXML(xmlXPathContextPtr ct= xt, return ret; } =20 + static int -virPCIEDeviceInfoParseXML(xmlXPathContextPtr ctxt, - xmlNodePtr pciExpressNode, - virPCIEDeviceInfoPtr pci_express) +nodeDevPCIEDeviceInfoParseXML(xmlXPathContextPtr ctxt, + xmlNodePtr pciExpressNode, + virPCIEDeviceInfoPtr pci_express) { xmlNodePtr lnk, origNode =3D ctxt->node; int ret =3D -1; @@ -1182,8 +1198,8 @@ virPCIEDeviceInfoParseXML(xmlXPathContextPtr ctxt, if (VIR_ALLOC(pci_express->link_cap) < 0) goto cleanup; =20 - if (virPCIEDeviceInfoLinkParseXML(ctxt, lnk, - pci_express->link_cap) < 0) + if (nodeDevPCIEDeviceInfoLinkParseXML(ctxt, lnk, + pci_express->link_cap) < 0) goto cleanup; } =20 @@ -1191,8 +1207,8 @@ virPCIEDeviceInfoParseXML(xmlXPathContextPtr ctxt, if (VIR_ALLOC(pci_express->link_sta) < 0) goto cleanup; =20 - if (virPCIEDeviceInfoLinkParseXML(ctxt, lnk, - pci_express->link_sta) < 0) + if (nodeDevPCIEDeviceInfoLinkParseXML(ctxt, lnk, + pci_express->link_sta) < 0) goto cleanup; } =20 @@ -1204,9 +1220,9 @@ virPCIEDeviceInfoParseXML(xmlXPathContextPtr ctxt, =20 =20 static int -virNodeDevPCICapabilityParseXML(xmlXPathContextPtr ctxt, - xmlNodePtr node, - virNodeDevCapDataPtr data) +nodeDevPCICapabilityParseXML(xmlXPathContextPtr ctxt, + xmlNodePtr node, + virNodeDevCapDataPtr data) { char *maxFuncsStr =3D virXMLPropString(node, "maxCount"); char *type =3D virXMLPropString(node, "type"); @@ -1292,10 +1308,10 @@ virNodeDevPCICapabilityParseXML(xmlXPathContextPtr = ctxt, =20 =20 static int -virNodeDevCapPCIDevParseXML(xmlXPathContextPtr ctxt, - virNodeDeviceDefPtr def, - xmlNodePtr node, - virNodeDevCapDataPtr data) +nodeDevCapPCIDevParseXML(xmlXPathContextPtr ctxt, + virNodeDeviceDefPtr def, + xmlNodePtr node, + virNodeDevCapDataPtr data) { xmlNodePtr orignode, iommuGroupNode, pciExpress; xmlNodePtr *nodes =3D NULL; @@ -1308,40 +1324,40 @@ virNodeDevCapPCIDevParseXML(xmlXPathContextPtr ctxt, orignode =3D ctxt->node; ctxt->node =3D node; =20 - if (virNodeDevCapsDefParseULong("number(./domain[1])", ctxt, - &data->pci_dev.domain, def, - _("no PCI domain ID supplied for '%s'"= ), - _("invalid PCI domain ID supplied for = '%s'")) < 0) + if (nodeDevCapsDefParseULong("number(./domain[1])", ctxt, + &data->pci_dev.domain, def, + _("no PCI domain ID supplied for '%s'"), + _("invalid PCI domain ID supplied for '%s= '")) < 0) goto out; =20 - if (virNodeDevCapsDefParseULong("number(./bus[1])", ctxt, - &data->pci_dev.bus, def, - _("no PCI bus ID supplied for '%s'"), - _("invalid PCI bus ID supplied for '%s= '")) < 0) + if (nodeDevCapsDefParseULong("number(./bus[1])", ctxt, + &data->pci_dev.bus, def, + _("no PCI bus ID supplied for '%s'"), + _("invalid PCI bus ID supplied for '%s'")= ) < 0) goto out; =20 - if (virNodeDevCapsDefParseULong("number(./slot[1])", ctxt, - &data->pci_dev.slot, def, - _("no PCI slot ID supplied for '%s'"), - _("invalid PCI slot ID supplied for '%= s'")) < 0) + if (nodeDevCapsDefParseULong("number(./slot[1])", ctxt, + &data->pci_dev.slot, def, + _("no PCI slot ID supplied for '%s'"), + _("invalid PCI slot ID supplied for '%s'"= )) < 0) goto out; =20 - if (virNodeDevCapsDefParseULong("number(./function[1])", ctxt, - &data->pci_dev.function, def, - _("no PCI function ID supplied for '%s= '"), - _("invalid PCI function ID supplied fo= r '%s'")) < 0) + if (nodeDevCapsDefParseULong("number(./function[1])", ctxt, + &data->pci_dev.function, def, + _("no PCI function ID supplied for '%s'"), + _("invalid PCI function ID supplied for '= %s'")) < 0) goto out; =20 - if (virNodeDevCapsDefParseHexId("string(./vendor[1]/@id)", ctxt, - &data->pci_dev.vendor, def, - _("no PCI vendor ID supplied for '%s'"= ), - _("invalid PCI vendor ID supplied for = '%s'")) < 0) + if (nodeDevCapsDefParseHexId("string(./vendor[1]/@id)", ctxt, + &data->pci_dev.vendor, def, + _("no PCI vendor ID supplied for '%s'"), + _("invalid PCI vendor ID supplied for '%s= '")) < 0) goto out; =20 - if (virNodeDevCapsDefParseHexId("string(./product[1]/@id)", ctxt, - &data->pci_dev.product, def, - _("no PCI product ID supplied for '%s'= "), - _("invalid PCI product ID supplied for= '%s'")) < 0) + if (nodeDevCapsDefParseHexId("string(./product[1]/@id)", ctxt, + &data->pci_dev.product, def, + _("no PCI product ID supplied for '%s'"), + _("invalid PCI product ID supplied for '%= s'")) < 0) goto out; =20 data->pci_dev.vendor_name =3D virXPathString("string(./vendor[1])", c= txt); @@ -1351,30 +1367,30 @@ virNodeDevCapPCIDevParseXML(xmlXPathContextPtr ctxt, goto out; =20 for (i =3D 0; i < n; i++) { - if (virNodeDevPCICapabilityParseXML(ctxt, nodes[i], data) < 0) + if (nodeDevPCICapabilityParseXML(ctxt, nodes[i], data) < 0) goto out; } VIR_FREE(nodes); =20 if ((iommuGroupNode =3D virXPathNode("./iommuGroup[1]", ctxt))) { - if (virNodeDevCapPCIDevIommuGroupParseXML(ctxt, iommuGroupNode, - data) < 0) { + if (nodeDevCapPCIDevIommuGroupParseXML(ctxt, iommuGroupNode, + data) < 0) { goto out; } } =20 /* The default value is -1 since zero is valid NUMA node number */ data->pci_dev.numa_node =3D -1; - if (virNodeDevCapsDefParseIntOptional("number(./numa[1]/@node)", ctxt, - &data->pci_dev.numa_node, def, - _("invalid NUMA node ID supplied= for '%s'")) < 0) + if (nodeDevCapsDefParseIntOptional("number(./numa[1]/@node)", ctxt, + &data->pci_dev.numa_node, def, + _("invalid NUMA node ID supplied fo= r '%s'")) < 0) goto out; =20 if ((pciExpress =3D virXPathNode("./pci-express[1]", ctxt))) { if (VIR_ALLOC(pci_express) < 0) goto out; =20 - if (virPCIEDeviceInfoParseXML(ctxt, pciExpress, pci_express) < 0) + if (nodeDevPCIEDeviceInfoParseXML(ctxt, pciExpress, pci_express) <= 0) goto out; =20 data->pci_dev.pci_express =3D pci_express; @@ -1391,11 +1407,12 @@ virNodeDevCapPCIDevParseXML(xmlXPathContextPtr ctxt, return ret; } =20 + static int -virNodeDevCapSystemParseXML(xmlXPathContextPtr ctxt, - virNodeDeviceDefPtr def, - xmlNodePtr node, - virNodeDevCapDataPtr data) +nodeDevCapSystemParseXML(xmlXPathContextPtr ctxt, + virNodeDeviceDefPtr def, + xmlNodePtr node, + virNodeDevCapDataPtr data) { xmlNodePtr orignode; int ret =3D -1; @@ -1435,12 +1452,13 @@ virNodeDevCapSystemParseXML(xmlXPathContextPtr ctxt, return ret; } =20 + static virNodeDevCapsDefPtr -virNodeDevCapsDefParseXML(xmlXPathContextPtr ctxt, - virNodeDeviceDefPtr def, - xmlNodePtr node, - int create, - const char *virt_type) +nodeDevCapsDefParseXML(xmlXPathContextPtr ctxt, + virNodeDeviceDefPtr def, + xmlNodePtr node, + int create, + const char *virt_type) { virNodeDevCapsDefPtr caps; char *tmp; @@ -1467,37 +1485,37 @@ virNodeDevCapsDefParseXML(xmlXPathContextPtr ctxt, =20 switch (caps->data.type) { case VIR_NODE_DEV_CAP_SYSTEM: - ret =3D virNodeDevCapSystemParseXML(ctxt, def, node, &caps->data); + ret =3D nodeDevCapSystemParseXML(ctxt, def, node, &caps->data); break; case VIR_NODE_DEV_CAP_PCI_DEV: - ret =3D virNodeDevCapPCIDevParseXML(ctxt, def, node, &caps->data); + ret =3D nodeDevCapPCIDevParseXML(ctxt, def, node, &caps->data); break; case VIR_NODE_DEV_CAP_USB_DEV: - ret =3D virNodeDevCapUSBDevParseXML(ctxt, def, node, &caps->data); + ret =3D nodeDevCapUSBDevParseXML(ctxt, def, node, &caps->data); break; case VIR_NODE_DEV_CAP_USB_INTERFACE: - ret =3D virNodeDevCapUSBInterfaceParseXML(ctxt, def, node, &caps->= data); + ret =3D nodeDevCapUSBInterfaceParseXML(ctxt, def, node, &caps->dat= a); break; case VIR_NODE_DEV_CAP_NET: - ret =3D virNodeDevCapNetParseXML(ctxt, def, node, &caps->data); + ret =3D nodeDevCapNetParseXML(ctxt, def, node, &caps->data); break; case VIR_NODE_DEV_CAP_SCSI_HOST: - ret =3D virNodeDevCapSCSIHostParseXML(ctxt, def, node, - &caps->data, - create, - virt_type); + ret =3D nodeDevCapSCSIHostParseXML(ctxt, def, node, + &caps->data, + create, + virt_type); break; case VIR_NODE_DEV_CAP_SCSI_TARGET: - ret =3D virNodeDevCapSCSITargetParseXML(ctxt, def, node, &caps->da= ta); + ret =3D nodeDevCapSCSITargetParseXML(ctxt, def, node, &caps->data); break; case VIR_NODE_DEV_CAP_SCSI: - ret =3D virNodeDevCapSCSIParseXML(ctxt, def, node, &caps->data); + ret =3D nodeDevCapSCSIParseXML(ctxt, def, node, &caps->data); break; case VIR_NODE_DEV_CAP_STORAGE: - ret =3D virNodeDevCapStorageParseXML(ctxt, def, node, &caps->data); + ret =3D nodeDevCapStorageParseXML(ctxt, def, node, &caps->data); break; case VIR_NODE_DEV_CAP_DRM: - ret =3D virNodeDevCapDRMParseXML(ctxt, def, node, &caps->data); + ret =3D nodeDevCapDRMParseXML(ctxt, def, node, &caps->data); break; case VIR_NODE_DEV_CAP_FC_HOST: case VIR_NODE_DEV_CAP_VPORTS: @@ -1519,10 +1537,11 @@ virNodeDevCapsDefParseXML(xmlXPathContextPtr ctxt, return NULL; } =20 + static virNodeDeviceDefPtr -virNodeDeviceDefParseXML(xmlXPathContextPtr ctxt, - int create, - const char *virt_type) +nodeDeviceDefParseXML(xmlXPathContextPtr ctxt, + int create, + const char *virt_type) { virNodeDeviceDefPtr def; virNodeDevCapsDefPtr *next_cap; @@ -1614,10 +1633,10 @@ virNodeDeviceDefParseXML(xmlXPathContextPtr ctxt, =20 next_cap =3D &def->caps; for (i =3D 0; i < n; i++) { - *next_cap =3D virNodeDevCapsDefParseXML(ctxt, def, - nodes[i], - create, - virt_type); + *next_cap =3D nodeDevCapsDefParseXML(ctxt, def, + nodes[i], + create, + virt_type); if (!*next_cap) goto error; =20 @@ -1633,6 +1652,7 @@ virNodeDeviceDefParseXML(xmlXPathContextPtr ctxt, return NULL; } =20 + virNodeDeviceDefPtr virNodeDeviceDefParseNode(xmlDocPtr xml, xmlNodePtr root, @@ -1657,18 +1677,19 @@ virNodeDeviceDefParseNode(xmlDocPtr xml, } =20 ctxt->node =3D root; - def =3D virNodeDeviceDefParseXML(ctxt, create, virt_type); + def =3D nodeDeviceDefParseXML(ctxt, create, virt_type); =20 cleanup: xmlXPathFreeContext(ctxt); return def; } =20 + static virNodeDeviceDefPtr -virNodeDeviceDefParse(const char *str, - const char *filename, - int create, - const char *virt_type) +nodeDeviceDefParse(const char *str, + const char *filename, + int create, + const char *virt_type) { xmlDocPtr xml; virNodeDeviceDefPtr def =3D NULL; @@ -1682,22 +1703,25 @@ virNodeDeviceDefParse(const char *str, return def; } =20 + virNodeDeviceDefPtr virNodeDeviceDefParseString(const char *str, int create, const char *virt_type) { - return virNodeDeviceDefParse(str, NULL, create, virt_type); + return nodeDeviceDefParse(str, NULL, create, virt_type); } =20 + virNodeDeviceDefPtr virNodeDeviceDefParseFile(const char *filename, int create, const char *virt_type) { - return virNodeDeviceDefParse(NULL, filename, create, virt_type); + return nodeDeviceDefParse(NULL, filename, create, virt_type); } =20 + /* * Return fc_host dev's WWNN and WWPN */ diff --git a/src/conf/virnodedeviceobj.c b/src/conf/virnodedeviceobj.c index 83f7217..a416fb8 100644 --- a/src/conf/virnodedeviceobj.c +++ b/src/conf/virnodedeviceobj.c @@ -33,7 +33,9 @@ VIR_LOG_INIT("conf.virnodedeviceobj"); =20 =20 -int virNodeDeviceHasCap(const virNodeDeviceObj *dev, const char *cap) +int +virNodeDeviceHasCap(const virNodeDeviceObj *dev, + const char *cap) { virNodeDevCapsDefPtr caps =3D dev->def->caps; const char *fc_host_cap =3D @@ -58,7 +60,7 @@ int virNodeDeviceHasCap(const virNodeDeviceObj *dev, cons= t char *cap) } =20 =20 -/* virNodeDeviceFindFCCapDef: +/* nodeDeviceFindFCCapDef: * @dev: Pointer to current device * * Search the device object 'caps' array for fc_host capability. @@ -67,7 +69,7 @@ int virNodeDeviceHasCap(const virNodeDeviceObj *dev, cons= t char *cap) * Pointer to the caps or NULL if not found */ static virNodeDevCapsDefPtr -virNodeDeviceFindFCCapDef(const virNodeDeviceObj *dev) +nodeDeviceFindFCCapDef(const virNodeDeviceObj *dev) { virNodeDevCapsDefPtr caps =3D dev->def->caps; =20 @@ -125,8 +127,9 @@ virNodeDeviceFindBySysfsPath(virNodeDeviceObjListPtr de= vs, } =20 =20 -virNodeDeviceObjPtr virNodeDeviceFindByName(virNodeDeviceObjListPtr devs, - const char *name) +virNodeDeviceObjPtr +virNodeDeviceFindByName(virNodeDeviceObjListPtr devs, + const char *name) { size_t i; =20 @@ -142,16 +145,16 @@ virNodeDeviceObjPtr virNodeDeviceFindByName(virNodeDe= viceObjListPtr devs, =20 =20 static virNodeDeviceObjPtr -virNodeDeviceFindByWWNs(virNodeDeviceObjListPtr devs, - const char *parent_wwnn, - const char *parent_wwpn) +nodeDeviceFindByWWNs(virNodeDeviceObjListPtr devs, + const char *parent_wwnn, + const char *parent_wwpn) { size_t i; =20 for (i =3D 0; i < devs->count; i++) { virNodeDevCapsDefPtr cap; virNodeDeviceObjLock(devs->objs[i]); - if ((cap =3D virNodeDeviceFindFCCapDef(devs->objs[i])) && + if ((cap =3D nodeDeviceFindFCCapDef(devs->objs[i])) && STREQ_NULLABLE(cap->data.scsi_host.wwnn, parent_wwnn) && STREQ_NULLABLE(cap->data.scsi_host.wwpn, parent_wwpn)) return devs->objs[i]; @@ -163,15 +166,15 @@ virNodeDeviceFindByWWNs(virNodeDeviceObjListPtr devs, =20 =20 static virNodeDeviceObjPtr -virNodeDeviceFindByFabricWWN(virNodeDeviceObjListPtr devs, - const char *parent_fabric_wwn) +nodeDeviceFindByFabricWWN(virNodeDeviceObjListPtr devs, + const char *parent_fabric_wwn) { size_t i; =20 for (i =3D 0; i < devs->count; i++) { virNodeDevCapsDefPtr cap; virNodeDeviceObjLock(devs->objs[i]); - if ((cap =3D virNodeDeviceFindFCCapDef(devs->objs[i])) && + if ((cap =3D nodeDeviceFindFCCapDef(devs->objs[i])) && STREQ_NULLABLE(cap->data.scsi_host.fabric_wwn, parent_fabric_w= wn)) return devs->objs[i]; virNodeDeviceObjUnlock(devs->objs[i]); @@ -182,8 +185,8 @@ virNodeDeviceFindByFabricWWN(virNodeDeviceObjListPtr de= vs, =20 =20 static virNodeDeviceObjPtr -virNodeDeviceFindByCap(virNodeDeviceObjListPtr devs, - const char *cap) +nodeDeviceFindByCap(virNodeDeviceObjListPtr devs, + const char *cap) { size_t i; =20 @@ -198,7 +201,8 @@ virNodeDeviceFindByCap(virNodeDeviceObjListPtr devs, } =20 =20 -void virNodeDeviceObjFree(virNodeDeviceObjPtr dev) +void +virNodeDeviceObjFree(virNodeDeviceObjPtr dev) { if (!dev) return; @@ -212,7 +216,9 @@ void virNodeDeviceObjFree(virNodeDeviceObjPtr dev) VIR_FREE(dev); } =20 -void virNodeDeviceObjListFree(virNodeDeviceObjListPtr devs) + +void +virNodeDeviceObjListFree(virNodeDeviceObjListPtr devs) { size_t i; for (i =3D 0; i < devs->count; i++) @@ -221,8 +227,10 @@ void virNodeDeviceObjListFree(virNodeDeviceObjListPtr = devs) devs->count =3D 0; } =20 -virNodeDeviceObjPtr virNodeDeviceAssignDef(virNodeDeviceObjListPtr devs, - virNodeDeviceDefPtr def) + +virNodeDeviceObjPtr +virNodeDeviceAssignDef(virNodeDeviceObjListPtr devs, + virNodeDeviceDefPtr def) { virNodeDeviceObjPtr device; =20 @@ -254,8 +262,10 @@ virNodeDeviceObjPtr virNodeDeviceAssignDef(virNodeDevi= ceObjListPtr devs, =20 } =20 -void virNodeDeviceObjRemove(virNodeDeviceObjListPtr devs, - virNodeDeviceObjPtr *dev) + +void +virNodeDeviceObjRemove(virNodeDeviceObjListPtr devs, + virNodeDeviceObjPtr *dev) { size_t i; =20 @@ -279,7 +289,7 @@ void virNodeDeviceObjRemove(virNodeDeviceObjListPtr dev= s, /* * Return the NPIV dev's parent device name */ -/* virNodeDeviceFindFCParentHost: +/* nodeDeviceFindFCParentHost: * @parent: Pointer to node device object * * Search the capabilities for the device to find the FC capabilities @@ -289,7 +299,7 @@ void virNodeDeviceObjRemove(virNodeDeviceObjListPtr dev= s, * parent_host value on success (>=3D 0), -1 otherwise. */ static int -virNodeDeviceFindFCParentHost(virNodeDeviceObjPtr parent) +nodeDeviceFindFCParentHost(virNodeDeviceObjPtr parent) { virNodeDevCapsDefPtr cap =3D virNodeDeviceFindVPORTCapDef(parent); =20 @@ -306,9 +316,9 @@ virNodeDeviceFindFCParentHost(virNodeDeviceObjPtr paren= t) =20 =20 static int -virNodeDeviceGetParentHostByParent(virNodeDeviceObjListPtr devs, - const char *dev_name, - const char *parent_name) +nodeDeviceGetParentHostByParent(virNodeDeviceObjListPtr devs, + const char *dev_name, + const char *parent_name) { virNodeDeviceObjPtr parent =3D NULL; int ret; @@ -320,7 +330,7 @@ virNodeDeviceGetParentHostByParent(virNodeDeviceObjList= Ptr devs, return -1; } =20 - ret =3D virNodeDeviceFindFCParentHost(parent); + ret =3D nodeDeviceFindFCParentHost(parent); =20 virNodeDeviceObjUnlock(parent); =20 @@ -329,22 +339,22 @@ virNodeDeviceGetParentHostByParent(virNodeDeviceObjLi= stPtr devs, =20 =20 static int -virNodeDeviceGetParentHostByWWNs(virNodeDeviceObjListPtr devs, - const char *dev_name, - const char *parent_wwnn, - const char *parent_wwpn) +nodeDeviceGetParentHostByWWNs(virNodeDeviceObjListPtr devs, + const char *dev_name, + const char *parent_wwnn, + const char *parent_wwpn) { virNodeDeviceObjPtr parent =3D NULL; int ret; =20 - if (!(parent =3D virNodeDeviceFindByWWNs(devs, parent_wwnn, parent_wwp= n))) { + if (!(parent =3D nodeDeviceFindByWWNs(devs, parent_wwnn, parent_wwpn))= ) { virReportError(VIR_ERR_INTERNAL_ERROR, _("Could not find parent device for '%s'"), dev_name); return -1; } =20 - ret =3D virNodeDeviceFindFCParentHost(parent); + ret =3D nodeDeviceFindFCParentHost(parent); =20 virNodeDeviceObjUnlock(parent); =20 @@ -353,21 +363,21 @@ virNodeDeviceGetParentHostByWWNs(virNodeDeviceObjList= Ptr devs, =20 =20 static int -virNodeDeviceGetParentHostByFabricWWN(virNodeDeviceObjListPtr devs, - const char *dev_name, - const char *parent_fabric_wwn) +nodeDeviceGetParentHostByFabricWWN(virNodeDeviceObjListPtr devs, + const char *dev_name, + const char *parent_fabric_wwn) { virNodeDeviceObjPtr parent =3D NULL; int ret; =20 - if (!(parent =3D virNodeDeviceFindByFabricWWN(devs, parent_fabric_wwn)= )) { + if (!(parent =3D nodeDeviceFindByFabricWWN(devs, parent_fabric_wwn))) { virReportError(VIR_ERR_INTERNAL_ERROR, _("Could not find parent device for '%s'"), dev_name); return -1; } =20 - ret =3D virNodeDeviceFindFCParentHost(parent); + ret =3D nodeDeviceFindFCParentHost(parent); =20 virNodeDeviceObjUnlock(parent); =20 @@ -376,19 +386,19 @@ virNodeDeviceGetParentHostByFabricWWN(virNodeDeviceOb= jListPtr devs, =20 =20 static int -virNodeDeviceFindVportParentHost(virNodeDeviceObjListPtr devs) +nodeDeviceFindVportParentHost(virNodeDeviceObjListPtr devs) { virNodeDeviceObjPtr parent =3D NULL; const char *cap =3D virNodeDevCapTypeToString(VIR_NODE_DEV_CAP_VPORTS); int ret; =20 - if (!(parent =3D virNodeDeviceFindByCap(devs, cap))) { + if (!(parent =3D nodeDeviceFindByCap(devs, cap))) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("Could not find any vport capable device")); return -1; } =20 - ret =3D virNodeDeviceFindFCParentHost(parent); + ret =3D nodeDeviceFindFCParentHost(parent); =20 virNodeDeviceObjUnlock(parent); =20 @@ -404,38 +414,42 @@ virNodeDeviceGetParentHost(virNodeDeviceObjListPtr de= vs, int parent_host =3D -1; =20 if (def->parent) { - parent_host =3D virNodeDeviceGetParentHostByParent(devs, def->name, - def->parent); + parent_host =3D nodeDeviceGetParentHostByParent(devs, def->name, + def->parent); } else if (def->parent_wwnn && def->parent_wwpn) { - parent_host =3D virNodeDeviceGetParentHostByWWNs(devs, def->name, - def->parent_wwnn, - def->parent_wwpn); + parent_host =3D nodeDeviceGetParentHostByWWNs(devs, def->name, + def->parent_wwnn, + def->parent_wwpn); } else if (def->parent_fabric_wwn) { parent_host =3D - virNodeDeviceGetParentHostByFabricWWN(devs, def->name, - def->parent_fabric_wwn); + nodeDeviceGetParentHostByFabricWWN(devs, def->name, + def->parent_fabric_wwn); } else if (create =3D=3D CREATE_DEVICE) { /* Try to find a vport capable scsi_host when no parent supplied */ - parent_host =3D virNodeDeviceFindVportParentHost(devs); + parent_host =3D nodeDeviceFindVportParentHost(devs); } =20 return parent_host; } =20 =20 -void virNodeDeviceObjLock(virNodeDeviceObjPtr obj) +void +virNodeDeviceObjLock(virNodeDeviceObjPtr obj) { virMutexLock(&obj->lock); } =20 -void virNodeDeviceObjUnlock(virNodeDeviceObjPtr obj) + +void +virNodeDeviceObjUnlock(virNodeDeviceObjPtr obj) { virMutexUnlock(&obj->lock); } =20 + static bool -virNodeDeviceCapMatch(virNodeDeviceObjPtr devobj, - int type) +nodeDeviceCapMatch(virNodeDeviceObjPtr devobj, + int type) { virNodeDevCapsDefPtr cap =3D NULL; =20 @@ -459,11 +473,12 @@ virNodeDeviceCapMatch(virNodeDeviceObjPtr devobj, return false; } =20 + #define MATCH(FLAG) ((flags & (VIR_CONNECT_LIST_NODE_DEVICES_CAP_ ## FLAG)= ) && \ - virNodeDeviceCapMatch(devobj, VIR_NODE_DEV_CAP_ ## FL= AG)) + nodeDeviceCapMatch(devobj, VIR_NODE_DEV_CAP_ ## FLAG)) static bool -virNodeDeviceMatch(virNodeDeviceObjPtr devobj, - unsigned int flags) +nodeDeviceMatch(virNodeDeviceObjPtr devobj, + unsigned int flags) { /* filter by cap type */ if (flags & VIR_CONNECT_LIST_NODE_DEVICES_FILTERS_CAP) { @@ -487,6 +502,7 @@ virNodeDeviceMatch(virNodeDeviceObjPtr devobj, } #undef MATCH =20 + int virNodeDeviceObjListExport(virConnectPtr conn, virNodeDeviceObjList devobjs, @@ -507,7 +523,7 @@ virNodeDeviceObjListExport(virConnectPtr conn, virNodeDeviceObjPtr devobj =3D devobjs.objs[i]; virNodeDeviceObjLock(devobj); if ((!filter || filter(conn, devobj->def)) && - virNodeDeviceMatch(devobj, flags)) { + nodeDeviceMatch(devobj, flags)) { if (devices) { if (!(device =3D virGetNodeDevice(conn, devobj->def->name)= ) || VIR_STRDUP(device->parent, devobj->def->parent) < 0) { --=20 2.9.3 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list