From nobody Tue Dec 16 08:05:53 2025 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 1502887277705733.4500877446561; Wed, 16 Aug 2017 05:41:17 -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 C0A667790C; Wed, 16 Aug 2017 12:41:15 +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 97AB06062D; Wed, 16 Aug 2017 12:41:15 +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 62D753FAD7; Wed, 16 Aug 2017 12:41:15 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id v7GCetR5021734 for ; Wed, 16 Aug 2017 08:40:55 -0400 Received: by smtp.corp.redhat.com (Postfix) id 3DD537D57E; Wed, 16 Aug 2017 12:40:55 +0000 (UTC) Received: from antique-work.brq.redhat.com (unknown [10.43.2.152]) by smtp.corp.redhat.com (Postfix) with ESMTP id B673B7D971 for ; Wed, 16 Aug 2017 12:40:54 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com C0A667790C 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: Wed, 16 Aug 2017 14:40:42 +0200 Message-Id: <2288dbf47616df0d9007f67c2b5076e21c1af413.1502887192.git.phrdina@redhat.com> In-Reply-To: References: In-Reply-To: References: X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 05/10] conf: use virXMLPropString for network 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.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.26]); Wed, 16 Aug 2017 12:41:16 +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 --- Notes: hint: review with -b src/conf/domain_conf.c | 223 +++++++++++++++++++++++++--------------------= ---- 1 file changed, 116 insertions(+), 107 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 4138a87f8b..90f3f55f25 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -9793,6 +9793,7 @@ virDomainNetDefParseXML(virDomainXMLOptionPtr xmlopt, virDomainNetDefPtr def; virDomainHostdevDefPtr hostdev; xmlNodePtr cur; + xmlNodePtr tmpNode; char *macaddr =3D NULL; char *type =3D NULL; char *network =3D NULL; @@ -9952,8 +9953,10 @@ virDomainNetDefParseXML(virDomainXMLOptionPtr xmlopt, if (!localaddr && def->type =3D=3D VIR_DOMAIN_NET_TYPE_UDP= ) { xmlNodePtr tmpnode =3D ctxt->node; ctxt->node =3D cur; - localaddr =3D virXPathString("string(./local/@address)= ", ctxt); - localport =3D virXPathString("string(./local/@port)", = ctxt); + if ((tmpNode =3D virXPathNode("./local", ctxt))) { + localaddr =3D virXMLPropString(tmpNode, "address"); + localport =3D virXMLPropString(tmpNode, "port"); + } ctxt->node =3D tmpnode; } } else if (!ifname && @@ -10399,124 +10402,130 @@ virDomainNetDefParseXML(virDomainXMLOptionPtr x= mlopt, } def->driver.virtio.tx_queue_size =3D q; } - if ((str =3D virXPathString("string(./driver/host/@csum)", ctxt)))= { - if ((val =3D virTristateSwitchTypeFromString(str)) <=3D 0) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, - _("unknown host csum mode '%s'"), - str); - goto error; + + if ((tmpNode =3D virXPathNode("./driver/host", ctxt))) { + if ((str =3D virXMLPropString(tmpNode, "csum"))) { + if ((val =3D virTristateSwitchTypeFromString(str)) <=3D 0)= { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("unknown host csum mode '%s'"), + str); + goto error; + } + def->driver.virtio.host.csum =3D val; } - def->driver.virtio.host.csum =3D val; - } - VIR_FREE(str); - if ((str =3D virXPathString("string(./driver/host/@gso)", ctxt))) { - if ((val =3D virTristateSwitchTypeFromString(str)) <=3D 0) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, - _("unknown host gso mode '%s'"), - str); - goto error; + VIR_FREE(str); + if ((str =3D virXMLPropString(tmpNode, "gso"))) { + if ((val =3D virTristateSwitchTypeFromString(str)) <=3D 0)= { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("unknown host gso mode '%s'"), + str); + goto error; + } + def->driver.virtio.host.gso =3D val; } - def->driver.virtio.host.gso =3D val; - } - VIR_FREE(str); - if ((str =3D virXPathString("string(./driver/host/@tso4)", ctxt)))= { - if ((val =3D virTristateSwitchTypeFromString(str)) <=3D 0) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, - _("unknown host tso4 mode '%s'"), - str); - goto error; + VIR_FREE(str); + if ((str =3D virXMLPropString(tmpNode, "tso4"))) { + if ((val =3D virTristateSwitchTypeFromString(str)) <=3D 0)= { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("unknown host tso4 mode '%s'"), + str); + goto error; + } + def->driver.virtio.host.tso4 =3D val; } - def->driver.virtio.host.tso4 =3D val; - } - VIR_FREE(str); - if ((str =3D virXPathString("string(./driver/host/@tso6)", ctxt)))= { - if ((val =3D virTristateSwitchTypeFromString(str)) <=3D 0) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, - _("unknown host tso6 mode '%s'"), - str); - goto error; + VIR_FREE(str); + if ((str =3D virXMLPropString(tmpNode, "tso6"))) { + if ((val =3D virTristateSwitchTypeFromString(str)) <=3D 0)= { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("unknown host tso6 mode '%s'"), + str); + goto error; + } + def->driver.virtio.host.tso6 =3D val; } - def->driver.virtio.host.tso6 =3D val; - } - VIR_FREE(str); - if ((str =3D virXPathString("string(./driver/host/@ecn)", ctxt))) { - if ((val =3D virTristateSwitchTypeFromString(str)) <=3D 0) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, - _("unknown host ecn mode '%s'"), - str); - goto error; + VIR_FREE(str); + if ((str =3D virXMLPropString(tmpNode, "ecn"))) { + if ((val =3D virTristateSwitchTypeFromString(str)) <=3D 0)= { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("unknown host ecn mode '%s'"), + str); + goto error; + } + def->driver.virtio.host.ecn =3D val; } - def->driver.virtio.host.ecn =3D val; - } - VIR_FREE(str); - if ((str =3D virXPathString("string(./driver/host/@ufo)", ctxt))) { - if ((val =3D virTristateSwitchTypeFromString(str)) <=3D 0) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, - _("unknown host ufo mode '%s'"), - str); - goto error; + VIR_FREE(str); + if ((str =3D virXMLPropString(tmpNode, "ufo"))) { + if ((val =3D virTristateSwitchTypeFromString(str)) <=3D 0)= { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("unknown host ufo mode '%s'"), + str); + goto error; + } + def->driver.virtio.host.ufo =3D val; } - def->driver.virtio.host.ufo =3D val; - } - VIR_FREE(str); - if ((str =3D virXPathString("string(./driver/host/@mrg_rxbuf)", ct= xt))) { - if ((val =3D virTristateSwitchTypeFromString(str)) <=3D 0) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, - _("unknown host mrg_rxbuf mode '%s'"), - str); - goto error; + VIR_FREE(str); + if ((str =3D virXMLPropString(tmpNode, "mrg_rxbuf"))) { + if ((val =3D virTristateSwitchTypeFromString(str)) <=3D 0)= { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("unknown host mrg_rxbuf mode '%s'"), + str); + goto error; + } + def->driver.virtio.host.mrg_rxbuf =3D val; } - def->driver.virtio.host.mrg_rxbuf =3D val; + VIR_FREE(str); } - VIR_FREE(str); - if ((str =3D virXPathString("string(./driver/guest/@csum)", ctxt))= ) { - if ((val =3D virTristateSwitchTypeFromString(str)) <=3D 0) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, - _("unknown guest csum mode '%s'"), - str); - goto error; + + if ((tmpNode =3D virXPathNode("./driver/guest", ctxt))) { + if ((str =3D virXMLPropString(tmpNode, "csum"))) { + if ((val =3D virTristateSwitchTypeFromString(str)) <=3D 0)= { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("unknown guest csum mode '%s'"), + str); + goto error; + } + def->driver.virtio.guest.csum =3D val; } - def->driver.virtio.guest.csum =3D val; - } - VIR_FREE(str); - if ((str =3D virXPathString("string(./driver/guest/@tso4)", ctxt))= ) { - if ((val =3D virTristateSwitchTypeFromString(str)) <=3D 0) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, - _("unknown guest tso4 mode '%s'"), - str); - goto error; + VIR_FREE(str); + if ((str =3D virXMLPropString(tmpNode, "tso4"))) { + if ((val =3D virTristateSwitchTypeFromString(str)) <=3D 0)= { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("unknown guest tso4 mode '%s'"), + str); + goto error; + } + def->driver.virtio.guest.tso4 =3D val; } - def->driver.virtio.guest.tso4 =3D val; - } - VIR_FREE(str); - if ((str =3D virXPathString("string(./driver/guest/@tso6)", ctxt))= ) { - if ((val =3D virTristateSwitchTypeFromString(str)) <=3D 0) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, - _("unknown guest tso6 mode '%s'"), - str); - goto error; + VIR_FREE(str); + if ((str =3D virXMLPropString(tmpNode, "tso6"))) { + if ((val =3D virTristateSwitchTypeFromString(str)) <=3D 0)= { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("unknown guest tso6 mode '%s'"), + str); + goto error; + } + def->driver.virtio.guest.tso6 =3D val; } - def->driver.virtio.guest.tso6 =3D val; - } - VIR_FREE(str); - if ((str =3D virXPathString("string(./driver/guest/@ecn)", ctxt)))= { - if ((val =3D virTristateSwitchTypeFromString(str)) <=3D 0) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, - _("unknown guest ecn mode '%s'"), - str); - goto error; + VIR_FREE(str); + if ((str =3D virXMLPropString(tmpNode, "ecn"))) { + if ((val =3D virTristateSwitchTypeFromString(str)) <=3D 0)= { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("unknown guest ecn mode '%s'"), + str); + goto error; + } + def->driver.virtio.guest.ecn =3D val; } - def->driver.virtio.guest.ecn =3D val; - } - VIR_FREE(str); - if ((str =3D virXPathString("string(./driver/guest/@ufo)", ctxt)))= { - if ((val =3D virTristateSwitchTypeFromString(str)) <=3D 0) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, - _("unknown guest ufo mode '%s'"), - str); - goto error; + VIR_FREE(str); + if ((str =3D virXMLPropString(tmpNode, "ufo"))) { + if ((val =3D virTristateSwitchTypeFromString(str)) <=3D 0)= { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("unknown guest ufo mode '%s'"), + str); + goto error; + } + def->driver.virtio.guest.ufo =3D val; } - def->driver.virtio.guest.ufo =3D val; } def->backend.vhost =3D vhost_path; vhost_path =3D NULL; --=20 2.13.5 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list