From nobody Tue Dec 16 08:36:45 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 1502887273869463.56263874525314; Wed, 16 Aug 2017 05:41:13 -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 EE82479754; Wed, 16 Aug 2017 12:41:11 +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 C8C4B7E38D; Wed, 16 Aug 2017 12:41: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 4B9AA1806107; Wed, 16 Aug 2017 12:41:11 +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 v7GCesfO021726 for ; Wed, 16 Aug 2017 08:40:54 -0400 Received: by smtp.corp.redhat.com (Postfix) id 697937D57E; Wed, 16 Aug 2017 12:40:54 +0000 (UTC) Received: from antique-work.brq.redhat.com (unknown [10.43.2.152]) by smtp.corp.redhat.com (Postfix) with ESMTP id E60527DB27 for ; Wed, 16 Aug 2017 12:40:53 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com EE82479754 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:41 +0200 Message-Id: <2094fd9e7e605590eb6f900c040756832da14965.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 04/10] conf: use virXMLPropString for IOMMU 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.14 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:12 +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 | 57 ++++++++++++++++++++++++++--------------------= ---- 1 file changed, 30 insertions(+), 27 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index ec4fbf36b3..4138a87f8b 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -14429,6 +14429,7 @@ virDomainIOMMUDefParseXML(xmlNodePtr node, { virDomainIOMMUDefPtr iommu =3D NULL, ret =3D NULL; xmlNodePtr save =3D ctxt->node; + xmlNodePtr driver; char *tmp =3D NULL; int val; =20 @@ -14450,39 +14451,41 @@ virDomainIOMMUDefParseXML(xmlNodePtr node, =20 iommu->model =3D val; =20 - VIR_FREE(tmp); - if ((tmp =3D virXPathString("string(./driver/@intremap)", ctxt))) { - if ((val =3D virTristateSwitchTypeFromString(tmp)) < 0) { - virReportError(VIR_ERR_XML_ERROR, _("unknown intremap value: %= s"), tmp); - goto cleanup; + if ((driver =3D virXPathNode("./driver", ctxt))) { + VIR_FREE(tmp); + if ((tmp =3D virXMLPropString(driver, "intremap"))) { + if ((val =3D virTristateSwitchTypeFromString(tmp)) < 0) { + virReportError(VIR_ERR_XML_ERROR, _("unknown intremap valu= e: %s"), tmp); + goto cleanup; + } + iommu->intremap =3D val; } - iommu->intremap =3D val; - } =20 - VIR_FREE(tmp); - if ((tmp =3D virXPathString("string(./driver/@caching_mode)", ctxt))) { - if ((val =3D virTristateSwitchTypeFromString(tmp)) < 0) { - virReportError(VIR_ERR_XML_ERROR, _("unknown caching_mode valu= e: %s"), tmp); - goto cleanup; + VIR_FREE(tmp); + if ((tmp =3D virXMLPropString(driver, "caching_mode"))) { + if ((val =3D virTristateSwitchTypeFromString(tmp)) < 0) { + virReportError(VIR_ERR_XML_ERROR, _("unknown caching_mode = value: %s"), tmp); + goto cleanup; + } + iommu->caching_mode =3D val; } - iommu->caching_mode =3D val; - } - VIR_FREE(tmp); - if ((tmp =3D virXPathString("string(./driver/@iotlb)", ctxt))) { - if ((val =3D virTristateSwitchTypeFromString(tmp)) < 0) { - virReportError(VIR_ERR_XML_ERROR, _("unknown iotlb value: %s")= , tmp); - goto cleanup; + VIR_FREE(tmp); + if ((tmp =3D virXMLPropString(driver, "iotlb"))) { + if ((val =3D virTristateSwitchTypeFromString(tmp)) < 0) { + virReportError(VIR_ERR_XML_ERROR, _("unknown iotlb value: = %s"), tmp); + goto cleanup; + } + iommu->iotlb =3D val; } - iommu->iotlb =3D val; - } =20 - VIR_FREE(tmp); - if ((tmp =3D virXPathString("string(./driver/@eim)", ctxt))) { - if ((val =3D virTristateSwitchTypeFromString(tmp)) < 0) { - virReportError(VIR_ERR_XML_ERROR, _("unknown eim value: %s"), = tmp); - goto cleanup; + VIR_FREE(tmp); + if ((tmp =3D virXMLPropString(driver, "eim"))) { + if ((val =3D virTristateSwitchTypeFromString(tmp)) < 0) { + virReportError(VIR_ERR_XML_ERROR, _("unknown eim value: %s= "), tmp); + goto cleanup; + } + iommu->eim =3D val; } - iommu->eim =3D val; } =20 ret =3D iommu; --=20 2.13.5 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list