From nobody Tue Dec 16 08:42:47 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 15028872818821004.6045901252305; Wed, 16 Aug 2017 05:41:21 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id EE8457CB8B; Wed, 16 Aug 2017 12:41:19 +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 CAFD67DB51; Wed, 16 Aug 2017 12:41:19 +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 D69883FAEB; Wed, 16 Aug 2017 12:41:17 +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 v7GCeuGg021757 for ; Wed, 16 Aug 2017 08:40:56 -0400 Received: by smtp.corp.redhat.com (Postfix) id D26E17DB24; Wed, 16 Aug 2017 12:40:56 +0000 (UTC) Received: from antique-work.brq.redhat.com (unknown [10.43.2.152]) by smtp.corp.redhat.com (Postfix) with ESMTP id 59CAD7D57E for ; Wed, 16 Aug 2017 12:40:56 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com EE8457CB8B 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:44 +0200 Message-Id: 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 07/10] conf: use virXMLPropString for actual 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.11 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:20 +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 | 61 ++++++++++++++++++++++++++++------------------= ---- 1 file changed, 34 insertions(+), 27 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 917ea004e5..83432fa5b0 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -9656,18 +9656,22 @@ virDomainActualNetDefParseXML(xmlNodePtr node, } =20 if (actual->type =3D=3D VIR_DOMAIN_NET_TYPE_DIRECT) { - actual->data.direct.linkdev =3D virXPathString("string(./source[1]= /@dev)", ctxt); + xmlNodePtr sourceNode =3D virXPathNode("./source[1]", ctxt); =20 - mode =3D virXPathString("string(./source[1]/@mode)", ctxt); - if (mode) { - int m; - if ((m =3D virNetDevMacVLanModeTypeFromString(mode)) < 0) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, - _("Unknown mode '%s' in interface = element"), - mode); - goto error; + if (sourceNode) { + actual->data.direct.linkdev =3D virXMLPropString(sourceNode, "= dev"); + + mode =3D virXMLPropString(sourceNode, "mode"); + if (mode) { + int m; + if ((m =3D virNetDevMacVLanModeTypeFromString(mode)) < 0) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("Unknown mode '%s' in interface element"), + mode); + goto error; + } + actual->data.direct.mode =3D m; } - actual->data.direct.mode =3D m; } } else if (actual->type =3D=3D VIR_DOMAIN_NET_TYPE_HOSTDEV) { virDomainHostdevDefPtr hostdev =3D &actual->data.hostdev.def; @@ -9703,24 +9707,27 @@ virDomainActualNetDefParseXML(xmlNodePtr node, } if (actual->type =3D=3D VIR_DOMAIN_NET_TYPE_BRIDGE || actual->type =3D=3D VIR_DOMAIN_NET_TYPE_NETWORK) { - char *brname =3D virXPathString("string(./source/@bridge)", ctxt); + xmlNodePtr sourceNode =3D virXPathNode("./source", ctxt); + if (sourceNode) { + char *brname =3D virXMLPropString(sourceNode, "bridge"); =20 - if (!brname && actual->type =3D=3D VIR_DOMAIN_NET_TYPE_BRIDGE) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("Missing element with bridge name in= " - "interface's element")); - goto error; - } - actual->data.bridge.brname =3D brname; - macTableManager =3D virXPathString("string(./source/@macTableManag= er)", ctxt); - if (macTableManager && - (actual->data.bridge.macTableManager - =3D virNetworkBridgeMACTableManagerTypeFromString(macTableMan= ager)) <=3D 0) { - virReportError(VIR_ERR_XML_ERROR, - _("Invalid macTableManager setting '%s' " - "in domain interface's element"), - macTableManager); - goto error; + if (!brname && actual->type =3D=3D VIR_DOMAIN_NET_TYPE_BRIDGE)= { + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("Missing element with bridge nam= e in " + "interface's element")); + goto error; + } + actual->data.bridge.brname =3D brname; + macTableManager =3D virXMLPropString(sourceNode, "macTableMana= ger"); + if (macTableManager && + (actual->data.bridge.macTableManager + =3D virNetworkBridgeMACTableManagerTypeFromString(macTabl= eManager)) <=3D 0) { + virReportError(VIR_ERR_XML_ERROR, + _("Invalid macTableManager setting '%s' " + "in domain interface's element"), + macTableManager); + goto error; + } } } =20 --=20 2.13.5 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list