From nobody Sat Apr 27 12:38:25 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1502713977607753.4173771931415; Mon, 14 Aug 2017 05:32:57 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 7F8FB61E5F; Mon, 14 Aug 2017 12:32:55 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 598EC60841; Mon, 14 Aug 2017 12:32:55 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 1295B1803B23; Mon, 14 Aug 2017 12:32:55 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id v7ECWptZ015502 for ; Mon, 14 Aug 2017 08:32:51 -0400 Received: by smtp.corp.redhat.com (Postfix) id 49AEC6872B; Mon, 14 Aug 2017 12:32:51 +0000 (UTC) Received: from antique-work.brq.redhat.com (unknown [10.43.2.152]) by smtp.corp.redhat.com (Postfix) with ESMTP id C36BE68737 for ; Mon, 14 Aug 2017 12:32:50 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 7F8FB61E5F Authentication-Results: ext-mx10.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx10.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=libvir-list-bounces@redhat.com From: Pavel Hrdina To: libvir-list@redhat.com Date: Mon, 14 Aug 2017 14:32:40 +0200 Message-Id: <5bd8a1c5d8d86f5b0099eb8bdf8e29314013c0b9.1502713940.git.phrdina@redhat.com> In-Reply-To: References: In-Reply-To: References: X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 1/8] util: introduce virXMLNodeNameEqual X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.39]); Mon, 14 Aug 2017 12:32:56 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Signed-off-by: Pavel Hrdina --- src/libvirt_private.syms | 1 + src/util/virxml.c | 16 ++++++++++++++++ src/util/virxml.h | 3 +++ 3 files changed, 20 insertions(+) diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index 447dd938d0..4f1ad2a0cc 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -2931,6 +2931,7 @@ virVHBAPathExists; virXMLCheckIllegalChars; virXMLChildElementCount; virXMLExtractNamespaceXML; +virXMLNodeNameEqual; virXMLNodeSanitizeNamespaces; virXMLNodeToString; virXMLParseHelper; diff --git a/src/util/virxml.c b/src/util/virxml.c index 39049d869b..b42358a08c 100644 --- a/src/util/virxml.c +++ b/src/util/virxml.c @@ -950,6 +950,22 @@ virXMLNodeToString(xmlDocPtr doc, return ret; } =20 + +/** + * virXMLNodeNameEqual: + * @node: xml Node pointer to check + * @name: name of the @node + * + * Compares the @node name with @name. + */ +bool +virXMLNodeNameEqual(xmlNodePtr node, + const char *name) +{ + return xmlStrEqual(node->name, BAD_CAST name); +} + + typedef int (*virXMLForeachCallback)(xmlNodePtr node, void *opaque); =20 diff --git a/src/util/virxml.h b/src/util/virxml.h index 17fccd81f4..2f953a6d44 100644 --- a/src/util/virxml.h +++ b/src/util/virxml.h @@ -168,6 +168,9 @@ int virXMLSaveFile(const char *path, =20 char *virXMLNodeToString(xmlDocPtr doc, xmlNodePtr node); =20 +bool virXMLNodeNameEqual(xmlNodePtr node, + const char *name); + xmlNodePtr virXMLFindChildNodeByNs(xmlNodePtr root, const char *uri); =20 --=20 2.13.5 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Sat Apr 27 12:38:25 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1502713977358756.7732969642936; Mon, 14 Aug 2017 05:32:57 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 8469C624C6; Mon, 14 Aug 2017 12:32:55 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 55ED64D740; Mon, 14 Aug 2017 12:32:55 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id DA5B014B1E; Mon, 14 Aug 2017 12:32:54 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id v7ECWqmr015519 for ; Mon, 14 Aug 2017 08:32:52 -0400 Received: by smtp.corp.redhat.com (Postfix) id 8B98068738; Mon, 14 Aug 2017 12:32:52 +0000 (UTC) Received: from antique-work.brq.redhat.com (unknown [10.43.2.152]) by smtp.corp.redhat.com (Postfix) with ESMTP id 9378B6872B for ; Mon, 14 Aug 2017 12:32:51 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 8469C624C6 Authentication-Results: ext-mx10.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx10.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=libvir-list-bounces@redhat.com From: Pavel Hrdina To: libvir-list@redhat.com Date: Mon, 14 Aug 2017 14:32:41 +0200 Message-Id: <068606f85ca258a748be31da834aa0cdbd1f780c.1502713940.git.phrdina@redhat.com> In-Reply-To: References: In-Reply-To: References: X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 2/8] use virXMLNodeNameEqual instead of xmlStrEqual X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.39]); Mon, 14 Aug 2017 12:32:56 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Signed-off-by: Pavel Hrdina --- src/conf/cpu_conf.c | 2 +- src/conf/domain_conf.c | 212 +++++++++++++++++--------------= ---- src/conf/interface_conf.c | 2 +- src/conf/netdev_bandwidth_conf.c | 6 +- src/conf/netdev_vport_profile_conf.c | 2 +- src/conf/network_conf.c | 12 +- src/conf/node_device_conf.c | 2 +- src/conf/nwfilter_conf.c | 6 +- src/conf/nwfilter_params.c | 2 +- src/conf/secret_conf.c | 2 +- src/conf/snapshot_conf.c | 2 +- src/conf/storage_conf.c | 4 +- src/conf/virnetworkobj.c | 2 +- src/conf/virsavecookie.c | 2 +- src/esx/esx_vi_types.c | 9 +- src/security/virt-aa-helper.c | 2 +- src/test/test_driver.c | 2 +- src/vz/vz_sdk.c | 2 +- tools/virsh-domain.c | 18 +-- tools/virsh-interface.c | 12 +- 20 files changed, 152 insertions(+), 151 deletions(-) diff --git a/src/conf/cpu_conf.c b/src/conf/cpu_conf.c index 065b4df997..cdb8583647 100644 --- a/src/conf/cpu_conf.c +++ b/src/conf/cpu_conf.c @@ -280,7 +280,7 @@ virCPUDefParseXML(xmlXPathContextPtr ctxt, goto cleanup; } =20 - if (!xmlStrEqual(ctxt->node->name, BAD_CAST "cpu")) { + if (!virXMLNodeNameEqual(ctxt->node, "cpu")) { virReportError(VIR_ERR_XML_ERROR, "%s", _("XML does not contain expected 'cpu' element")); goto cleanup; diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index b487ff2fdf..37aa975eca 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -1202,9 +1202,9 @@ virDomainBlkioDeviceParseXML(xmlNodePtr root, node =3D root->children; while (node) { if (node->type =3D=3D XML_ELEMENT_NODE) { - if (xmlStrEqual(node->name, BAD_CAST "path") && !dev->path) { + if (virXMLNodeNameEqual(node, "path") && !dev->path) { dev->path =3D (char *)xmlNodeGetContent(node); - } else if (xmlStrEqual(node->name, BAD_CAST "weight")) { + } else if (virXMLNodeNameEqual(node, "weight")) { c =3D (char *)xmlNodeGetContent(node); if (virStrToLong_ui(c, NULL, 10, &dev->weight) < 0) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, @@ -1213,7 +1213,7 @@ virDomainBlkioDeviceParseXML(xmlNodePtr root, goto error; } VIR_FREE(c); - } else if (xmlStrEqual(node->name, BAD_CAST "read_bytes_sec"))= { + } else if (virXMLNodeNameEqual(node, "read_bytes_sec")) { c =3D (char *)xmlNodeGetContent(node); if (virStrToLong_ull(c, NULL, 10, &dev->rbps) < 0) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, @@ -1222,7 +1222,7 @@ virDomainBlkioDeviceParseXML(xmlNodePtr root, goto error; } VIR_FREE(c); - } else if (xmlStrEqual(node->name, BAD_CAST "write_bytes_sec")= ) { + } else if (virXMLNodeNameEqual(node, "write_bytes_sec")) { c =3D (char *)xmlNodeGetContent(node); if (virStrToLong_ull(c, NULL, 10, &dev->wbps) < 0) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, @@ -1231,7 +1231,7 @@ virDomainBlkioDeviceParseXML(xmlNodePtr root, goto error; } VIR_FREE(c); - } else if (xmlStrEqual(node->name, BAD_CAST "read_iops_sec")) { + } else if (virXMLNodeNameEqual(node, "read_iops_sec")) { c =3D (char *)xmlNodeGetContent(node); if (virStrToLong_ui(c, NULL, 10, &dev->riops) < 0) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, @@ -1240,7 +1240,7 @@ virDomainBlkioDeviceParseXML(xmlNodePtr root, goto error; } VIR_FREE(c); - } else if (xmlStrEqual(node->name, BAD_CAST "write_iops_sec"))= { + } else if (virXMLNodeNameEqual(node, "write_iops_sec")) { c =3D (char *)xmlNodeGetContent(node); if (virStrToLong_ui(c, NULL, 10, &dev->wiops) < 0) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, @@ -5913,21 +5913,21 @@ virDomainDeviceInfoParseXML(xmlNodePtr node, if (cur->type =3D=3D XML_ELEMENT_NODE) { if (alias =3D=3D NULL && !(flags & VIR_DOMAIN_DEF_PARSE_INACTIVE) && - xmlStrEqual(cur->name, BAD_CAST "alias")) { + virXMLNodeNameEqual(cur, "alias")) { alias =3D cur; } else if (address =3D=3D NULL && - xmlStrEqual(cur->name, BAD_CAST "address")) { + virXMLNodeNameEqual(cur, "address")) { address =3D cur; } else if (master =3D=3D NULL && - xmlStrEqual(cur->name, BAD_CAST "master")) { + virXMLNodeNameEqual(cur, "master")) { master =3D cur; } else if (boot =3D=3D NULL && (flags & VIR_DOMAIN_DEF_PARSE_ALLOW_BOOT) && - xmlStrEqual(cur->name, BAD_CAST "boot")) { + virXMLNodeNameEqual(cur, "boot")) { boot =3D cur; } else if (rom =3D=3D NULL && (flags & VIR_DOMAIN_DEF_PARSE_ALLOW_ROM) && - xmlStrEqual(cur->name, BAD_CAST "rom")) { + virXMLNodeNameEqual(cur, "rom")) { rom =3D cur; } } @@ -6105,7 +6105,7 @@ virDomainHostdevSubsysUSBDefParseXML(xmlNodePtr node, cur =3D node->children; while (cur !=3D NULL) { if (cur->type =3D=3D XML_ELEMENT_NODE) { - if (xmlStrEqual(cur->name, BAD_CAST "vendor")) { + if (virXMLNodeNameEqual(cur, "vendor")) { char *vendor =3D virXMLPropString(cur, "id"); =20 if (vendor) { @@ -6122,7 +6122,7 @@ virDomainHostdevSubsysUSBDefParseXML(xmlNodePtr node, "%s", _("usb vendor needs id")); goto out; } - } else if (xmlStrEqual(cur->name, BAD_CAST "product")) { + } else if (virXMLNodeNameEqual(cur, "product")) { char* product =3D virXMLPropString(cur, "id"); =20 if (product) { @@ -6141,7 +6141,7 @@ virDomainHostdevSubsysUSBDefParseXML(xmlNodePtr node, "%s", _("usb product needs id")); goto out; } - } else if (xmlStrEqual(cur->name, BAD_CAST "address")) { + } else if (virXMLNodeNameEqual(cur, "address")) { char *bus, *device; =20 bus =3D virXMLPropString(cur, "bus"); @@ -6223,11 +6223,11 @@ virDomainHostdevSubsysPCIOrigStatesDefParseXML(xmlN= odePtr node, =20 while (cur !=3D NULL) { if (cur->type =3D=3D XML_ELEMENT_NODE) { - if (xmlStrEqual(cur->name, BAD_CAST "unbind")) { + if (virXMLNodeNameEqual(cur, "unbind")) { def->states.pci.unbind_from_stub =3D true; - } else if (xmlStrEqual(cur->name, BAD_CAST "removeslot")) { + } else if (virXMLNodeNameEqual(cur, "removeslot")) { def->states.pci.remove_slot =3D true; - } else if (xmlStrEqual(cur->name, BAD_CAST "reprobe")) { + } else if (virXMLNodeNameEqual(cur, "reprobe")) { def->states.pci.reprobe =3D true; } else { virReportError(VIR_ERR_INTERNAL_ERROR, @@ -6253,14 +6253,14 @@ virDomainHostdevSubsysPCIDefParseXML(xmlNodePtr nod= e, cur =3D node->children; while (cur !=3D NULL) { if (cur->type =3D=3D XML_ELEMENT_NODE) { - if (xmlStrEqual(cur->name, BAD_CAST "address")) { + if (virXMLNodeNameEqual(cur, "address")) { virPCIDeviceAddressPtr addr =3D &def->source.subsys.u.pci.addr; =20 if (virPCIDeviceAddressParseXML(cur, addr) < 0) goto out; } else if ((flags & VIR_DOMAIN_DEF_PARSE_STATUS) && - xmlStrEqual(cur->name, BAD_CAST "state")) { + virXMLNodeNameEqual(cur, "state")) { /* Legacy back-compat. Don't add any more attributes here = */ char *devaddr =3D virXMLPropString(cur, "devaddr"); if (devaddr && @@ -6274,7 +6274,7 @@ virDomainHostdevSubsysPCIDefParseXML(xmlNodePtr node, } def->info->type =3D VIR_DOMAIN_DEVICE_ADDRESS_TYPE_PCI; } else if ((flags & VIR_DOMAIN_DEF_PARSE_PCI_ORIG_STATES) && - xmlStrEqual(cur->name, BAD_CAST "origstates")) { + virXMLNodeNameEqual(cur, "origstates")) { virDomainHostdevOrigStatesPtr states =3D &def->origstates; if (virDomainHostdevSubsysPCIOrigStatesDefParseXML(cur, st= ates) < 0) goto out; @@ -6371,7 +6371,7 @@ virDomainStorageNetworkParseHosts(xmlNodePtr node, =20 for (child =3D node->children; child; child =3D child->next) { if (child->type =3D=3D XML_ELEMENT_NODE && - xmlStrEqual(child->name, BAD_CAST "host")) { + virXMLNodeNameEqual(child, "host")) { =20 if (virDomainStorageNetworkParseHost(child, hosts, nhosts) < 0) return -1; @@ -6395,7 +6395,7 @@ virDomainHostdevSubsysSCSIHostDefParseXML(xmlNodePtr = sourcenode, cur =3D sourcenode->children; while (cur !=3D NULL) { if (cur->type =3D=3D XML_ELEMENT_NODE) { - if (xmlStrEqual(cur->name, BAD_CAST "address")) { + if (virXMLNodeNameEqual(cur, "address")) { if (got_address) { virReportError(VIR_ERR_XML_ERROR, "%s", _("more than one source addresses is " @@ -6432,7 +6432,7 @@ virDomainHostdevSubsysSCSIHostDefParseXML(xmlNodePtr = sourcenode, } =20 got_address =3D true; - } else if (xmlStrEqual(cur->name, BAD_CAST "adapter")) { + } else if (virXMLNodeNameEqual(cur, "adapter")) { if (got_adapter) { virReportError(VIR_ERR_XML_ERROR, "%s", _("more than one adapters is specified " @@ -6508,7 +6508,7 @@ virDomainHostdevSubsysSCSIiSCSIDefParseXML(xmlNodePtr= sourcenode, cur =3D sourcenode->children; while (cur !=3D NULL) { if (cur->type =3D=3D XML_ELEMENT_NODE && - xmlStrEqual(cur->name, BAD_CAST "auth")) { + virXMLNodeNameEqual(cur, "auth")) { if (!(authdef =3D virStorageAuthDefParse(sourcenode->doc, cur)= )) goto cleanup; if ((auth_secret_usage =3D @@ -7591,13 +7591,13 @@ virDomainLeaseDefParseXML(xmlNodePtr node) cur =3D node->children; while (cur !=3D NULL) { if (cur->type =3D=3D XML_ELEMENT_NODE) { - if (!key && xmlStrEqual(cur->name, BAD_CAST "key")) { + if (!key && virXMLNodeNameEqual(cur, "key")) { key =3D (char *)xmlNodeGetContent(cur); } else if (!lockspace && - xmlStrEqual(cur->name, BAD_CAST "lockspace")) { + virXMLNodeNameEqual(cur, "lockspace")) { lockspace =3D (char *)xmlNodeGetContent(cur); } else if (!path && - xmlStrEqual(cur->name, BAD_CAST "target")) { + virXMLNodeNameEqual(cur, "target")) { path =3D virXMLPropString(cur, "path"); offset =3D virXMLPropString(cur, "offset"); } @@ -8346,7 +8346,7 @@ virDomainDiskDefParseXML(virDomainXMLOptionPtr xmlopt, if (cur->type !=3D XML_ELEMENT_NODE) continue; =20 - if (!source && xmlStrEqual(cur->name, BAD_CAST "source")) { + if (!source && virXMLNodeNameEqual(cur, "source")) { sourceNode =3D cur; =20 if (virDomainDiskSourceParse(cur, ctxt, def->src) < 0) @@ -8364,7 +8364,7 @@ virDomainDiskDefParseXML(virDomainXMLOptionPtr xmlopt, startupPolicy =3D virXMLPropString(cur, "startupPolicy"); =20 } else if (!target && - xmlStrEqual(cur->name, BAD_CAST "target")) { + virXMLNodeNameEqual(cur, "target")) { target =3D virXMLPropString(cur, "dev"); bus =3D virXMLPropString(cur, "bus"); tray =3D virXMLPropString(cur, "tray"); @@ -8376,12 +8376,12 @@ virDomainDiskDefParseXML(virDomainXMLOptionPtr xmlo= pt, STRPREFIX(target, "ioemu:")) memmove(target, target+6, strlen(target)-5); } else if (!domain_name && - xmlStrEqual(cur->name, BAD_CAST "backenddomain")) { + virXMLNodeNameEqual(cur, "backenddomain")) { domain_name =3D virXMLPropString(cur, "name"); - } else if (xmlStrEqual(cur->name, BAD_CAST "geometry")) { + } else if (virXMLNodeNameEqual(cur, "geometry")) { if (virDomainDiskDefGeometryParse(def, cur, ctxt) < 0) goto error; - } else if (xmlStrEqual(cur->name, BAD_CAST "blockio")) { + } else if (virXMLNodeNameEqual(cur, "blockio")) { logical_block_size =3D virXMLPropString(cur, "logical_block_size"); if (logical_block_size && @@ -8403,16 +8403,16 @@ virDomainDiskDefParseXML(virDomainXMLOptionPtr xmlo= pt, goto error; } } else if (!def->src->driverName && - xmlStrEqual(cur->name, BAD_CAST "driver")) { + virXMLNodeNameEqual(cur, "driver")) { if (virDomainDiskDefDriverParseXML(def, cur) < 0) goto error; } else if (!def->mirror && - xmlStrEqual(cur->name, BAD_CAST "mirror") && + virXMLNodeNameEqual(cur, "mirror") && !(flags & VIR_DOMAIN_DEF_PARSE_INACTIVE)) { if (virDomainDiskDefMirrorParse(def, cur, ctxt) < 0) goto error; } else if (!authdef && - xmlStrEqual(cur->name, BAD_CAST "auth")) { + virXMLNodeNameEqual(cur, "auth")) { if (!(authdef =3D virStorageAuthDefParse(node->doc, cur))) goto error; /* Disk volume types won't have the secrettype filled in until @@ -8426,36 +8426,36 @@ virDomainDiskDefParseXML(virDomainXMLOptionPtr xmlo= pt, authdef->secrettype); goto error; } - } else if (xmlStrEqual(cur->name, BAD_CAST "iotune")) { + } else if (virXMLNodeNameEqual(cur, "iotune")) { if (virDomainDiskDefIotuneParse(def, ctxt) < 0) goto error; - } else if (xmlStrEqual(cur->name, BAD_CAST "readonly")) { + } else if (virXMLNodeNameEqual(cur, "readonly")) { def->src->readonly =3D true; - } else if (xmlStrEqual(cur->name, BAD_CAST "shareable")) { + } else if (virXMLNodeNameEqual(cur, "shareable")) { def->src->shared =3D true; - } else if (xmlStrEqual(cur->name, BAD_CAST "transient")) { + } else if (virXMLNodeNameEqual(cur, "transient")) { def->transient =3D true; } else if ((flags & VIR_DOMAIN_DEF_PARSE_STATUS) && - xmlStrEqual(cur->name, BAD_CAST "state")) { + virXMLNodeNameEqual(cur, "state")) { /* Legacy back-compat. Don't add any more attributes here */ devaddr =3D virXMLPropString(cur, "devaddr"); } else if (encryption =3D=3D NULL && - xmlStrEqual(cur->name, BAD_CAST "encryption")) { + virXMLNodeNameEqual(cur, "encryption")) { encryption =3D virStorageEncryptionParseNode(node->doc, cur); if (encryption =3D=3D NULL) goto error; } else if (!serial && - xmlStrEqual(cur->name, BAD_CAST "serial")) { + virXMLNodeNameEqual(cur, "serial")) { serial =3D (char *)xmlNodeGetContent(cur); } else if (!wwn && - xmlStrEqual(cur->name, BAD_CAST "wwn")) { + virXMLNodeNameEqual(cur, "wwn")) { wwn =3D (char *)xmlNodeGetContent(cur); =20 if (!virValidateWWN(wwn)) goto error; } else if (!vendor && - xmlStrEqual(cur->name, BAD_CAST "vendor")) { + virXMLNodeNameEqual(cur, "vendor")) { vendor =3D (char *)xmlNodeGetContent(cur); =20 if (strlen(vendor) > VENDOR_LEN) { @@ -8470,7 +8470,7 @@ virDomainDiskDefParseXML(virDomainXMLOptionPtr xmlopt, goto error; } } else if (!product && - xmlStrEqual(cur->name, BAD_CAST "product")) { + virXMLNodeNameEqual(cur, "product")) { product =3D (char *)xmlNodeGetContent(cur); =20 if (strlen(product) > PRODUCT_LEN) { @@ -8484,7 +8484,7 @@ virDomainDiskDefParseXML(virDomainXMLOptionPtr xmlopt, _("disk product is not printable string")); goto error; } - } else if (xmlStrEqual(cur->name, BAD_CAST "boot")) { + } else if (virXMLNodeNameEqual(cur, "boot")) { /* boot is parsed as part of virDomainDeviceInfoParseXML */ } } @@ -9070,13 +9070,13 @@ virDomainControllerDefParseXML(xmlNodePtr node, cur =3D node->children; while (cur !=3D NULL) { if (cur->type =3D=3D XML_ELEMENT_NODE) { - if (xmlStrEqual(cur->name, BAD_CAST "driver")) { + if (virXMLNodeNameEqual(cur, "driver")) { queues =3D virXMLPropString(cur, "queues"); cmd_per_lun =3D virXMLPropString(cur, "cmd_per_lun"); max_sectors =3D virXMLPropString(cur, "max_sectors"); ioeventfd =3D virXMLPropString(cur, "ioeventfd"); iothread =3D virXMLPropString(cur, "iothread"); - } else if (xmlStrEqual(cur->name, BAD_CAST "model")) { + } else if (virXMLNodeNameEqual(cur, "model")) { if (processedModel) { virReportError(VIR_ERR_XML_ERROR, "%s", _("Multiple elements in " @@ -9085,7 +9085,7 @@ virDomainControllerDefParseXML(xmlNodePtr node, } modelName =3D virXMLPropString(cur, "name"); processedModel =3D true; - } else if (xmlStrEqual(cur->name, BAD_CAST "target")) { + } else if (virXMLNodeNameEqual(cur, "target")) { if (processedTarget) { virReportError(VIR_ERR_XML_ERROR, "%s", _("Multiple elements in " @@ -9450,7 +9450,7 @@ virDomainFSDefParseXML(xmlNodePtr node, while (cur !=3D NULL) { if (cur->type =3D=3D XML_ELEMENT_NODE) { if (!source && - xmlStrEqual(cur->name, BAD_CAST "source")) { + virXMLNodeNameEqual(cur, "source")) { =20 if (def->type =3D=3D VIR_DOMAIN_FS_TYPE_MOUNT || def->type =3D=3D VIR_DOMAIN_FS_TYPE_BIND) { @@ -9470,11 +9470,11 @@ virDomainFSDefParseXML(xmlNodePtr node, goto error; } } else if (!target && - xmlStrEqual(cur->name, BAD_CAST "target")) { + virXMLNodeNameEqual(cur, "target")) { target =3D virXMLPropString(cur, "dir"); - } else if (xmlStrEqual(cur->name, BAD_CAST "readonly")) { + } else if (virXMLNodeNameEqual(cur, "readonly")) { def->readonly =3D true; - } else if (xmlStrEqual(cur->name, BAD_CAST "driver")) { + } else if (virXMLNodeNameEqual(cur, "driver")) { if (!fsdriver) fsdriver =3D virXMLPropString(cur, "type"); if (!wrpolicy) @@ -9857,7 +9857,7 @@ virDomainNetDefParseXML(virDomainXMLOptionPtr xmlopt, cur =3D node->children; while (cur !=3D NULL) { if (cur->type =3D=3D XML_ELEMENT_NODE) { - if (xmlStrEqual(cur->name, BAD_CAST "source")) { + if (virXMLNodeNameEqual(cur, "source")) { xmlNodePtr tmpnode =3D ctxt->node; =20 ctxt->node =3D cur; @@ -9866,27 +9866,27 @@ virDomainNetDefParseXML(virDomainXMLOptionPtr xmlop= t, goto error; ctxt->node =3D tmpnode; } - if (!macaddr && xmlStrEqual(cur->name, BAD_CAST "mac")) { + if (!macaddr && virXMLNodeNameEqual(cur, "mac")) { macaddr =3D virXMLPropString(cur, "address"); } else if (!network && def->type =3D=3D VIR_DOMAIN_NET_TYPE_NETWORK && - xmlStrEqual(cur->name, BAD_CAST "source")) { + virXMLNodeNameEqual(cur, "source")) { network =3D virXMLPropString(cur, "network"); portgroup =3D virXMLPropString(cur, "portgroup"); } else if (!internal && def->type =3D=3D VIR_DOMAIN_NET_TYPE_INTERNAL && - xmlStrEqual(cur->name, BAD_CAST "source")) { + virXMLNodeNameEqual(cur, "source")) { internal =3D virXMLPropString(cur, "name"); } else if (!bridge && def->type =3D=3D VIR_DOMAIN_NET_TYPE_BRIDGE && - xmlStrEqual(cur->name, BAD_CAST "source")) { + virXMLNodeNameEqual(cur, "source")) { bridge =3D virXMLPropString(cur, "bridge"); } else if (!dev && def->type =3D=3D VIR_DOMAIN_NET_TYPE_DIRECT= && - xmlStrEqual(cur->name, BAD_CAST "source")) { + virXMLNodeNameEqual(cur, "source")) { dev =3D virXMLPropString(cur, "dev"); mode =3D virXMLPropString(cur, "mode"); } else if (!dev && def->type =3D=3D VIR_DOMAIN_NET_TYPE_ETHERN= ET && - xmlStrEqual(cur->name, BAD_CAST "source")) { + virXMLNodeNameEqual(cur, "source")) { /* This clause is only necessary because from 2010 to * 2016 it was possible (but never documented) to * configure the name of the guest-side interface of @@ -9908,12 +9908,12 @@ virDomainNetDefParseXML(virDomainXMLOptionPtr xmlop= t, } } else if (!vhostuser_path && !vhostuser_mode && !vhostuser_ty= pe && def->type =3D=3D VIR_DOMAIN_NET_TYPE_VHOSTUSER && - xmlStrEqual(cur->name, BAD_CAST "source")) { + virXMLNodeNameEqual(cur, "source")) { vhostuser_type =3D virXMLPropString(cur, "type"); vhostuser_path =3D virXMLPropString(cur, "path"); vhostuser_mode =3D virXMLPropString(cur, "mode"); } else if (!def->virtPortProfile - && xmlStrEqual(cur->name, BAD_CAST "virtualport")) { + && virXMLNodeNameEqual(cur, "virtualport")) { if (def->type =3D=3D VIR_DOMAIN_NET_TYPE_NETWORK) { if (!(def->virtPortProfile =3D virNetDevVPortProfileParse(cur, @@ -9941,7 +9941,7 @@ virDomainNetDefParseXML(virDomainXMLOptionPtr xmlopt, def->type =3D=3D VIR_DOMAIN_NET_TYPE_CLIENT || def->type =3D=3D VIR_DOMAIN_NET_TYPE_MCAST || def->type =3D=3D VIR_DOMAIN_NET_TYPE_UDP) && - xmlStrEqual(cur->name, BAD_CAST "source")) { + virXMLNodeNameEqual(cur, "source")) { address =3D virXMLPropString(cur, "address"); port =3D virXMLPropString(cur, "port"); if (!localaddr && def->type =3D=3D VIR_DOMAIN_NET_TYPE_UDP= ) { @@ -9952,7 +9952,7 @@ virDomainNetDefParseXML(virDomainXMLOptionPtr xmlopt, ctxt->node =3D tmpnode; } } else if (!ifname && - xmlStrEqual(cur->name, BAD_CAST "target")) { + virXMLNodeNameEqual(cur, "target")) { ifname =3D virXMLPropString(cur, "dev"); if (ifname && (flags & VIR_DOMAIN_DEF_PARSE_INACTIVE) && @@ -9962,21 +9962,21 @@ virDomainNetDefParseXML(virDomainXMLOptionPtr xmlop= t, VIR_FREE(ifname); } } else if ((!ifname_guest || !ifname_guest_actual) && - xmlStrEqual(cur->name, BAD_CAST "guest")) { + virXMLNodeNameEqual(cur, "guest")) { ifname_guest =3D virXMLPropString(cur, "dev"); ifname_guest_actual =3D virXMLPropString(cur, "actual"); } else if (!linkstate && - xmlStrEqual(cur->name, BAD_CAST "link")) { + virXMLNodeNameEqual(cur, "link")) { linkstate =3D virXMLPropString(cur, "state"); } else if (!script && - xmlStrEqual(cur->name, BAD_CAST "script")) { + virXMLNodeNameEqual(cur, "script")) { script =3D virXMLPropString(cur, "path"); } else if (!domain_name && - xmlStrEqual(cur->name, BAD_CAST "backenddomain")) { + virXMLNodeNameEqual(cur, "backenddomain")) { domain_name =3D virXMLPropString(cur, "name"); - } else if (xmlStrEqual(cur->name, BAD_CAST "model")) { + } else if (virXMLNodeNameEqual(cur, "model")) { model =3D virXMLPropString(cur, "type"); - } else if (xmlStrEqual(cur->name, BAD_CAST "driver")) { + } else if (virXMLNodeNameEqual(cur, "driver")) { backend =3D virXMLPropString(cur, "name"); txmode =3D virXMLPropString(cur, "txmode"); ioeventfd =3D virXMLPropString(cur, "ioeventfd"); @@ -9984,7 +9984,7 @@ virDomainNetDefParseXML(virDomainXMLOptionPtr xmlopt, queues =3D virXMLPropString(cur, "queues"); rx_queue_size =3D virXMLPropString(cur, "rx_queue_size"); tx_queue_size =3D virXMLPropString(cur, "tx_queue_size"); - } else if (xmlStrEqual(cur->name, BAD_CAST "filterref")) { + } else if (virXMLNodeNameEqual(cur, "filterref")) { if (filter) { virReportError(VIR_ERR_XML_ERROR, "%s", _("Invalid specification of multiple s " @@ -9995,28 +9995,28 @@ virDomainNetDefParseXML(virDomainXMLOptionPtr xmlop= t, virNWFilterHashTableFree(filterparams); filterparams =3D virNWFilterParseParamAttributes(cur); } else if ((flags & VIR_DOMAIN_DEF_PARSE_STATUS) && - xmlStrEqual(cur->name, BAD_CAST "state")) { + virXMLNodeNameEqual(cur, "state")) { /* Legacy back-compat. Don't add any more attributes here = */ devaddr =3D virXMLPropString(cur, "devaddr"); - } else if (xmlStrEqual(cur->name, BAD_CAST "boot")) { + } else if (virXMLNodeNameEqual(cur, "boot")) { /* boot is parsed as part of virDomainDeviceInfoParseXML */ } else if (!actual && (flags & VIR_DOMAIN_DEF_PARSE_ACTUAL_NET) && def->type =3D=3D VIR_DOMAIN_NET_TYPE_NETWORK && - xmlStrEqual(cur->name, BAD_CAST "actual")) { + virXMLNodeNameEqual(cur, "actual")) { if (virDomainActualNetDefParseXML(cur, ctxt, def, &actual, flags) < 0) { goto error; } - } else if (xmlStrEqual(cur->name, BAD_CAST "bandwidth")) { + } else if (virXMLNodeNameEqual(cur, "bandwidth")) { if (virNetDevBandwidthParse(&def->bandwidth, cur, def->type) < 0) goto error; - } else if (xmlStrEqual(cur->name, BAD_CAST "vlan")) { + } else if (virXMLNodeNameEqual(cur, "vlan")) { if (virNetDevVlanParse(cur, ctxt, &def->vlan) < 0) goto error; - } else if (xmlStrEqual(cur->name, BAD_CAST "backend")) { + } else if (virXMLNodeNameEqual(cur, "backend")) { char *tmp =3D NULL; =20 if ((tmp =3D virXMLPropString(cur, "tap"))) @@ -10823,7 +10823,7 @@ virDomainChrSourceDefParseXML(virDomainChrSourceDef= Ptr def, =20 while (cur !=3D NULL) { if (cur->type =3D=3D XML_ELEMENT_NODE) { - if (xmlStrEqual(cur->name, BAD_CAST "source")) { + if (virXMLNodeNameEqual(cur, "source")) { if (!mode) mode =3D virXMLPropString(cur, "mode"); if (!haveTLS) @@ -10904,12 +10904,12 @@ virDomainChrSourceDefParseXML(virDomainChrSourceD= efPtr def, } ctxt->node =3D saved_node; } - } else if (xmlStrEqual(cur->name, BAD_CAST "log")) { + } else if (virXMLNodeNameEqual(cur, "log")) { if (!logfile) logfile =3D virXMLPropString(cur, "file"); if (!logappend) logappend =3D virXMLPropString(cur, "append"); - } else if (xmlStrEqual(cur->name, BAD_CAST "protocol")) { + } else if (virXMLNodeNameEqual(cur, "protocol")) { if (!protocol) protocol =3D virXMLPropString(cur, "type"); } else { @@ -11239,7 +11239,7 @@ virDomainChrDefParseXML(virDomainXMLOptionPtr xmlop= t, cur =3D node->children; while (cur !=3D NULL) { if (cur->type =3D=3D XML_ELEMENT_NODE) { - if (xmlStrEqual(cur->name, BAD_CAST "target")) { + if (virXMLNodeNameEqual(cur, "target")) { seenTarget =3D true; if (virDomainChrDefParseTargetXML(def, cur, flags) < 0) goto error; @@ -11331,7 +11331,7 @@ virDomainSmartcardDefParseXML(virDomainXMLOptionPtr= xmlopt, cur =3D node->children; while (cur) { if (cur->type =3D=3D XML_ELEMENT_NODE && - xmlStrEqual(cur->name, BAD_CAST "certificate")) { + virXMLNodeNameEqual(cur, "certificate")) { if (i =3D=3D 3) { virReportError(VIR_ERR_XML_ERROR, "%s", _("host-certificates mode needs " @@ -11345,7 +11345,7 @@ virDomainSmartcardDefParseXML(virDomainXMLOptionPtr= xmlopt, } i++; } else if (cur->type =3D=3D XML_ELEMENT_NODE && - xmlStrEqual(cur->name, BAD_CAST "database") && + virXMLNodeNameEqual(cur, "database") && !def->data.cert.database) { def->data.cert.database =3D (char *)xmlNodeGetContent(cur); if (!def->data.cert.database) { @@ -12477,7 +12477,7 @@ virDomainGraphicsDefParseXMLSpice(virDomainGraphics= DefPtr def, cur =3D node->children; while (cur !=3D NULL) { if (cur->type =3D=3D XML_ELEMENT_NODE) { - if (xmlStrEqual(cur->name, BAD_CAST "channel")) { + if (virXMLNodeNameEqual(cur, "channel")) { char *name, *mode; int nameval, modeval; name =3D virXMLPropString(cur, "name"); @@ -12511,7 +12511,7 @@ virDomainGraphicsDefParseXMLSpice(virDomainGraphics= DefPtr def, VIR_FREE(mode); =20 def->data.spice.channels[nameval] =3D modeval; - } else if (xmlStrEqual(cur->name, BAD_CAST "image")) { + } else if (virXMLNodeNameEqual(cur, "image")) { char *compression =3D virXMLPropString(cur, "compression"); int compressionVal; =20 @@ -12532,7 +12532,7 @@ virDomainGraphicsDefParseXMLSpice(virDomainGraphics= DefPtr def, VIR_FREE(compression); =20 def->data.spice.image =3D compressionVal; - } else if (xmlStrEqual(cur->name, BAD_CAST "jpeg")) { + } else if (virXMLNodeNameEqual(cur, "jpeg")) { char *compression =3D virXMLPropString(cur, "compression"); int compressionVal; =20 @@ -12553,7 +12553,7 @@ virDomainGraphicsDefParseXMLSpice(virDomainGraphics= DefPtr def, VIR_FREE(compression); =20 def->data.spice.jpeg =3D compressionVal; - } else if (xmlStrEqual(cur->name, BAD_CAST "zlib")) { + } else if (virXMLNodeNameEqual(cur, "zlib")) { char *compression =3D virXMLPropString(cur, "compression"); int compressionVal; =20 @@ -12574,7 +12574,7 @@ virDomainGraphicsDefParseXMLSpice(virDomainGraphics= DefPtr def, VIR_FREE(compression); =20 def->data.spice.zlib =3D compressionVal; - } else if (xmlStrEqual(cur->name, BAD_CAST "playback")) { + } else if (virXMLNodeNameEqual(cur, "playback")) { char *compression =3D virXMLPropString(cur, "compression"); int compressionVal; =20 @@ -12595,7 +12595,7 @@ virDomainGraphicsDefParseXMLSpice(virDomainGraphics= DefPtr def, VIR_FREE(compression); =20 def->data.spice.playback =3D compressionVal; - } else if (xmlStrEqual(cur->name, BAD_CAST "streaming")) { + } else if (virXMLNodeNameEqual(cur, "streaming")) { char *mode =3D virXMLPropString(cur, "mode"); int modeVal; =20 @@ -12615,7 +12615,7 @@ virDomainGraphicsDefParseXMLSpice(virDomainGraphics= DefPtr def, VIR_FREE(mode); =20 def->data.spice.streaming =3D modeVal; - } else if (xmlStrEqual(cur->name, BAD_CAST "clipboard")) { + } else if (virXMLNodeNameEqual(cur, "clipboard")) { char *copypaste =3D virXMLPropString(cur, "copypaste"); int copypasteVal; =20 @@ -12635,7 +12635,7 @@ virDomainGraphicsDefParseXMLSpice(virDomainGraphics= DefPtr def, VIR_FREE(copypaste); =20 def->data.spice.copypaste =3D copypasteVal; - } else if (xmlStrEqual(cur->name, BAD_CAST "filetransfer")) { + } else if (virXMLNodeNameEqual(cur, "filetransfer")) { char *enable =3D virXMLPropString(cur, "enable"); int enableVal; =20 @@ -12655,7 +12655,7 @@ virDomainGraphicsDefParseXMLSpice(virDomainGraphics= DefPtr def, VIR_FREE(enable); =20 def->data.spice.filetransfer =3D enableVal; - } else if (xmlStrEqual(cur->name, BAD_CAST "gl")) { + } else if (virXMLNodeNameEqual(cur, "gl")) { char *enable =3D virXMLPropString(cur, "enable"); char *rendernode =3D virXMLPropString(cur, "rendernode"); int enableVal; @@ -12680,7 +12680,7 @@ virDomainGraphicsDefParseXMLSpice(virDomainGraphics= DefPtr def, def->data.spice.gl =3D enableVal; def->data.spice.rendernode =3D rendernode; =20 - } else if (xmlStrEqual(cur->name, BAD_CAST "mouse")) { + } else if (virXMLNodeNameEqual(cur, "mouse")) { char *mode =3D virXMLPropString(cur, "mode"); int modeVal; =20 @@ -13237,7 +13237,7 @@ virSysinfoBIOSParseXML(xmlNodePtr node, int ret =3D -1; virSysinfoBIOSDefPtr def; =20 - if (!xmlStrEqual(node->name, BAD_CAST "bios")) { + if (!virXMLNodeNameEqual(node, "bios")) { virReportError(VIR_ERR_XML_ERROR, "%s", _("XML does not contain expected 'bios' element")); return ret; @@ -13299,7 +13299,7 @@ virSysinfoSystemParseXML(xmlNodePtr node, virSysinfoSystemDefPtr def; char *tmpUUID =3D NULL; =20 - if (!xmlStrEqual(node->name, BAD_CAST "system")) { + if (!virXMLNodeNameEqual(node, "system")) { virReportError(VIR_ERR_XML_ERROR, "%s", _("XML does not contain expected 'system' element")= ); return ret; @@ -13427,7 +13427,7 @@ virSysinfoParseXML(xmlNodePtr node, xmlNodePtr oldnode, tmpnode; char *type; =20 - if (!xmlStrEqual(node->name, BAD_CAST "sysinfo")) { + if (!virXMLNodeNameEqual(node, "sysinfo")) { virReportError(VIR_ERR_XML_ERROR, "%s", _("XML does not contain expected 'sysinfo' element"= )); return NULL; @@ -13564,7 +13564,7 @@ virDomainVideoAccelDefParseXML(xmlNodePtr node) while (cur !=3D NULL) { if (cur->type =3D=3D XML_ELEMENT_NODE) { if (!accel3d && !accel2d && - xmlStrEqual(cur->name, BAD_CAST "acceleration")) { + virXMLNodeNameEqual(cur, "acceleration")) { accel3d =3D virXMLPropString(cur, "accel3d"); accel2d =3D virXMLPropString(cur, "accel2d"); } @@ -13614,7 +13614,7 @@ virDomainVideoDriverDefParseXML(xmlNodePtr node) while (cur !=3D NULL) { if (cur->type =3D=3D XML_ELEMENT_NODE) { if (!vgaconf && - xmlStrEqual(cur->name, BAD_CAST "driver")) { + virXMLNodeNameEqual(cur, "driver")) { vgaconf =3D virXMLPropString(cur, "vgaconf"); } } @@ -13665,7 +13665,7 @@ virDomainVideoDefParseXML(xmlNodePtr node, while (cur !=3D NULL) { if (cur->type =3D=3D XML_ELEMENT_NODE) { if (!type && !vram && !ram && !heads && - xmlStrEqual(cur->name, BAD_CAST "model")) { + virXMLNodeNameEqual(cur, "model")) { type =3D virXMLPropString(cur, "type"); ram =3D virXMLPropString(cur, "ram"); vram =3D virXMLPropString(cur, "vram"); @@ -14516,10 +14516,10 @@ virDomainDeviceDefParse(const char *xmlStr, if ((dev->type =3D virDomainDeviceTypeFromString((const char *) node->= name)) < 0) { /* Some crazy mapping of serial, parallel, console and channel to * VIR_DOMAIN_DEVICE_CHR. */ - if (xmlStrEqual(node->name, BAD_CAST "channel") || - xmlStrEqual(node->name, BAD_CAST "console") || - xmlStrEqual(node->name, BAD_CAST "parallel") || - xmlStrEqual(node->name, BAD_CAST "serial")) { + if (virXMLNodeNameEqual(node, "channel") || + virXMLNodeNameEqual(node, "console") || + virXMLNodeNameEqual(node, "parallel") || + virXMLNodeNameEqual(node, "serial")) { dev->type =3D VIR_DOMAIN_DEVICE_CHR; } else { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, @@ -14681,7 +14681,7 @@ virDomainDiskDefSourceParse(const char *xmlStr, goto cleanup; node =3D ctxt->node; =20 - if (!xmlStrEqual(node->name, BAD_CAST "disk")) { + if (!virXMLNodeNameEqual(node, "disk")) { virReportError(VIR_ERR_XML_ERROR, _("expecting root element of 'disk', not '%s'"), node->name); @@ -19044,7 +19044,7 @@ virDomainDefParseNode(xmlDocPtr xml, xmlXPathContextPtr ctxt =3D NULL; virDomainDefPtr def =3D NULL; =20 - if (!xmlStrEqual(root->name, BAD_CAST "domain")) { + if (!virXMLNodeNameEqual(root, "domain")) { virReportError(VIR_ERR_XML_ERROR, _("unexpected root element <%s>, " "expecting "), @@ -19077,7 +19077,7 @@ virDomainObjParseNode(xmlDocPtr xml, xmlXPathContextPtr ctxt =3D NULL; virDomainObjPtr obj =3D NULL; =20 - if (!xmlStrEqual(root->name, BAD_CAST "domstatus")) { + if (!virXMLNodeNameEqual(root, "domstatus")) { virReportError(VIR_ERR_XML_ERROR, _("unexpected root element <%s>, " "expecting "), diff --git a/src/conf/interface_conf.c b/src/conf/interface_conf.c index 8c46cf52d6..0a4b28f489 100644 --- a/src/conf/interface_conf.c +++ b/src/conf/interface_conf.c @@ -824,7 +824,7 @@ virInterfaceDefParseNode(xmlDocPtr xml, xmlXPathContextPtr ctxt =3D NULL; virInterfaceDefPtr def =3D NULL; =20 - if (!xmlStrEqual(root->name, BAD_CAST "interface")) { + if (!virXMLNodeNameEqual(root, "interface")) { virReportError(VIR_ERR_XML_ERROR, _("unexpected root element <%s>, " "expecting "), diff --git a/src/conf/netdev_bandwidth_conf.c b/src/conf/netdev_bandwidth_c= onf.c index 50138fd29f..80b113196a 100644 --- a/src/conf/netdev_bandwidth_conf.c +++ b/src/conf/netdev_bandwidth_conf.c @@ -125,7 +125,7 @@ virNetDevBandwidthParse(virNetDevBandwidthPtr *bandwidt= h, if (VIR_ALLOC(def) < 0) return ret; =20 - if (!node || !xmlStrEqual(node->name, BAD_CAST "bandwidth")) { + if (!node || !virXMLNodeNameEqual(node, "bandwidth")) { virReportError(VIR_ERR_INVALID_ARG, "%s", _("invalid argument supplied")); goto cleanup; @@ -135,7 +135,7 @@ virNetDevBandwidthParse(virNetDevBandwidthPtr *bandwidt= h, =20 while (cur) { if (cur->type =3D=3D XML_ELEMENT_NODE) { - if (xmlStrEqual(cur->name, BAD_CAST "inbound")) { + if (virXMLNodeNameEqual(cur, "inbound")) { if (in) { virReportError(VIR_ERR_XML_DETAIL, "%s", _("Only one child " @@ -143,7 +143,7 @@ virNetDevBandwidthParse(virNetDevBandwidthPtr *bandwidt= h, goto cleanup; } in =3D cur; - } else if (xmlStrEqual(cur->name, BAD_CAST "outbound")) { + } else if (virXMLNodeNameEqual(cur, "outbound")) { if (out) { virReportError(VIR_ERR_XML_DETAIL, "%s", _("Only one child " diff --git a/src/conf/netdev_vport_profile_conf.c b/src/conf/netdev_vport_p= rofile_conf.c index 1641a3e01e..58a50793c2 100644 --- a/src/conf/netdev_vport_profile_conf.c +++ b/src/conf/netdev_vport_profile_conf.c @@ -61,7 +61,7 @@ virNetDevVPortProfileParse(xmlNodePtr node, unsigned int = flags) } =20 while (cur !=3D NULL) { - if (xmlStrEqual(cur->name, BAD_CAST "parameters")) { + if (virXMLNodeNameEqual(cur, "parameters")) { virtPortManagerID =3D virXMLPropString(cur, "managerid"); virtPortTypeID =3D virXMLPropString(cur, "typeid"); virtPortTypeIDVersion =3D virXMLPropString(cur, "typeidversion= "); diff --git a/src/conf/network_conf.c b/src/conf/network_conf.c index 3ebf67ff5c..54109a3d2e 100644 --- a/src/conf/network_conf.c +++ b/src/conf/network_conf.c @@ -529,7 +529,7 @@ virNetworkDHCPDefParseXML(const char *networkName, cur =3D node->children; while (cur !=3D NULL) { if (cur->type =3D=3D XML_ELEMENT_NODE && - xmlStrEqual(cur->name, BAD_CAST "range")) { + virXMLNodeNameEqual(cur, "range")) { =20 if (virSocketAddrRangeParseXML(networkName, def, cur, &range) = < 0) goto cleanup; @@ -537,7 +537,7 @@ virNetworkDHCPDefParseXML(const char *networkName, goto cleanup; =20 } else if (cur->type =3D=3D XML_ELEMENT_NODE && - xmlStrEqual(cur->name, BAD_CAST "host")) { + virXMLNodeNameEqual(cur, "host")) { =20 if (virNetworkDHCPHostDefParseXML(networkName, def, cur, &host, false) < 0) @@ -547,7 +547,7 @@ virNetworkDHCPDefParseXML(const char *networkName, =20 } else if (VIR_SOCKET_ADDR_IS_FAMILY(&def->address, AF_INET) && cur->type =3D=3D XML_ELEMENT_NODE && - xmlStrEqual(cur->name, BAD_CAST "bootp")) { + virXMLNodeNameEqual(cur, "bootp")) { char *file; char *server; virSocketAddr inaddr; @@ -609,7 +609,7 @@ virNetworkDNSHostDefParseXML(const char *networkName, cur =3D node->children; while (cur !=3D NULL) { if (cur->type =3D=3D XML_ELEMENT_NODE && - xmlStrEqual(cur->name, BAD_CAST "hostname")) { + virXMLNodeNameEqual(cur, "hostname")) { if (cur->children !=3D NULL) { char *name =3D (char *) xmlNodeGetContent(cur); =20 @@ -2034,7 +2034,7 @@ virNetworkDefParseNode(xmlDocPtr xml, xmlXPathContextPtr ctxt =3D NULL; virNetworkDefPtr def =3D NULL; =20 - if (!xmlStrEqual(root->name, BAD_CAST "network")) { + if (!virXMLNodeNameEqual(root, "network")) { virReportError(VIR_ERR_XML_ERROR, _("unexpected root element <%s>, " "expecting "), @@ -2702,7 +2702,7 @@ virNetworkDefUpdateCheckElementName(virNetworkDefPtr = def, xmlNodePtr node, const char *section) { - if (!xmlStrEqual(node->name, BAD_CAST section)) { + if (!virXMLNodeNameEqual(node, section)) { virReportError(VIR_ERR_XML_ERROR, _("unexpected element <%s>, expecting <%s>, " "while updating network '%s'"), diff --git a/src/conf/node_device_conf.c b/src/conf/node_device_conf.c index 726bf042c8..bf84fd2b37 100644 --- a/src/conf/node_device_conf.c +++ b/src/conf/node_device_conf.c @@ -2047,7 +2047,7 @@ virNodeDeviceDefParseNode(xmlDocPtr xml, xmlXPathContextPtr ctxt =3D NULL; virNodeDeviceDefPtr def =3D NULL; =20 - if (!xmlStrEqual(root->name, BAD_CAST "device")) { + if (!virXMLNodeNameEqual(root, "device")) { virReportError(VIR_ERR_XML_ERROR, _("unexpected root element <%s> " "expecting "), diff --git a/src/conf/nwfilter_conf.c b/src/conf/nwfilter_conf.c index cb251b0344..5d6423e060 100644 --- a/src/conf/nwfilter_conf.c +++ b/src/conf/nwfilter_conf.c @@ -2452,7 +2452,7 @@ virNWFilterRuleParse(xmlNodePtr node) if (found) i =3D found_i; =20 - if (xmlStrEqual(cur->name, BAD_CAST virAttr[i].id)) { + if (virXMLNodeNameEqual(cur, virAttr[i].id)) { =20 found_i =3D i; found =3D true; @@ -2668,12 +2668,12 @@ virNWFilterDefParseXML(xmlXPathContextPtr ctxt) if (VIR_ALLOC(entry) < 0) goto cleanup; =20 - if (xmlStrEqual(curr->name, BAD_CAST "rule")) { + if (virXMLNodeNameEqual(curr, "rule")) { if (!(entry->rule =3D virNWFilterRuleParse(curr))) { virNWFilterEntryFree(entry); goto cleanup; } - } else if (xmlStrEqual(curr->name, BAD_CAST "filterref")) { + } else if (virXMLNodeNameEqual(curr, "filterref")) { if (!(entry->include =3D virNWFilterIncludeParse(curr))) { virNWFilterEntryFree(entry); goto cleanup; diff --git a/src/conf/nwfilter_params.c b/src/conf/nwfilter_params.c index 496ffdabf8..3a01049182 100644 --- a/src/conf/nwfilter_params.c +++ b/src/conf/nwfilter_params.c @@ -810,7 +810,7 @@ virNWFilterParseParamAttributes(xmlNodePtr cur) =20 while (cur !=3D NULL) { if (cur->type =3D=3D XML_ELEMENT_NODE) { - if (xmlStrEqual(cur->name, BAD_CAST "parameter")) { + if (virXMLNodeNameEqual(cur, "parameter")) { nam =3D virXMLPropString(cur, "name"); val =3D virXMLPropString(cur, "value"); value =3D NULL; diff --git a/src/conf/secret_conf.c b/src/conf/secret_conf.c index 985bae47ed..bd085b7e41 100644 --- a/src/conf/secret_conf.c +++ b/src/conf/secret_conf.c @@ -131,7 +131,7 @@ secretXMLParseNode(xmlDocPtr xml, xmlNodePtr root) char *prop =3D NULL; char *uuidstr =3D NULL; =20 - if (!xmlStrEqual(root->name, BAD_CAST "secret")) { + if (!virXMLNodeNameEqual(root, "secret")) { virReportError(VIR_ERR_XML_ERROR, _("unexpected root element <%s>, " "expecting "), diff --git a/src/conf/snapshot_conf.c b/src/conf/snapshot_conf.c index 6330f7d1f9..5a07d3734a 100644 --- a/src/conf/snapshot_conf.c +++ b/src/conf/snapshot_conf.c @@ -394,7 +394,7 @@ virDomainSnapshotDefParseNode(xmlDocPtr xml, xmlXPathContextPtr ctxt =3D NULL; virDomainSnapshotDefPtr def =3D NULL; =20 - if (!xmlStrEqual(root->name, BAD_CAST "domainsnapshot")) { + if (!virXMLNodeNameEqual(root, "domainsnapshot")) { virReportError(VIR_ERR_XML_ERROR, "%s", _("domainsnapshot")); goto cleanup; } diff --git a/src/conf/storage_conf.c b/src/conf/storage_conf.c index b66e67254a..c35fa0e15c 100644 --- a/src/conf/storage_conf.c +++ b/src/conf/storage_conf.c @@ -823,7 +823,7 @@ virStoragePoolDefParseNode(xmlDocPtr xml, xmlXPathContextPtr ctxt =3D NULL; virStoragePoolDefPtr def =3D NULL; =20 - if (!xmlStrEqual(root->name, BAD_CAST "pool")) { + if (!virXMLNodeNameEqual(root, "pool")) { virReportError(VIR_ERR_XML_ERROR, _("unexpected root element <%s>, " "expecting "), @@ -1267,7 +1267,7 @@ virStorageVolDefParseNode(virStoragePoolDefPtr pool, xmlXPathContextPtr ctxt =3D NULL; virStorageVolDefPtr def =3D NULL; =20 - if (!xmlStrEqual(root->name, BAD_CAST "volume")) { + if (!virXMLNodeNameEqual(root, "volume")) { virReportError(VIR_ERR_XML_ERROR, _("unexpected root element <%s>, " "expecting "), diff --git a/src/conf/virnetworkobj.c b/src/conf/virnetworkobj.c index d8eca1e90a..d2a23e6307 100644 --- a/src/conf/virnetworkobj.c +++ b/src/conf/virnetworkobj.c @@ -684,7 +684,7 @@ virNetworkLoadState(virNetworkObjListPtr nets, =20 /* now parse possible status data */ node =3D xmlDocGetRootElement(xml); - if (xmlStrEqual(node->name, BAD_CAST "networkstatus")) { + if (virXMLNodeNameEqual(node, "networkstatus")) { /* Newer network status file. Contains useful * info which are not to be found in bare config XML */ char *class_id =3D NULL; diff --git a/src/conf/virsavecookie.c b/src/conf/virsavecookie.c index 502c04d0f4..37a3808481 100644 --- a/src/conf/virsavecookie.c +++ b/src/conf/virsavecookie.c @@ -39,7 +39,7 @@ virSaveCookieParseNode(xmlXPathContextPtr ctxt, { *obj =3D NULL; =20 - if (!xmlStrEqual(ctxt->node->name, BAD_CAST "cookie")) { + if (!virXMLNodeNameEqual(ctxt->node, "cookie")) { virReportError(VIR_ERR_XML_ERROR, "%s", _("XML does not contain expected 'cookie' element")= ); return -1; diff --git a/src/esx/esx_vi_types.c b/src/esx/esx_vi_types.c index 6b558e59fb..3ad2ba2922 100644 --- a/src/esx/esx_vi_types.c +++ b/src/esx/esx_vi_types.c @@ -33,6 +33,7 @@ #include "esx_vi.h" #include "esx_vi_types.h" #include "virstring.h" +#include "virxml.h" =20 #define VIR_FROM_THIS VIR_FROM_ESX =20 @@ -437,7 +438,7 @@ VIR_LOG_INIT("esx.esx_vi_types"); =20 =20 #define ESX_VI__TEMPLATE__PROPERTY__DESERIALIZE(_type, _name) = \ - if (xmlStrEqual(childNode->name, BAD_CAST #_name)) { = \ + if (virXMLNodeNameEqual(childNode, #_name)) { \ if (esxVI_##_type##_Deserialize(childNode, &(*ptrptr)->_name) < 0)= { \ goto failure; = \ } = \ @@ -448,14 +449,14 @@ VIR_LOG_INIT("esx.esx_vi_types"); =20 =20 #define ESX_VI__TEMPLATE__PROPERTY__DESERIALIZE_IGNORE(_name) = \ - if (xmlStrEqual(childNode->name, BAD_CAST #_name)) { = \ + if (virXMLNodeNameEqual(childNode, #_name)) { \ continue; = \ } =20 =20 =20 #define ESX_VI__TEMPLATE__PROPERTY__DESERIALIZE_VALUE(_type, _name) = \ - if (xmlStrEqual(childNode->name, BAD_CAST #_name)) { = \ + if (virXMLNodeNameEqual(childNode, #_name)) { \ if (esxVI_##_type##_DeserializeValue(childNode, = \ &(*ptrptr)->_name) < 0) { = \ goto failure; = \ @@ -467,7 +468,7 @@ VIR_LOG_INIT("esx.esx_vi_types"); =20 =20 #define ESX_VI__TEMPLATE__PROPERTY__DESERIALIZE_LIST(_type, _name) = \ - if (xmlStrEqual(childNode->name, BAD_CAST #_name)) { = \ + if (virXMLNodeNameEqual(childNode, #_name)) { \ esxVI_##_type *_name##Item =3D NULL; = \ = \ if (esxVI_##_type##_Deserialize(childNode, &_name##Item) < 0) { = \ diff --git a/src/security/virt-aa-helper.c b/src/security/virt-aa-helper.c index 35dcb35bc4..209ffaefb7 100644 --- a/src/security/virt-aa-helper.c +++ b/src/security/virt-aa-helper.c @@ -616,7 +616,7 @@ caps_mockup(vahControl * ctl, const char *xmlStr) goto cleanup; } =20 - if (!xmlStrEqual(ctxt->node->name, BAD_CAST "domain")) { + if (!virXMLNodeNameEqual(ctxt->node, "domain")) { vah_error(NULL, 0, _("unexpected root element, expecting "= )); goto cleanup; } diff --git a/src/test/test_driver.c b/src/test/test_driver.c index bf1344b968..493460cc90 100644 --- a/src/test/test_driver.c +++ b/src/test/test_driver.c @@ -1232,7 +1232,7 @@ testOpenParse(testDriverPtr privconn, const char *file, xmlXPathContextPtr ctxt) { - if (!xmlStrEqual(ctxt->node->name, BAD_CAST "node")) { + if (!virXMLNodeNameEqual(ctxt->node, "node")) { virReportError(VIR_ERR_XML_ERROR, "%s", _("Root element is not 'node'")); goto error; diff --git a/src/vz/vz_sdk.c b/src/vz/vz_sdk.c index c5f11a4fcd..52e18292df 100644 --- a/src/vz/vz_sdk.c +++ b/src/vz/vz_sdk.c @@ -4676,7 +4676,7 @@ prlsdkParseSnapshotTree(const char *treexml) goto cleanup; =20 root =3D xmlDocGetRootElement(xml); - if (!xmlStrEqual(root->name, BAD_CAST "ParallelsSavedStates")) { + if (!virXMLNodeNameEqual(root, "ParallelsSavedStates")) { virReportError(VIR_ERR_INTERNAL_ERROR, _("unexpected root element: '%s'"), root->name); goto cleanup; diff --git a/tools/virsh-domain.c b/tools/virsh-domain.c index 512804ccc2..40f1673866 100644 --- a/tools/virsh-domain.c +++ b/tools/virsh-domain.c @@ -3061,7 +3061,7 @@ cmdDomIfSetLink(vshControl *ctl, const vshCmd *cmd) =20 while (cur) { if (cur->type =3D=3D XML_ELEMENT_NODE && - xmlStrEqual(cur->name, BAD_CAST element)) { + virXMLNodeNameEqual(cur, element)) { value =3D virXMLPropString(cur, attr); =20 if (STRCASEEQ(value, iface)) { @@ -3084,7 +3084,7 @@ cmdDomIfSetLink(vshControl *ctl, const vshCmd *cmd) =20 while (cur) { if (cur->type =3D=3D XML_ELEMENT_NODE && - xmlStrEqual(cur->name, BAD_CAST "link")) { + virXMLNodeNameEqual(cur, "link")) { /* found, just modify the property */ xmlSetProp(cur, BAD_CAST "state", BAD_CAST state); =20 @@ -11704,7 +11704,7 @@ virshDomainDetachInterface(char *doc, cur =3D obj->nodesetval->nodeTab[i]->children; while (cur !=3D NULL) { if (cur->type =3D=3D XML_ELEMENT_NODE && - xmlStrEqual(cur->name, BAD_CAST "mac")) { + virXMLNodeNameEqual(cur, "mac")) { char *tmp_mac =3D virXMLPropString(cur, "address"); diff_mac =3D virMacAddrCompare(tmp_mac, mac); VIR_FREE(tmp_mac); @@ -11859,7 +11859,7 @@ virshFindDisk(const char *doc, is_supported =3D false; =20 /* Check if the disk is CDROM or floppy disk */ - if (xmlStrEqual(n->name, BAD_CAST "disk")) { + if (virXMLNodeNameEqual(n, "disk")) { char *device_value =3D virXMLPropString(n, "device"); =20 if (STREQ(device_value, "cdrom") || @@ -11878,13 +11878,13 @@ virshFindDisk(const char *doc, if (cur->type =3D=3D XML_ELEMENT_NODE) { char *tmp =3D NULL; =20 - if (xmlStrEqual(cur->name, BAD_CAST "source")) { + if (virXMLNodeNameEqual(cur, "source")) { if ((tmp =3D virXMLPropString(cur, "file")) || (tmp =3D virXMLPropString(cur, "dev")) || (tmp =3D virXMLPropString(cur, "dir")) || (tmp =3D virXMLPropString(cur, "name"))) { } - } else if (xmlStrEqual(cur->name, BAD_CAST "target")) { + } else if (virXMLNodeNameEqual(cur, "target")) { tmp =3D virXMLPropString(cur, "dev"); } =20 @@ -11963,13 +11963,13 @@ virshUpdateDiskXML(xmlNodePtr disk_node, if (tmp->type !=3D XML_ELEMENT_NODE) continue; =20 - if (xmlStrEqual(tmp->name, BAD_CAST "source")) + if (virXMLNodeNameEqual(tmp, "source")) source =3D tmp; =20 - if (xmlStrEqual(tmp->name, BAD_CAST "target")) + if (virXMLNodeNameEqual(tmp, "target")) target_node =3D tmp; =20 - if (xmlStrEqual(tmp->name, BAD_CAST "backingStore")) + if (virXMLNodeNameEqual(tmp, "backingStore")) backingStore =3D tmp; =20 /* diff --git a/tools/virsh-interface.c b/tools/virsh-interface.c index 9f7d1bd0d4..25e21710f6 100644 --- a/tools/virsh-interface.c +++ b/tools/virsh-interface.c @@ -939,9 +939,9 @@ cmdInterfaceBridge(vshControl *ctl, const vshCmd *cmd) =20 cur =3D cur->next; if ((old->type =3D=3D XML_ELEMENT_NODE) && - (xmlStrEqual(old->name, BAD_CAST "mac") || /* ethernet stuff = to move down */ - xmlStrEqual(old->name, BAD_CAST "bond") || /* bond stuff to m= ove down */ - xmlStrEqual(old->name, BAD_CAST "vlan"))) { /* vlan stuff to = move down */ + (virXMLNodeNameEqual(old, "mac") || /* ethernet stuff to move= down */ + virXMLNodeNameEqual(old, "bond") || /* bond stuff to move dow= n */ + virXMLNodeNameEqual(old, "vlan"))) { /* vlan stuff to move do= wn */ xmlUnlinkNode(old); if (!xmlAddChild(if_node, old)) { vshError(ctl, _("Failed to move '%s' element in xml docume= nt"), old->name); @@ -1130,9 +1130,9 @@ cmdInterfaceUnbridge(vshControl *ctl, const vshCmd *c= md) =20 cur =3D cur->next; if ((old->type =3D=3D XML_ELEMENT_NODE) && - (xmlStrEqual(old->name, BAD_CAST "mac") || /* ethernet stuff = to move down */ - xmlStrEqual(old->name, BAD_CAST "bond") || /* bond stuff to m= ove down */ - xmlStrEqual(old->name, BAD_CAST "vlan"))) { /* vlan stuff to = move down */ + (virXMLNodeNameEqual(old, "mac") || /* ethernet stuff to move= down */ + virXMLNodeNameEqual(old, "bond") || /* bond stuff to move dow= n */ + virXMLNodeNameEqual(old, "vlan"))) { /* vlan stuff to move do= wn */ xmlUnlinkNode(old); if (!xmlAddChild(top_node, old)) { vshError(ctl, _("Failed to move '%s' element in xml docume= nt"), old->name); --=20 2.13.5 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Sat Apr 27 12:38:25 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1502713985724559.3786057636648; Mon, 14 Aug 2017 05:33:05 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id DECAB9D503; Mon, 14 Aug 2017 12:33:03 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id A749D7FCC6; Mon, 14 Aug 2017 12:33:03 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 58BB7180BA80; Mon, 14 Aug 2017 12:33:03 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id v7ECWsLH015533 for ; Mon, 14 Aug 2017 08:32:54 -0400 Received: by smtp.corp.redhat.com (Postfix) id 86AF16872B; Mon, 14 Aug 2017 12:32:54 +0000 (UTC) Received: from antique-work.brq.redhat.com (unknown [10.43.2.152]) by smtp.corp.redhat.com (Postfix) with ESMTP id 0FF8868738 for ; Mon, 14 Aug 2017 12:32:52 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com DECAB9D503 Authentication-Results: ext-mx10.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx10.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=libvir-list-bounces@redhat.com From: Pavel Hrdina To: libvir-list@redhat.com Date: Mon, 14 Aug 2017 14:32:42 +0200 Message-Id: <78ac13860ac92dc93c1a349a352de3d8e92ce8ce.1502713940.git.phrdina@redhat.com> In-Reply-To: References: In-Reply-To: References: X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 3/8] conf: cleanup virDomainChrSourceDef parsing X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.39]); Mon, 14 Aug 2017 12:33:04 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" The @remaining variable is leftover from old code and it's not used anymore. Signed-off-by: Pavel Hrdina --- src/conf/domain_conf.c | 23 +++++++++-------------- 1 file changed, 9 insertions(+), 14 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 37aa975eca..528d11c17d 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -10793,9 +10793,9 @@ virDomainChrDefParseTargetXML(virDomainChrDefPtr de= f, =20 /* Parse the source half of the XML definition for a character device, * where node is the first element of node->children of the parent - * element. def->type must already be valid. Return -1 on failure, - * otherwise the number of ignored children (this intentionally skips - * , which is used by but not ). */ + * element. def->type must already be valid. + * + * Return -1 on failure, 0 on success. */ static int virDomainChrSourceDefParseXML(virDomainChrSourceDefPtr def, xmlNodePtr cur, unsigned int flags, @@ -10804,6 +10804,7 @@ virDomainChrSourceDefParseXML(virDomainChrSourceDef= Ptr def, virSecurityLabelDefPtr* vmSeclabels, int nvmSeclabels) { + int ret =3D -1; char *bindHost =3D NULL; char *bindService =3D NULL; char *connectHost =3D NULL; @@ -10819,7 +10820,6 @@ virDomainChrSourceDefParseXML(virDomainChrSourceDef= Ptr def, char *append =3D NULL; char *haveTLS =3D NULL; char *tlsFromConfig =3D NULL; - int remaining =3D 0; =20 while (cur !=3D NULL) { if (cur->type =3D=3D XML_ELEMENT_NODE) { @@ -10912,8 +10912,6 @@ virDomainChrSourceDefParseXML(virDomainChrSourceDef= Ptr def, } else if (virXMLNodeNameEqual(cur, "protocol")) { if (!protocol) protocol =3D virXMLPropString(cur, "type"); - } else { - remaining++; } } cur =3D cur->next; @@ -11099,6 +11097,7 @@ virDomainChrSourceDefParseXML(virDomainChrSourceDef= Ptr def, goto error; } =20 + ret =3D 0; cleanup: VIR_FREE(mode); VIR_FREE(protocol); @@ -11114,11 +11113,10 @@ virDomainChrSourceDefParseXML(virDomainChrSourceD= efPtr def, VIR_FREE(haveTLS); VIR_FREE(tlsFromConfig); =20 - return remaining; + return ret; =20 error: virDomainChrSourceDefClear(def); - remaining =3D -1; goto cleanup; } =20 @@ -13895,7 +13893,6 @@ virDomainRedirdevDefParseXML(virDomainXMLOptionPtr = xmlopt, xmlNodePtr cur; virDomainRedirdevDefPtr def; char *bus =3D NULL, *type =3D NULL; - int remaining; =20 if (VIR_ALLOC(def) < 0) return NULL; @@ -13929,11 +13926,9 @@ virDomainRedirdevDefParseXML(virDomainXMLOptionPtr= xmlopt, =20 cur =3D node->children; /* boot gets parsed in virDomainDeviceInfoParseXML - * source gets parsed in virDomainChrSourceDefParseXML - * we don't know any of the elements that might remain */ - remaining =3D virDomainChrSourceDefParseXML(def->source, cur, flags, - NULL, NULL, NULL, 0); - if (remaining < 0) + * source gets parsed in virDomainChrSourceDefParseXML */ + if (virDomainChrSourceDefParseXML(def->source, cur, flags, + NULL, NULL, NULL, 0) < 0) goto error; =20 if (def->source->type =3D=3D VIR_DOMAIN_CHR_TYPE_SPICEVMC) --=20 2.13.5 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Sat Apr 27 12:38:25 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1502713989760360.4586873161395; Mon, 14 Aug 2017 05:33:09 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id AFCE36626C; Mon, 14 Aug 2017 12:33:07 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 83AB61823F; Mon, 14 Aug 2017 12:33:07 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 3613C14B20; Mon, 14 Aug 2017 12:33:07 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id v7ECWttX015550 for ; Mon, 14 Aug 2017 08:32:55 -0400 Received: by smtp.corp.redhat.com (Postfix) id 57F4568735; Mon, 14 Aug 2017 12:32:55 +0000 (UTC) Received: from antique-work.brq.redhat.com (unknown [10.43.2.152]) by smtp.corp.redhat.com (Postfix) with ESMTP id D452E6872B for ; Mon, 14 Aug 2017 12:32:54 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com AFCE36626C Authentication-Results: ext-mx03.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx03.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=libvir-list-bounces@redhat.com From: Pavel Hrdina To: libvir-list@redhat.com Date: Mon, 14 Aug 2017 14:32:43 +0200 Message-Id: In-Reply-To: References: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-loop: libvir-list@redhat.com Subject: [libvirt] =?utf-8?q?=5BPATCH_4/8=5D_conf=3A=C2=A0use_virXMLPropSt?= =?utf-8?q?ring_for_KeyWrapCipherDef_parsing?= 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: , Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.27]); Mon, 14 Aug 2017 12:33:08 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" XPath is good for random search of elements, not for accessing attributes of one node. Signed-off-by: Pavel Hrdina --- src/conf/domain_conf.c | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 528d11c17d..9dc788e9f9 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -933,7 +933,6 @@ virDomainXMLOptionClassDispose(void *obj) * * @def Domain definition * @node An XML cipher node - * @ctxt The XML context * * Parse the attributes from the cipher node and store the state * attribute in @def. @@ -947,8 +946,7 @@ virDomainXMLOptionClassDispose(void *obj) */ static int virDomainKeyWrapCipherDefParseXML(virDomainKeyWrapDefPtr keywrap, - xmlNodePtr node, - xmlXPathContextPtr ctxt) + xmlNodePtr node) { =20 char *name =3D NULL; @@ -956,10 +954,8 @@ virDomainKeyWrapCipherDefParseXML(virDomainKeyWrapDefP= tr keywrap, int state_type; int name_type; int ret =3D -1; - xmlNodePtr oldnode =3D ctxt->node; =20 - ctxt->node =3D node; - if (!(name =3D virXPathString("string(./@name)", ctxt))) { + if (!(name =3D virXMLPropString(node, "name"))) { virReportError(VIR_ERR_CONF_SYNTAX, "%s", _("missing name for cipher")); goto cleanup; @@ -971,7 +967,7 @@ virDomainKeyWrapCipherDefParseXML(virDomainKeyWrapDefPt= r keywrap, goto cleanup; } =20 - if (!(state =3D virXPathString("string(./@state)", ctxt))) { + if (!(state =3D virXMLPropString(node, "state"))) { virReportError(VIR_ERR_CONF_SYNTAX, _("missing state for cipher named %s"), name); goto cleanup; @@ -1017,7 +1013,6 @@ virDomainKeyWrapCipherDefParseXML(virDomainKeyWrapDef= Ptr keywrap, cleanup: VIR_FREE(name); VIR_FREE(state); - ctxt->node =3D oldnode; return ret; } =20 @@ -1036,7 +1031,7 @@ virDomainKeyWrapDefParseXML(virDomainDefPtr def, xmlX= PathContextPtr ctxt) goto cleanup; =20 for (i =3D 0; i < n; i++) { - if (virDomainKeyWrapCipherDefParseXML(def->keywrap, nodes[i], ctxt= ) < 0) + if (virDomainKeyWrapCipherDefParseXML(def->keywrap, nodes[i]) < 0) goto cleanup; } =20 --=20 2.13.5 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Sat Apr 27 12:38:25 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1502713994537227.8956464838093; Mon, 14 Aug 2017 05:33:14 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 4A71B6529; Mon, 14 Aug 2017 12:33:11 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 1EE487900F; Mon, 14 Aug 2017 12:33:11 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id C217F14B26; Mon, 14 Aug 2017 12:33:10 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id v7ECWuGo015559 for ; Mon, 14 Aug 2017 08:32:56 -0400 Received: by smtp.corp.redhat.com (Postfix) id 2923B68738; Mon, 14 Aug 2017 12:32:56 +0000 (UTC) Received: from antique-work.brq.redhat.com (unknown [10.43.2.152]) by smtp.corp.redhat.com (Postfix) with ESMTP id A44356872B for ; Mon, 14 Aug 2017 12:32:55 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 4A71B6529 Authentication-Results: ext-mx10.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx10.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=libvir-list-bounces@redhat.com From: Pavel Hrdina To: libvir-list@redhat.com Date: Mon, 14 Aug 2017 14:32:44 +0200 Message-Id: <47be6d56cd73c2a4d0a212a4d957eb0ef259df93.1502713940.git.phrdina@redhat.com> In-Reply-To: References: In-Reply-To: References: X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 5/8] conf: use virXMLPropString for disk geometry parsing X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.39]); Mon, 14 Aug 2017 12:33:11 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" XPath is good for random search of elements, not for accessing attributes of one node. Signed-off-by: Pavel Hrdina --- src/conf/domain_conf.c | 59 ++++++++++++++++++++++++++++------------------= ---- 1 file changed, 33 insertions(+), 26 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 9dc788e9f9..cb1b5b55fb 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -8029,46 +8029,53 @@ virDomainDiskDefMirrorParse(virDomainDiskDefPtr def, =20 static int virDomainDiskDefGeometryParse(virDomainDiskDefPtr def, - xmlNodePtr cur, - xmlXPathContextPtr ctxt) + xmlNodePtr cur) { - char *trans; + char *tmp; =20 - if (virXPathUInt("string(./geometry/@cyls)", - ctxt, &def->geometry.cylinders) < 0) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("invalid geometry settings (cyls)")); - return -1; + if ((tmp =3D virXMLPropString(cur, "cyls"))) { + if (virStrToLong_ui(tmp, NULL, 10, &def->geometry.cylinders) < 0) { + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("invalid geometry settings (cyls)")); + goto error; + } + VIR_FREE(tmp); } =20 - if (virXPathUInt("string(./geometry/@heads)", - ctxt, &def->geometry.heads) < 0) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("invalid geometry settings (heads)")); - return -1; + if ((tmp =3D virXMLPropString(cur, "heads"))) { + if (virStrToLong_ui(tmp, NULL, 10, &def->geometry.heads) < 0) { + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("invalid geometry settings (heads)")); + goto error; + } + VIR_FREE(tmp); } =20 - if (virXPathUInt("string(./geometry/@secs)", - ctxt, &def->geometry.sectors) < 0) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("invalid geometry settings (secs)")); - return -1; + if ((tmp =3D virXMLPropString(cur, "secs"))) { + if (virStrToLong_ui(tmp, NULL, 10, &def->geometry.sectors) < 0) { + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("invalid geometry settings (secs)")); + goto error; + } + VIR_FREE(tmp); } =20 - trans =3D virXMLPropString(cur, "trans"); - if (trans) { - def->geometry.trans =3D virDomainDiskGeometryTransTypeFromString(t= rans); + if ((tmp =3D virXMLPropString(cur, "trans"))) { + def->geometry.trans =3D virDomainDiskGeometryTransTypeFromString(t= mp); if (def->geometry.trans <=3D 0) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, _("invalid translation value '%s'"), - trans); - VIR_FREE(trans); - return -1; + tmp); + goto error; } - VIR_FREE(trans); + VIR_FREE(tmp); } =20 return 0; + + error: + VIR_FREE(tmp); + return -1; } =20 =20 @@ -8374,7 +8381,7 @@ virDomainDiskDefParseXML(virDomainXMLOptionPtr xmlopt, virXMLNodeNameEqual(cur, "backenddomain")) { domain_name =3D virXMLPropString(cur, "name"); } else if (virXMLNodeNameEqual(cur, "geometry")) { - if (virDomainDiskDefGeometryParse(def, cur, ctxt) < 0) + if (virDomainDiskDefGeometryParse(def, cur) < 0) goto error; } else if (virXMLNodeNameEqual(cur, "blockio")) { logical_block_size =3D --=20 2.13.5 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Sat Apr 27 12:38:25 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1502713987772104.0870417915711; Mon, 14 Aug 2017 05:33:07 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id A7418B16C; Mon, 14 Aug 2017 12:33:05 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 64833782CC; Mon, 14 Aug 2017 12:33:05 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 1644E180BA85; Mon, 14 Aug 2017 12:33:05 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id v7ECWuup015576 for ; Mon, 14 Aug 2017 08:32:56 -0400 Received: by smtp.corp.redhat.com (Postfix) id EC5AC68710; Mon, 14 Aug 2017 12:32:56 +0000 (UTC) Received: from antique-work.brq.redhat.com (unknown [10.43.2.152]) by smtp.corp.redhat.com (Postfix) with ESMTP id 753646872B for ; Mon, 14 Aug 2017 12:32:56 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com A7418B16C Authentication-Results: ext-mx06.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx06.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=libvir-list-bounces@redhat.com From: Pavel Hrdina To: libvir-list@redhat.com Date: Mon, 14 Aug 2017 14:32:45 +0200 Message-Id: In-Reply-To: References: In-Reply-To: References: X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 6/8] conf: use virXMLPropString for IOThread parsing X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.30]); Mon, 14 Aug 2017 12:33:06 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" XPath is good for random search of elements, not for accessing attributes of one node. Signed-off-by: Pavel Hrdina --- src/conf/domain_conf.c | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index cb1b5b55fb..6e424c96d8 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -16209,19 +16209,15 @@ virDomainIdmapDefParseXML(xmlXPathContextPtr ctxt, * */ static virDomainIOThreadIDDefPtr -virDomainIOThreadIDDefParseXML(xmlNodePtr node, - xmlXPathContextPtr ctxt) +virDomainIOThreadIDDefParseXML(xmlNodePtr node) { virDomainIOThreadIDDefPtr iothrid; - xmlNodePtr oldnode =3D ctxt->node; char *tmp =3D NULL; =20 if (VIR_ALLOC(iothrid) < 0) return NULL; =20 - ctxt->node =3D node; - - if (!(tmp =3D virXPathString("string(./@id)", ctxt))) { + if (!(tmp =3D virXMLPropString(node, "id"))) { virReportError(VIR_ERR_XML_ERROR, "%s", _("Missing 'id' attribute in element")); goto error; @@ -16235,7 +16231,6 @@ virDomainIOThreadIDDefParseXML(xmlNodePtr node, =20 cleanup: VIR_FREE(tmp); - ctxt->node =3D oldnode; return iothrid; =20 error: @@ -16275,7 +16270,7 @@ virDomainDefParseIOThreads(virDomainDefPtr def, =20 for (i =3D 0; i < n; i++) { virDomainIOThreadIDDefPtr iothrid =3D NULL; - if (!(iothrid =3D virDomainIOThreadIDDefParseXML(nodes[i], ctxt))) + if (!(iothrid =3D virDomainIOThreadIDDefParseXML(nodes[i]))) goto error; =20 if (virDomainIOThreadIDFind(def, iothrid->iothread_id)) { --=20 2.13.5 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Sat Apr 27 12:38:25 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1502713985785495.5803737532103; Mon, 14 Aug 2017 05:33:05 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id CB810C04B31B; Mon, 14 Aug 2017 12:33:03 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id A6E1F68737; Mon, 14 Aug 2017 12:33:03 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 5A44C180BA83; Mon, 14 Aug 2017 12:33:03 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id v7ECWv7k015587 for ; Mon, 14 Aug 2017 08:32:57 -0400 Received: by smtp.corp.redhat.com (Postfix) id CC6CC68710; Mon, 14 Aug 2017 12:32:57 +0000 (UTC) Received: from antique-work.brq.redhat.com (unknown [10.43.2.152]) by smtp.corp.redhat.com (Postfix) with ESMTP id 53B9678A55 for ; Mon, 14 Aug 2017 12:32:57 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com CB810C04B31B Authentication-Results: ext-mx07.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx07.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=libvir-list-bounces@redhat.com From: Pavel Hrdina To: libvir-list@redhat.com Date: Mon, 14 Aug 2017 14:32:46 +0200 Message-Id: In-Reply-To: References: In-Reply-To: References: X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 7/8] conf: use virXMLPropString for IOThread pin parsing X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.31]); Mon, 14 Aug 2017 12:33:04 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" XPath is good for random search of elements, not for accessing attributes of one node. Signed-off-by: Pavel Hrdina --- src/conf/domain_conf.c | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 6e424c96d8..23ef46dc79 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -16362,19 +16362,15 @@ virDomainVcpuPinDefParseXML(virDomainDefPtr def, */ static int virDomainIOThreadPinDefParseXML(xmlNodePtr node, - xmlXPathContextPtr ctxt, virDomainDefPtr def) { int ret =3D -1; virDomainIOThreadIDDefPtr iothrid; virBitmapPtr cpumask =3D NULL; - xmlNodePtr oldnode =3D ctxt->node; unsigned int iothreadid; char *tmp =3D NULL; =20 - ctxt->node =3D node; - - if (!(tmp =3D virXPathString("string(./@iothread)", ctxt))) { + if (!(tmp =3D virXMLPropString(node, "iothread"))) { virReportError(VIR_ERR_XML_ERROR, "%s", _("missing iothread id in iothreadpin")); goto cleanup; @@ -16430,7 +16426,6 @@ virDomainIOThreadPinDefParseXML(xmlNodePtr node, cleanup: VIR_FREE(tmp); virBitmapFree(cpumask); - ctxt->node =3D oldnode; return ret; } =20 @@ -17705,7 +17700,7 @@ virDomainDefParseXML(xmlDocPtr xml, } =20 for (i =3D 0; i < n; i++) { - if (virDomainIOThreadPinDefParseXML(nodes[i], ctxt, def) < 0) + if (virDomainIOThreadPinDefParseXML(nodes[i], def) < 0) goto error; } VIR_FREE(nodes); --=20 2.13.5 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Sat Apr 27 12:38:25 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1502713991783195.9633997266708; Mon, 14 Aug 2017 05:33:11 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id C5A137972A; Mon, 14 Aug 2017 12:33:09 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 9533C7900F; Mon, 14 Aug 2017 12:33:09 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 43FAA180BA88; Mon, 14 Aug 2017 12:33:09 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id v7ECWwoP015602 for ; Mon, 14 Aug 2017 08:32:58 -0400 Received: by smtp.corp.redhat.com (Postfix) id 9C2E768733; Mon, 14 Aug 2017 12:32:58 +0000 (UTC) Received: from antique-work.brq.redhat.com (unknown [10.43.2.152]) by smtp.corp.redhat.com (Postfix) with ESMTP id 23F8468710 for ; Mon, 14 Aug 2017 12:32:57 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com C5A137972A Authentication-Results: ext-mx02.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx02.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=libvir-list-bounces@redhat.com From: Pavel Hrdina To: libvir-list@redhat.com Date: Mon, 14 Aug 2017 14:32:47 +0200 Message-Id: <6379914e4785602d23a489393090927d06902f5b.1502713940.git.phrdina@redhat.com> In-Reply-To: References: In-Reply-To: References: X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 8/8] conf: use virXMLPropString for Domain def parsing X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.26]); Mon, 14 Aug 2017 12:33:10 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" XPath is good for random search of elements, not for accessing attributes of one node. Signed-off-by: Pavel Hrdina --- src/conf/domain_conf.c | 46 +++++++++++++--------------------------------- 1 file changed, 13 insertions(+), 33 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 23ef46dc79..281dc68f0e 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -17140,7 +17140,7 @@ virDomainDefParseBootOptions(virDomainDefPtr def, if (n =3D=3D 1) { oldnode =3D ctxt->node; ctxt->node =3D nodes[0]; - tmp =3D virXPathString("string(./@type)", ctxt); + tmp =3D virXMLPropString(nodes[0], "type"); =20 if (!tmp) { virReportError(VIR_ERR_XML_ERROR, "%s", @@ -17221,7 +17221,7 @@ virDomainDefParseXML(xmlDocPtr xml, def->id =3D (int)id; =20 /* Find out what type of virtualization to use */ - if (!(tmp =3D virXPathString("string(./@type)", ctxt))) { + if (!(tmp =3D virXMLPropString(ctxt->node, "type"))) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("missing domain type attribute")); goto error; @@ -17812,9 +17812,7 @@ virDomainDefParseXML(xmlDocPtr xml, break; =20 case VIR_DOMAIN_FEATURE_CAPABILITIES: - node =3D ctxt->node; - ctxt->node =3D nodes[i]; - if ((tmp =3D virXPathString("string(./@policy)", ctxt))) { + if ((tmp =3D virXMLPropString(nodes[i], "policy"))) { if ((def->features[val] =3D virDomainCapabilitiesPolicyTyp= eFromString(tmp)) =3D=3D -1) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, _("unknown state attribute '%s' of feat= ure '%s'"), @@ -17825,7 +17823,6 @@ virDomainDefParseXML(xmlDocPtr xml, } else { def->features[val] =3D VIR_TRISTATE_SWITCH_ABSENT; } - ctxt->node =3D node; break; =20 case VIR_DOMAIN_FEATURE_HAP: @@ -17833,9 +17830,7 @@ virDomainDefParseXML(xmlDocPtr xml, case VIR_DOMAIN_FEATURE_PVSPINLOCK: case VIR_DOMAIN_FEATURE_VMPORT: case VIR_DOMAIN_FEATURE_SMM: - node =3D ctxt->node; - ctxt->node =3D nodes[i]; - if ((tmp =3D virXPathString("string(./@state)", ctxt))) { + if ((tmp =3D virXMLPropString(nodes[i], "state"))) { if ((def->features[val] =3D virTristateSwitchTypeFromStrin= g(tmp)) =3D=3D -1) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, _("unknown state attribute '%s' of feat= ure '%s'"), @@ -17846,13 +17841,10 @@ virDomainDefParseXML(xmlDocPtr xml, } else { def->features[val] =3D VIR_TRISTATE_SWITCH_ON; } - ctxt->node =3D node; break; =20 case VIR_DOMAIN_FEATURE_GIC: - node =3D ctxt->node; - ctxt->node =3D nodes[i]; - if ((tmp =3D virXPathString("string(./@version)", ctxt))) { + if ((tmp =3D virXMLPropString(nodes[i], "version"))) { gic_version =3D virGICVersionTypeFromString(tmp); if (gic_version < 0 || gic_version =3D=3D VIR_GIC_VERSION_= NONE) { virReportError(VIR_ERR_XML_ERROR, @@ -17863,13 +17855,10 @@ virDomainDefParseXML(xmlDocPtr xml, VIR_FREE(tmp); } def->features[val] =3D VIR_TRISTATE_SWITCH_ON; - ctxt->node =3D node; break; =20 case VIR_DOMAIN_FEATURE_IOAPIC: - node =3D ctxt->node; - ctxt->node =3D nodes[i]; - tmp =3D virXPathString("string(./@driver)", ctxt); + tmp =3D virXMLPropString(nodes[i], "driver"); if (tmp) { int value =3D virDomainIOAPICTypeFromString(tmp); if (value < 0) { @@ -17882,7 +17871,6 @@ virDomainDefParseXML(xmlDocPtr xml, def->features[val] =3D VIR_TRISTATE_SWITCH_ON; VIR_FREE(tmp); } - ctxt->node =3D node; break; =20 /* coverity[dead_error_begin] */ @@ -17910,7 +17898,7 @@ virDomainDefParseXML(xmlDocPtr xml, =20 ctxt->node =3D nodes[i]; =20 - if (!(tmp =3D virXPathString("string(./@state)", ctxt))) { + if (!(tmp =3D virXMLPropString(nodes[i], "state"))) { virReportError(VIR_ERR_XML_ERROR, _("missing 'state' attribute for " "HyperV Enlightenment feature '%s'"), @@ -17962,8 +17950,8 @@ virDomainDefParseXML(xmlDocPtr xml, if (value !=3D VIR_TRISTATE_SWITCH_ON) break; =20 - if (!(def->hyperv_vendor_id =3D virXPathString("string(./@= value)", - ctxt))) { + if (!(def->hyperv_vendor_id =3D virXMLPropString(nodes[i], + "value"))) { virReportError(VIR_ERR_XML_ERROR, "%s", _("missing 'value' attribute for " "HyperV feature 'vendor_id'")); @@ -17997,7 +17985,6 @@ virDomainDefParseXML(xmlDocPtr xml, if (def->features[VIR_DOMAIN_FEATURE_KVM] =3D=3D VIR_TRISTATE_SWITCH_O= N) { int feature; int value; - node =3D ctxt->node; if ((n =3D virXPathNodeSet("./features/kvm/*", ctxt, &nodes)) < 0) goto error; =20 @@ -18010,11 +17997,9 @@ virDomainDefParseXML(xmlDocPtr xml, goto error; } =20 - ctxt->node =3D nodes[i]; - switch ((virDomainKVM) feature) { case VIR_DOMAIN_KVM_HIDDEN: - if (!(tmp =3D virXPathString("string(./@state)", ctxt)= )) { + if (!(tmp =3D virXMLPropString(nodes[i], "state"))) { virReportError(VIR_ERR_XML_ERROR, _("missing 'state' attribute for " "KVM feature '%s'"), @@ -18040,7 +18025,6 @@ virDomainDefParseXML(xmlDocPtr xml, } } VIR_FREE(nodes); - ctxt->node =3D node; } =20 if ((n =3D virXPathNodeSet("./features/capabilities/*", ctxt, &nodes))= < 0) @@ -18055,10 +18039,7 @@ virDomainDefParseXML(xmlDocPtr xml, } =20 if (val >=3D 0 && val < VIR_DOMAIN_CAPS_FEATURE_LAST) { - node =3D ctxt->node; - ctxt->node =3D nodes[i]; - - if ((tmp =3D virXPathString("string(./@state)", ctxt))) { + if ((tmp =3D virXMLPropString(nodes[i], "state"))) { if ((def->caps_features[val] =3D virTristateSwitchTypeFrom= String(tmp)) =3D=3D -1) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, _("unknown state attribute '%s' of feat= ure capability '%s'"), @@ -18069,7 +18050,6 @@ virDomainDefParseXML(xmlDocPtr xml, } else { def->caps_features[val] =3D VIR_TRISTATE_SWITCH_ON; } - ctxt->node =3D node; } } VIR_FREE(nodes); @@ -18914,7 +18894,7 @@ virDomainObjParseXML(xmlDocPtr xml, if (!obj->def) goto error; =20 - if (!(tmp =3D virXPathString("string(./@state)", ctxt))) { + if (!(tmp =3D virXMLPropString(ctxt->node, "state"))) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("missing domain state")); goto error; @@ -18927,7 +18907,7 @@ virDomainObjParseXML(xmlDocPtr xml, } VIR_FREE(tmp); =20 - if ((tmp =3D virXPathString("string(./@reason)", ctxt))) { + if ((tmp =3D virXMLPropString(ctxt->node, "reason"))) { if ((reason =3D virDomainStateReasonFromString(state, tmp)) < 0) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, _("invalid domain state reason '%s'"), tmp); --=20 2.13.5 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list