From nobody Mon Nov 25 22:48:22 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 207.211.31.81 as permitted sender) client-ip=207.211.31.81; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 207.211.31.81 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1591172263; cv=none; d=zohomail.com; s=zohoarc; b=iHFxbhNUNtK9B8dHmbNme7K7EjZ1nxzvQ3nZjvGoSN6HZ9fkoDB40T+BOtZLpV4XygMExQDCKa3k27dj9gymF7lJsKXWvy3p8BOy0tqAQAbn68AxuvRlJTYaTklUy6csTvQXZRmw1H+55xg08aLRG5fw8F4J3qstA9FE32kNqlQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1591172263; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=lS6QaIhdAM8+FvHAaA0zWsPzybmFI4V/i351huyhbw4=; b=ky4fODjn8OJqh/uu5v9n9Bt6F+XGcvh12/SwlEcRVRJtkucy3aM1lpCq9AG6WFDx/NNgBGSTL4hQMYFxpiaJhjkWDdjHP0pYG4WRJIiA/3V2v5wEymEL1Na7QS3GSFP+SGYHjgfYCOdGONHZGxJK3pqVR12WOI0T3ZGEsqa81r0= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 207.211.31.81 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-delivery-1.mimecast.com (us-smtp-2.mimecast.com [207.211.31.81]) by mx.zohomail.com with SMTPS id 1591172263887844.8692736291606; Wed, 3 Jun 2020 01:17:43 -0700 (PDT) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-267-TjGK4AiDMQamu-qV6c7Ovw-1; Wed, 03 Jun 2020 04:17:40 -0400 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 mimecast-mx01.redhat.com (Postfix) with ESMTPS id 2A89080B709; Wed, 3 Jun 2020 08:17:35 +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 E479F60C81; Wed, 3 Jun 2020 08:17:33 +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 1ED6E97028; Wed, 3 Jun 2020 08:17:31 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 0538HTPZ025552 for ; Wed, 3 Jun 2020 04:17:29 -0400 Received: by smtp.corp.redhat.com (Postfix) id 3C26118A54; Wed, 3 Jun 2020 08:17:29 +0000 (UTC) Received: from localhost.localdomain (unknown [10.40.193.222]) by smtp.corp.redhat.com (Postfix) with ESMTP id 8859660C81 for ; Wed, 3 Jun 2020 08:17:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1591172262; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=lS6QaIhdAM8+FvHAaA0zWsPzybmFI4V/i351huyhbw4=; b=VqED7nQl0paUUxUrz9O39cRob7RP8brd/dupElrGR3xYS73Tc6Uqt7vnj+T0xxqtZiYZDp mhQY7uRUhmACJ5UJexHnFoNDvjrXH2daroaaaNjRAleuIeOJiThpXm4k5vqHztUoZAQtCc /rOyh+YB8KmZ4W3TGCmhbUh+IZ//RC4= X-MC-Unique: TjGK4AiDMQamu-qV6c7Ovw-1 From: Michal Privoznik To: libvir-list@redhat.com Subject: [PATCH 1/2] virxml: Don't overwrite ctxt->node Date: Wed, 3 Jun 2020 10:17:22 +0200 Message-Id: <05bcb6ee43c0f133c7d009a317b9c93234b6045a.1591172116.git.mprivozn@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-loop: libvir-list@redhat.com 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: , 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-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" This reverts b897973f2e0. Even though it may have been the case in the past, relative XPaths don't overwrite the ctxt->node. Thus, there's no need to save it. Signed-off-by: Michal Privoznik Reviewed-by: J=C3=A1n Tomko --- src/util/virxml.c | 27 --------------------------- 1 file changed, 27 deletions(-) diff --git a/src/util/virxml.c b/src/util/virxml.c index 9ea7b99dba..02b59ea2f8 100644 --- a/src/util/virxml.c +++ b/src/util/virxml.c @@ -74,7 +74,6 @@ virXPathString(const char *xpath, xmlXPathContextPtr ctxt) { xmlXPathObjectPtr obj; - xmlNodePtr relnode; char *ret; =20 if ((ctxt =3D=3D NULL) || (xpath =3D=3D NULL)) { @@ -82,9 +81,7 @@ virXPathString(const char *xpath, "%s", _("Invalid parameter to virXPathString()")); return NULL; } - relnode =3D ctxt->node; obj =3D xmlXPathEval(BAD_CAST xpath, ctxt); - ctxt->node =3D relnode; if ((obj =3D=3D NULL) || (obj->type !=3D XPATH_STRING) || (obj->stringval =3D=3D NULL) || (obj->stringval[0] =3D=3D 0)) { xmlXPathFreeObject(obj); @@ -152,16 +149,13 @@ virXPathNumber(const char *xpath, double *value) { xmlXPathObjectPtr obj; - xmlNodePtr relnode; =20 if ((ctxt =3D=3D NULL) || (xpath =3D=3D NULL) || (value =3D=3D NULL)) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("Invalid parameter to virXPathNumber()")); return -1; } - relnode =3D ctxt->node; obj =3D xmlXPathEval(BAD_CAST xpath, ctxt); - ctxt->node =3D relnode; if ((obj =3D=3D NULL) || (obj->type !=3D XPATH_NUMBER) || (isnan(obj->floatval))) { xmlXPathFreeObject(obj); @@ -180,7 +174,6 @@ virXPathLongBase(const char *xpath, long *value) { xmlXPathObjectPtr obj; - xmlNodePtr relnode; int ret =3D 0; =20 if ((ctxt =3D=3D NULL) || (xpath =3D=3D NULL) || (value =3D=3D NULL)) { @@ -188,9 +181,7 @@ virXPathLongBase(const char *xpath, "%s", _("Invalid parameter to virXPathLong()")); return -1; } - relnode =3D ctxt->node; obj =3D xmlXPathEval(BAD_CAST xpath, ctxt); - ctxt->node =3D relnode; if ((obj !=3D NULL) && (obj->type =3D=3D XPATH_STRING) && (obj->stringval !=3D NULL) && (obj->stringval[0] !=3D 0)) { if (virStrToLong_l((char *) obj->stringval, NULL, base, value) < 0) @@ -285,7 +276,6 @@ virXPathULongBase(const char *xpath, unsigned long *value) { xmlXPathObjectPtr obj; - xmlNodePtr relnode; int ret =3D 0; =20 if ((ctxt =3D=3D NULL) || (xpath =3D=3D NULL) || (value =3D=3D NULL)) { @@ -293,9 +283,7 @@ virXPathULongBase(const char *xpath, "%s", _("Invalid parameter to virXPathULong()")); return -1; } - relnode =3D ctxt->node; obj =3D xmlXPathEval(BAD_CAST xpath, ctxt); - ctxt->node =3D relnode; if ((obj !=3D NULL) && (obj->type =3D=3D XPATH_STRING) && (obj->stringval !=3D NULL) && (obj->stringval[0] !=3D 0)) { if (virStrToLong_ul((char *) obj->stringval, NULL, base, value) < = 0) @@ -401,7 +389,6 @@ virXPathULongLong(const char *xpath, unsigned long long *value) { xmlXPathObjectPtr obj; - xmlNodePtr relnode; int ret =3D 0; =20 if ((ctxt =3D=3D NULL) || (xpath =3D=3D NULL) || (value =3D=3D NULL)) { @@ -409,9 +396,7 @@ virXPathULongLong(const char *xpath, "%s", _("Invalid parameter to virXPathULong()")); return -1; } - relnode =3D ctxt->node; obj =3D xmlXPathEval(BAD_CAST xpath, ctxt); - ctxt->node =3D relnode; if ((obj !=3D NULL) && (obj->type =3D=3D XPATH_STRING) && (obj->stringval !=3D NULL) && (obj->stringval[0] !=3D 0)) { if (virStrToLong_ull((char *) obj->stringval, NULL, 10, value) < 0) @@ -447,7 +432,6 @@ virXPathLongLong(const char *xpath, long long *value) { xmlXPathObjectPtr obj; - xmlNodePtr relnode; int ret =3D 0; =20 if ((ctxt =3D=3D NULL) || (xpath =3D=3D NULL) || (value =3D=3D NULL)) { @@ -455,9 +439,7 @@ virXPathLongLong(const char *xpath, "%s", _("Invalid parameter to virXPathLongLong()")); return -1; } - relnode =3D ctxt->node; obj =3D xmlXPathEval(BAD_CAST xpath, ctxt); - ctxt->node =3D relnode; if ((obj !=3D NULL) && (obj->type =3D=3D XPATH_STRING) && (obj->stringval !=3D NULL) && (obj->stringval[0] !=3D 0)) { if (virStrToLong_ll((char *) obj->stringval, NULL, 10, value) < 0) @@ -573,7 +555,6 @@ virXPathBoolean(const char *xpath, xmlXPathContextPtr ctxt) { xmlXPathObjectPtr obj; - xmlNodePtr relnode; int ret; =20 if ((ctxt =3D=3D NULL) || (xpath =3D=3D NULL)) { @@ -581,9 +562,7 @@ virXPathBoolean(const char *xpath, "%s", _("Invalid parameter to virXPathBoolean()")); return -1; } - relnode =3D ctxt->node; obj =3D xmlXPathEval(BAD_CAST xpath, ctxt); - ctxt->node =3D relnode; if ((obj =3D=3D NULL) || (obj->type !=3D XPATH_BOOLEAN) || (obj->boolval < 0) || (obj->boolval > 1)) { xmlXPathFreeObject(obj); @@ -610,7 +589,6 @@ virXPathNode(const char *xpath, xmlXPathContextPtr ctxt) { xmlXPathObjectPtr obj; - xmlNodePtr relnode; xmlNodePtr ret; =20 if ((ctxt =3D=3D NULL) || (xpath =3D=3D NULL)) { @@ -618,9 +596,7 @@ virXPathNode(const char *xpath, "%s", _("Invalid parameter to virXPathNode()")); return NULL; } - relnode =3D ctxt->node; obj =3D xmlXPathEval(BAD_CAST xpath, ctxt); - ctxt->node =3D relnode; if ((obj =3D=3D NULL) || (obj->type !=3D XPATH_NODESET) || (obj->nodesetval =3D=3D NULL) || (obj->nodesetval->nodeNr <=3D 0) = || (obj->nodesetval->nodeTab =3D=3D NULL)) { @@ -650,7 +626,6 @@ virXPathNodeSet(const char *xpath, xmlNodePtr **list) { xmlXPathObjectPtr obj; - xmlNodePtr relnode; int ret; =20 if ((ctxt =3D=3D NULL) || (xpath =3D=3D NULL)) { @@ -662,9 +637,7 @@ virXPathNodeSet(const char *xpath, if (list !=3D NULL) *list =3D NULL; =20 - relnode =3D ctxt->node; obj =3D xmlXPathEval(BAD_CAST xpath, ctxt); - ctxt->node =3D relnode; if (obj =3D=3D NULL) return 0; =20 --=20 2.26.2 From nobody Mon Nov 25 22:48:22 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 205.139.110.120 as permitted sender) client-ip=205.139.110.120; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 205.139.110.120 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1591172273; cv=none; d=zohomail.com; s=zohoarc; b=Lg3R3Ba+EZZ0EMOsBOS5795XyoR4MOjbF28xdzQ8oFkiLUBkegt93e/QyMG97O497+vN57OyfRn2BrumuqcJvolCCsYab4VMET1C+HJvAMcu3ik8w3YmwapBFStxyubNnnmLyM+1Q1oi5OhbIG5wlq2okUBPav9w3uyfn+z/l/8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1591172273; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=7zMLixTL3YNvX5wBE6h9gRSeaQweWLtr92lO8pletQ0=; b=l5X1v7umvxASHu1YZ5wteubkv8DJFoo1kl62IRN4nICmNDKAdiLn0cu7xVRaOMOTWzZFw5z1F003tNTOTPoIpayYoxKe6NIw3H7Utvre+1xK/LtazKSIApQczYAmoHQfTFpM/xnn7ODY4Z0wNTVwqJX3yaeSIv0BMopB5VAtxNI= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 205.139.110.120 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [205.139.110.120]) by mx.zohomail.com with SMTPS id 159117227335478.35958424429487; Wed, 3 Jun 2020 01:17:53 -0700 (PDT) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-208-mOeiGVRJPoeu9voF4T-CkA-1; Wed, 03 Jun 2020 04:17:49 -0400 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 mimecast-mx01.redhat.com (Postfix) with ESMTPS id C408780B729; Wed, 3 Jun 2020 08:17:44 +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 A12D65D9CD; Wed, 3 Jun 2020 08:17:44 +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 6E5401809543; Wed, 3 Jun 2020 08:17:44 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 0538HU2k025562 for ; Wed, 3 Jun 2020 04:17:30 -0400 Received: by smtp.corp.redhat.com (Postfix) id 6CCCB61987; Wed, 3 Jun 2020 08:17:30 +0000 (UTC) Received: from localhost.localdomain (unknown [10.40.193.222]) by smtp.corp.redhat.com (Postfix) with ESMTP id 8EDEF61984 for ; Wed, 3 Jun 2020 08:17:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1591172271; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=7zMLixTL3YNvX5wBE6h9gRSeaQweWLtr92lO8pletQ0=; b=P31dzA0U4H9ExhT+bPD2+V9THlSo8dLp8ZkV0zNCa2UBWsIBG7luCdDiv4cO7RCZ6jujN8 6K5gdDOAslNn5RTAtPsLnCNDZbsma3OQQM5Z9Ww/ZFbFqjc/fEAauyHbhv9+InfBhYeAzV 69METlSClU+CujU2ZM84O2abClXh2Io= X-MC-Unique: mOeiGVRJPoeu9voF4T-CkA-1 From: Michal Privoznik To: libvir-list@redhat.com Subject: [PATCH 2/2] Use more of VIR_XPATH_NODE_AUTORESTORE Date: Wed, 3 Jun 2020 10:17:23 +0200 Message-Id: <025b885e1b870eea69d9ffb712fceb48089e666a.1591172116.git.mprivozn@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-loop: libvir-list@redhat.com 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: , 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-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" This is convenience macro, use it more. This commit was generated using the following spatch: @@ symbol node; identifier old; identifier ctxt; type xmlNodePtr; @@ - xmlNodePtr old; + VIR_XPATH_NODE_AUTORESTORE(ctxt); ... - old =3D ctxt->node; ... when !=3D old - ctxt->node =3D old; @@ symbol node; identifier old; identifier ctxt; type xmlNodePtr; @@ - xmlNodePtr old =3D ctxt->node; + VIR_XPATH_NODE_AUTORESTORE(ctxt); ... when !=3D old - ctxt->node =3D old; Signed-off-by: Michal Privoznik Reviewed-by: J=C3=A1n Tomko --- src/conf/cpu_conf.c | 3 +- src/conf/domain_conf.c | 7 +-- src/conf/interface_conf.c | 16 ++----- src/conf/netdev_vlan_conf.c | 3 +- src/conf/network_conf.c | 25 +++------- src/conf/networkcommon_conf.c | 4 +- src/conf/node_device_conf.c | 84 +++++++++------------------------ src/conf/numa_conf.c | 3 +- src/conf/snapshot_conf.c | 3 +- src/conf/storage_adapter_conf.c | 3 +- src/conf/storage_conf.c | 4 +- src/conf/virsavecookie.c | 3 +- src/cpu/cpu_map.c | 12 +---- src/cpu/cpu_x86.c | 3 +- src/lxc/lxc_domain.c | 4 +- src/util/virstorageencryption.c | 8 +--- src/util/virstoragefile.c | 3 +- tools/virsh-domain.c | 6 +-- 18 files changed, 52 insertions(+), 142 deletions(-) diff --git a/src/conf/cpu_conf.c b/src/conf/cpu_conf.c index c6d36e0cb5..1d02e23175 100644 --- a/src/conf/cpu_conf.c +++ b/src/conf/cpu_conf.c @@ -326,7 +326,7 @@ virCPUDefParseXML(xmlXPathContextPtr ctxt, { virCPUDefPtr def =3D NULL; xmlNodePtr *nodes =3D NULL; - xmlNodePtr oldnode =3D ctxt->node; + VIR_XPATH_NODE_AUTORESTORE(ctxt); int n; size_t i; char *cpuMode; @@ -662,7 +662,6 @@ virCPUDefParseXML(xmlXPathContextPtr ctxt, ret =3D 0; =20 cleanup: - ctxt->node =3D oldnode; VIR_FREE(fallback); VIR_FREE(vendor_id); VIR_FREE(nodes); diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 1406cf079e..1cdc7971fc 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -13265,16 +13265,14 @@ virDomainChrSourceDefParseXML(virDomainChrSourceD= efPtr def, =20 /* Check for an optional seclabel override in . */ if (chr_def) { - xmlNodePtr saved_node =3D ctxt->node; + VIR_XPATH_NODE_AUTORESTORE(ctxt); ctxt->node =3D cur; if (virSecurityDeviceLabelDefParseXML(&def->seclabels, &def->nseclabels, ctxt, flags) < 0) { - ctxt->node =3D saved_node; goto error; } - ctxt->node =3D saved_node; } } else if (virXMLNodeNameEqual(cur, "log")) { if (logParsed) { @@ -22181,11 +22179,10 @@ virDomainDefParseXML(xmlDocPtr xml, } =20 if ((node =3D virXPathNode("./sysinfo[1]", ctxt)) !=3D NULL) { - xmlNodePtr oldnode =3D ctxt->node; + VIR_XPATH_NODE_AUTORESTORE(ctxt); ctxt->node =3D node; def->sysinfo =3D virSysinfoParseXML(node, ctxt, def->uuid, uuid_generated); - ctxt->node =3D oldnode; =20 if (def->sysinfo =3D=3D NULL) goto error; diff --git a/src/conf/interface_conf.c b/src/conf/interface_conf.c index d1732621b5..be5e1133a2 100644 --- a/src/conf/interface_conf.c +++ b/src/conf/interface_conf.c @@ -262,12 +262,11 @@ static int virInterfaceDefParseDhcp(virInterfaceProtocolDefPtr def, xmlNodePtr dhcp, xmlXPathContextPtr ctxt) { - xmlNodePtr save; + VIR_XPATH_NODE_AUTORESTORE(ctxt); char *tmp; int ret =3D 0; =20 def->dhcp =3D 1; - save =3D ctxt->node; ctxt->node =3D dhcp; def->peerdns =3D -1; /* Not much to do in the current version */ @@ -284,7 +283,6 @@ virInterfaceDefParseDhcp(virInterfaceProtocolDefPtr def, VIR_FREE(tmp); } =20 - ctxt->node =3D save; return ret; } =20 @@ -426,13 +424,11 @@ static int virInterfaceDefParseIfAdressing(virInterfaceDefPtr def, xmlXPathContextPtr ctxt) { - xmlNodePtr save; + VIR_XPATH_NODE_AUTORESTORE(ctxt); xmlNodePtr *protoNodes =3D NULL; int nProtoNodes, pp, ret =3D -1; char *tmp; =20 - save =3D ctxt->node; - nProtoNodes =3D virXPathNodeSet("./protocol", ctxt, &protoNodes); if (nProtoNodes < 0) goto error; @@ -487,7 +483,6 @@ virInterfaceDefParseIfAdressing(virInterfaceDefPtr def, =20 error: VIR_FREE(protoNodes); - ctxt->node =3D save; return ret; =20 } @@ -558,7 +553,7 @@ virInterfaceDefParseBondItfs(virInterfaceDefPtr def, xmlXPathContextPtr ctxt) { xmlNodePtr *interfaces =3D NULL; - xmlNodePtr bond =3D ctxt->node; + VIR_XPATH_NODE_AUTORESTORE(ctxt); virInterfaceDefPtr itf; int nbItf; size_t i; @@ -591,7 +586,6 @@ virInterfaceDefParseBondItfs(virInterfaceDefPtr def, ret =3D 0; cleanup: VIR_FREE(interfaces); - ctxt->node =3D bond; return ret; } =20 @@ -698,7 +692,7 @@ virInterfaceDefParseXML(xmlXPathContextPtr ctxt, virInterfaceDefPtr def; int type; char *tmp; - xmlNodePtr cur =3D ctxt->node; + VIR_XPATH_NODE_AUTORESTORE(ctxt); xmlNodePtr lnk; =20 =20 @@ -804,11 +798,9 @@ virInterfaceDefParseXML(xmlXPathContextPtr ctxt, =20 } =20 - ctxt->node =3D cur; return def; =20 error: - ctxt->node =3D cur; virInterfaceDefFree(def); return NULL; } diff --git a/src/conf/netdev_vlan_conf.c b/src/conf/netdev_vlan_conf.c index 516129280d..7830a341b2 100644 --- a/src/conf/netdev_vlan_conf.c +++ b/src/conf/netdev_vlan_conf.c @@ -33,7 +33,7 @@ int virNetDevVlanParse(xmlNodePtr node, xmlXPathContextPtr ctxt, virNetDevVlan= Ptr def) { int ret =3D -1; - xmlNodePtr save =3D ctxt->node; + VIR_XPATH_NODE_AUTORESTORE(ctxt); char *trunk =3D NULL; char *nativeMode =3D NULL; xmlNodePtr *tagNodes =3D NULL; @@ -128,7 +128,6 @@ virNetDevVlanParse(xmlNodePtr node, xmlXPathContextPtr = ctxt, virNetDevVlanPtr de =20 ret =3D 0; cleanup: - ctxt->node =3D save; VIR_FREE(tagNodes); VIR_FREE(trunk); VIR_FREE(nativeMode); diff --git a/src/conf/network_conf.c b/src/conf/network_conf.c index dc64ce6959..f1d22b25b1 100644 --- a/src/conf/network_conf.c +++ b/src/conf/network_conf.c @@ -800,7 +800,7 @@ virNetworkDNSSrvDefParseXML(const char *networkName, bool partialOkay) { int ret; - xmlNodePtr save_ctxt =3D ctxt->node; + VIR_XPATH_NODE_AUTORESTORE(ctxt); =20 ctxt->node =3D node; =20 @@ -895,12 +895,10 @@ virNetworkDNSSrvDefParseXML(const char *networkName, goto error; } =20 - ctxt->node =3D save_ctxt; return 0; =20 error: virNetworkDNSSrvDefClear(def); - ctxt->node =3D save_ctxt; return -1; } =20 @@ -961,7 +959,7 @@ virNetworkDNSDefParseXML(const char *networkName, int nhosts, nsrvs, ntxts, nfwds; size_t i; int ret =3D -1; - xmlNodePtr save =3D ctxt->node; + VIR_XPATH_NODE_AUTORESTORE(ctxt); =20 ctxt->node =3D node; =20 @@ -1100,7 +1098,6 @@ virNetworkDNSDefParseXML(const char *networkName, VIR_FREE(hostNodes); VIR_FREE(srvNodes); VIR_FREE(txtNodes); - ctxt->node =3D save; return ret; } =20 @@ -1116,7 +1113,7 @@ virNetworkIPDefParseXML(const char *networkName, * On failure clear it out, but don't free it. */ =20 - xmlNodePtr save; + VIR_XPATH_NODE_AUTORESTORE(ctxt); xmlNodePtr dhcp; char *address =3D NULL, *netmask =3D NULL; unsigned long prefix =3D 0; @@ -1124,7 +1121,6 @@ virNetworkIPDefParseXML(const char *networkName, int result =3D -1; char *localPtr =3D NULL; =20 - save =3D ctxt->node; ctxt->node =3D node; =20 /* grab raw data from XML */ @@ -1256,7 +1252,6 @@ virNetworkIPDefParseXML(const char *networkName, VIR_FREE(netmask); VIR_FREE(localPtr); =20 - ctxt->node =3D save; return result; } =20 @@ -1291,7 +1286,7 @@ virNetworkPortGroupParseXML(virPortGroupDefPtr def, * On failure clear it out, but don't free it. */ =20 - xmlNodePtr save; + VIR_XPATH_NODE_AUTORESTORE(ctxt); xmlNodePtr virtPortNode; xmlNodePtr vlanNode; xmlNodePtr bandwidth_node; @@ -1300,7 +1295,6 @@ virNetworkPortGroupParseXML(virPortGroupDefPtr def, =20 int result =3D -1; =20 - save =3D ctxt->node; ctxt->node =3D node; =20 /* grab raw data from XML */ @@ -1348,7 +1342,6 @@ virNetworkPortGroupParseXML(virPortGroupDefPtr def, VIR_FREE(isDefault); VIR_FREE(trustGuestRxFilters); =20 - ctxt->node =3D save; return result; } =20 @@ -1365,7 +1358,7 @@ virNetworkForwardNatDefParseXML(const char *networkNa= me, int nNatAddrs, nNatPorts; char *addrStart =3D NULL; char *addrEnd =3D NULL; - xmlNodePtr save =3D ctxt->node; + VIR_XPATH_NODE_AUTORESTORE(ctxt); =20 ctxt->node =3D node; =20 @@ -1477,7 +1470,6 @@ virNetworkForwardNatDefParseXML(const char *networkNa= me, VIR_FREE(addrEnd); VIR_FREE(natAddrNodes); VIR_FREE(natPortNodes); - ctxt->node =3D save; return ret; } =20 @@ -1499,7 +1491,7 @@ virNetworkForwardDefParseXML(const char *networkName, char *forwardManaged =3D NULL; char *forwardDriverName =3D NULL; char *type =3D NULL; - xmlNodePtr save =3D ctxt->node; + VIR_XPATH_NODE_AUTORESTORE(ctxt); =20 ctxt->node =3D node; =20 @@ -1726,7 +1718,6 @@ virNetworkForwardDefParseXML(const char *networkName, VIR_FREE(forwardIfNodes); VIR_FREE(forwardAddrNodes); VIR_FREE(forwardNatNodes); - ctxt->node =3D save; return ret; } =20 @@ -1747,7 +1738,7 @@ virNetworkDefParseXML(xmlXPathContextPtr ctxt, xmlNodePtr forwardNode =3D NULL; char *ipv6nogwStr =3D NULL; char *trustGuestRxFilters =3D NULL; - xmlNodePtr save =3D ctxt->node; + VIR_XPATH_NODE_AUTORESTORE(ctxt); xmlNodePtr bandwidthNode =3D NULL; xmlNodePtr vlanNode; xmlNodePtr metadataNode =3D NULL; @@ -2164,7 +2155,6 @@ virNetworkDefParseXML(xmlXPathContextPtr ctxt, goto error; } =20 - ctxt->node =3D save; return def; =20 error: @@ -2176,7 +2166,6 @@ virNetworkDefParseXML(xmlXPathContextPtr ctxt, VIR_FREE(portGroupNodes); VIR_FREE(ipv6nogwStr); VIR_FREE(trustGuestRxFilters); - ctxt->node =3D save; return NULL; } =20 diff --git a/src/conf/networkcommon_conf.c b/src/conf/networkcommon_conf.c index e90cfcbef5..a4f9ce5c62 100644 --- a/src/conf/networkcommon_conf.c +++ b/src/conf/networkcommon_conf.c @@ -228,7 +228,7 @@ virNetDevIPRouteParseXML(const char *errorDetail, */ =20 virNetDevIPRoutePtr def =3D NULL; - xmlNodePtr save; + VIR_XPATH_NODE_AUTORESTORE(ctxt); char *family =3D NULL; char *address =3D NULL, *netmask =3D NULL; char *gateway =3D NULL; @@ -237,7 +237,6 @@ virNetDevIPRouteParseXML(const char *errorDetail, bool hasPrefix =3D false; bool hasMetric =3D false; =20 - save =3D ctxt->node; ctxt->node =3D node; =20 /* grab raw data from XML */ @@ -278,7 +277,6 @@ virNetDevIPRouteParseXML(const char *errorDetail, hasMetric); =20 cleanup: - ctxt->node =3D save; VIR_FREE(family); VIR_FREE(address); VIR_FREE(netmask); diff --git a/src/conf/node_device_conf.c b/src/conf/node_device_conf.c index 4cf5b6e3d7..33c9c7dec0 100644 --- a/src/conf/node_device_conf.c +++ b/src/conf/node_device_conf.c @@ -703,11 +703,10 @@ virNodeDevCapDRMParseXML(xmlXPathContextPtr ctxt, xmlNodePtr node, virNodeDevCapDRMPtr drm) { - xmlNodePtr orignode; + VIR_XPATH_NODE_AUTORESTORE(ctxt); int ret =3D -1, val; char *type =3D NULL; =20 - orignode =3D ctxt->node; ctxt->node =3D node; =20 type =3D virXPathString("string(./type[1])", ctxt); @@ -723,7 +722,6 @@ virNodeDevCapDRMParseXML(xmlXPathContextPtr ctxt, =20 out: VIR_FREE(type); - ctxt->node =3D orignode; return ret; } =20 @@ -734,11 +732,10 @@ virNodeDevCapCCWParseXML(xmlXPathContextPtr ctxt, xmlNodePtr node, virNodeDevCapCCWPtr ccw_dev) { - xmlNodePtr orignode; + VIR_XPATH_NODE_AUTORESTORE(ctxt); int ret =3D -1; char *cssid =3D NULL, *ssid =3D NULL, *devno =3D NULL; =20 - orignode =3D ctxt->node; ctxt->node =3D node; =20 if (!(cssid =3D virXPathString("string(./cssid[1])", ctxt))) { @@ -783,7 +780,6 @@ virNodeDevCapCCWParseXML(xmlXPathContextPtr ctxt, ret =3D 0; =20 out: - ctxt->node =3D orignode; VIR_FREE(cssid); VIR_FREE(ssid); VIR_FREE(devno); @@ -797,12 +793,12 @@ virNodeDevCapStorageParseXML(xmlXPathContextPtr ctxt, xmlNodePtr node, virNodeDevCapStoragePtr storage) { - xmlNodePtr orignode, *nodes =3D NULL; + VIR_XPATH_NODE_AUTORESTORE(ctxt); + xmlNodePtr *nodes =3D NULL; size_t i; int n, ret =3D -1; unsigned long long val; =20 - orignode =3D ctxt->node; ctxt->node =3D node; =20 storage->block =3D virXPathString("string(./block[1])", ctxt); @@ -835,11 +831,8 @@ virNodeDevCapStorageParseXML(xmlXPathContextPtr ctxt, if (STREQ(type, "hotpluggable")) { storage->flags |=3D VIR_NODE_DEV_CAP_STORAGE_HOTPLUGGABLE; } else if (STREQ(type, "removable")) { - xmlNodePtr orignode2; - storage->flags |=3D VIR_NODE_DEV_CAP_STORAGE_REMOVABLE; =20 - orignode2 =3D ctxt->node; ctxt->node =3D nodes[i]; =20 if (virXPathBoolean("count(./media_available[. =3D '1']) > 0",= ctxt)) @@ -851,13 +844,10 @@ virNodeDevCapStorageParseXML(xmlXPathContextPtr ctxt, if (virNodeDevCapsDefParseULongLong("number(./media_size[1])",= ctxt, &val, def, _("no removable media size= supplied for '%s'"), _("invalid removable media= size supplied for '%s'")) < 0) { - ctxt->node =3D orignode2; VIR_FREE(type); goto out; } storage->removable_media_size =3D val; - - ctxt->node =3D orignode2; } else { virReportError(VIR_ERR_INTERNAL_ERROR, _("unknown storage capability type '%s' for '%s= '"), @@ -881,7 +871,6 @@ virNodeDevCapStorageParseXML(xmlXPathContextPtr ctxt, ret =3D 0; out: VIR_FREE(nodes); - ctxt->node =3D orignode; return ret; } =20 @@ -892,10 +881,9 @@ virNodeDevCapSCSIParseXML(xmlXPathContextPtr ctxt, xmlNodePtr node, virNodeDevCapSCSIPtr scsi) { - xmlNodePtr orignode; + VIR_XPATH_NODE_AUTORESTORE(ctxt); int ret =3D -1; =20 - orignode =3D ctxt->node; ctxt->node =3D node; =20 if (virNodeDevCapsDefParseULong("number(./host[1])", ctxt, @@ -926,7 +914,6 @@ virNodeDevCapSCSIParseXML(xmlXPathContextPtr ctxt, =20 ret =3D 0; out: - ctxt->node =3D orignode; return ret; } =20 @@ -937,12 +924,12 @@ virNodeDevCapSCSITargetParseXML(xmlXPathContextPtr ct= xt, xmlNodePtr node, virNodeDevCapSCSITargetPtr scsi_target) { - xmlNodePtr orignode, *nodes =3D NULL; + VIR_XPATH_NODE_AUTORESTORE(ctxt); + xmlNodePtr *nodes =3D NULL; int ret =3D -1, n =3D 0; size_t i; char *type =3D NULL; =20 - orignode =3D ctxt->node; ctxt->node =3D node; =20 scsi_target->name =3D virXPathString("string(./target[1])", ctxt); @@ -967,11 +954,8 @@ virNodeDevCapSCSITargetParseXML(xmlXPathContextPtr ctx= t, } =20 if (STREQ(type, "fc_remote_port")) { - xmlNodePtr orignode2; - scsi_target->flags |=3D VIR_NODE_DEV_CAP_FLAG_FC_RPORT; =20 - orignode2 =3D ctxt->node; ctxt->node =3D nodes[i]; =20 if (virNodeDevCapsDefParseString("string(./rport[1])", @@ -989,8 +973,6 @@ virNodeDevCapSCSITargetParseXML(xmlXPathContextPtr ctxt, def->name); goto out; } - - ctxt->node =3D orignode2; } else { virReportError(VIR_ERR_INTERNAL_ERROR, _("unknown SCSI target capability type '%s' for= '%s'"), @@ -1004,7 +986,6 @@ virNodeDevCapSCSITargetParseXML(xmlXPathContextPtr ctx= t, ret =3D 0; =20 out: - ctxt->node =3D orignode; VIR_FREE(type); VIR_FREE(nodes); return ret; @@ -1019,12 +1000,12 @@ virNodeDevCapSCSIHostParseXML(xmlXPathContextPtr ct= xt, int create, const char *virt_type) { - xmlNodePtr orignode, *nodes =3D NULL; + VIR_XPATH_NODE_AUTORESTORE(ctxt); + xmlNodePtr *nodes =3D NULL; int ret =3D -1, n =3D 0; size_t i; char *type =3D NULL; =20 - orignode =3D ctxt->node; ctxt->node =3D node; =20 if (create =3D=3D EXISTING_DEVICE) { @@ -1061,12 +1042,8 @@ virNodeDevCapSCSIHostParseXML(xmlXPathContextPtr ctx= t, scsi_host->flags |=3D VIR_NODE_DEV_CAP_FLAG_HBA_VPORT_OPS; =20 } else if (STREQ(type, "fc_host")) { - - xmlNodePtr orignode2; - scsi_host->flags |=3D VIR_NODE_DEV_CAP_FLAG_HBA_FC_HOST; =20 - orignode2 =3D ctxt->node; ctxt->node =3D nodes[i]; =20 if (virNodeDevCapsDefParseString("string(./wwnn[1])", @@ -1098,8 +1075,6 @@ virNodeDevCapSCSIHostParseXML(xmlXPathContextPtr ctxt, &scsi_host->fabric_wwn) < 0) VIR_DEBUG("No fabric_wwn defined for '%s'", def->name); =20 - ctxt->node =3D orignode2; - } else { virReportError(VIR_ERR_INTERNAL_ERROR, _("unknown SCSI host capability type '%s' for '= %s'"), @@ -1114,7 +1089,6 @@ virNodeDevCapSCSIHostParseXML(xmlXPathContextPtr ctxt, =20 out: VIR_FREE(type); - ctxt->node =3D orignode; VIR_FREE(nodes); return ret; } @@ -1126,13 +1100,13 @@ virNodeDevCapNetParseXML(xmlXPathContextPtr ctxt, xmlNodePtr node, virNodeDevCapNetPtr net) { - xmlNodePtr orignode, lnk; + VIR_XPATH_NODE_AUTORESTORE(ctxt); + xmlNodePtr lnk; size_t i =3D -1; int ret =3D -1, n =3D -1; char *tmp =3D NULL; xmlNodePtr *nodes =3D NULL; =20 - orignode =3D ctxt->node; ctxt->node =3D node; =20 net->ifname =3D virXPathString("string(./interface[1])", ctxt); @@ -1192,7 +1166,6 @@ virNodeDevCapNetParseXML(xmlXPathContextPtr ctxt, =20 ret =3D 0; out: - ctxt->node =3D orignode; VIR_FREE(nodes); VIR_FREE(tmp); return ret; @@ -1205,10 +1178,9 @@ virNodeDevCapUSBInterfaceParseXML(xmlXPathContextPtr= ctxt, xmlNodePtr node, virNodeDevCapUSBIfPtr usb_if) { - xmlNodePtr orignode; + VIR_XPATH_NODE_AUTORESTORE(ctxt); int ret =3D -1; =20 - orignode =3D ctxt->node; ctxt->node =3D node; =20 if (virNodeDevCapsDefParseULong("number(./number[1])", ctxt, @@ -1239,7 +1211,6 @@ virNodeDevCapUSBInterfaceParseXML(xmlXPathContextPtr = ctxt, =20 ret =3D 0; out: - ctxt->node =3D orignode; return ret; } =20 @@ -1274,10 +1245,9 @@ virNodeDevCapUSBDevParseXML(xmlXPathContextPtr ctxt, xmlNodePtr node, virNodeDevCapUSBDevPtr usb_dev) { - xmlNodePtr orignode; + VIR_XPATH_NODE_AUTORESTORE(ctxt); int ret =3D -1; =20 - orignode =3D ctxt->node; ctxt->node =3D node; =20 if (virNodeDevCapsDefParseULong("number(./bus[1])", ctxt, @@ -1309,7 +1279,6 @@ virNodeDevCapUSBDevParseXML(xmlXPathContextPtr ctxt, =20 ret =3D 0; out: - ctxt->node =3D orignode; return ret; } =20 @@ -1319,7 +1288,7 @@ virNodeDevCapPCIDevIommuGroupParseXML(xmlXPathContext= Ptr ctxt, xmlNodePtr iommuGroupNode, virNodeDevCapPCIDevPtr pci_dev) { - xmlNodePtr origNode =3D ctxt->node; + VIR_XPATH_NODE_AUTORESTORE(ctxt); xmlNodePtr *addrNodes =3D NULL; char *numberStr =3D NULL; int nAddrNodes, ret =3D -1; @@ -1363,7 +1332,6 @@ virNodeDevCapPCIDevIommuGroupParseXML(xmlXPathContext= Ptr ctxt, =20 ret =3D 0; cleanup: - ctxt->node =3D origNode; VIR_FREE(numberStr); VIR_FREE(addrNodes); VIR_FREE(pciAddr); @@ -1376,7 +1344,7 @@ virPCIEDeviceInfoLinkParseXML(xmlXPathContextPtr ctxt, xmlNodePtr linkNode, virPCIELinkPtr lnk) { - xmlNodePtr origNode =3D ctxt->node; + VIR_XPATH_NODE_AUTORESTORE(ctxt); int ret =3D -1, speed; char *speedStr =3D NULL, *portStr =3D NULL; =20 @@ -1413,7 +1381,6 @@ virPCIEDeviceInfoLinkParseXML(xmlXPathContextPtr ctxt, cleanup: VIR_FREE(portStr); VIR_FREE(speedStr); - ctxt->node =3D origNode; return ret; } =20 @@ -1423,7 +1390,8 @@ virPCIEDeviceInfoParseXML(xmlXPathContextPtr ctxt, xmlNodePtr pciExpressNode, virPCIEDeviceInfoPtr pci_express) { - xmlNodePtr lnk, origNode =3D ctxt->node; + VIR_XPATH_NODE_AUTORESTORE(ctxt); + xmlNodePtr lnk; int ret =3D -1; =20 ctxt->node =3D pciExpressNode; @@ -1448,7 +1416,6 @@ virPCIEDeviceInfoParseXML(xmlXPathContextPtr ctxt, =20 ret =3D 0; cleanup: - ctxt->node =3D origNode; return ret; } =20 @@ -1595,7 +1562,7 @@ virNodeDevPCICapabilityParseXML(xmlXPathContextPtr ct= xt, virNodeDevCapPCIDevPtr pci_dev) { char *type =3D virXMLPropString(node, "type"); - xmlNodePtr orignode =3D ctxt->node; + VIR_XPATH_NODE_AUTORESTORE(ctxt); int ret =3D -1; =20 ctxt->node =3D node; @@ -1624,7 +1591,6 @@ virNodeDevPCICapabilityParseXML(xmlXPathContextPtr ct= xt, ret =3D 0; cleanup: VIR_FREE(type); - ctxt->node =3D orignode; return ret; } =20 @@ -1635,7 +1601,9 @@ virNodeDevCapPCIDevParseXML(xmlXPathContextPtr ctxt, xmlNodePtr node, virNodeDevCapPCIDevPtr pci_dev) { - xmlNodePtr orignode, iommuGroupNode, pciExpress; + VIR_XPATH_NODE_AUTORESTORE(ctxt); + xmlNodePtr iommuGroupNode; + xmlNodePtr pciExpress; xmlNodePtr *nodes =3D NULL; int n =3D 0; int ret =3D -1; @@ -1643,7 +1611,6 @@ virNodeDevCapPCIDevParseXML(xmlXPathContextPtr ctxt, char *tmp =3D NULL; size_t i =3D 0; =20 - orignode =3D ctxt->node; ctxt->node =3D node; =20 if ((tmp =3D virXPathString("string(./class[1])", ctxt))) { @@ -1737,7 +1704,6 @@ virNodeDevCapPCIDevParseXML(xmlXPathContextPtr ctxt, VIR_FREE(nodes); VIR_FREE(tmp); virPCIEDeviceInfoFree(pci_express); - ctxt->node =3D orignode; return ret; } =20 @@ -1750,11 +1716,10 @@ virNodeDevCapSystemParseXML(xmlXPathContextPtr ctxt, { virNodeDevCapSystemHardwarePtr hardware =3D &syscap->hardware; virNodeDevCapSystemFirmwarePtr firmware =3D &syscap->firmware; - xmlNodePtr orignode; + VIR_XPATH_NODE_AUTORESTORE(ctxt); int ret =3D -1; char *tmp; =20 - orignode =3D ctxt->node; ctxt->node =3D node; =20 syscap->product_name =3D virXPathString("string(./product[1])", ctxt); @@ -1784,7 +1749,6 @@ virNodeDevCapSystemParseXML(xmlXPathContextPtr ctxt, =20 ret =3D 0; out: - ctxt->node =3D orignode; return ret; } =20 @@ -1795,10 +1759,9 @@ virNodeDevCapMdevParseXML(xmlXPathContextPtr ctxt, xmlNodePtr node, virNodeDevCapMdevPtr mdev) { - xmlNodePtr orignode; + VIR_XPATH_NODE_AUTORESTORE(ctxt); int ret =3D -1; =20 - orignode =3D ctxt->node; ctxt->node =3D node; =20 if (!(mdev->type =3D virXPathString("string(./type[1]/@id)", ctxt))) { @@ -1817,7 +1780,6 @@ virNodeDevCapMdevParseXML(xmlXPathContextPtr ctxt, =20 ret =3D 0; out: - ctxt->node =3D orignode; return ret; } =20 diff --git a/src/conf/numa_conf.c b/src/conf/numa_conf.c index 6f1257fd8e..09811cb51b 100644 --- a/src/conf/numa_conf.c +++ b/src/conf/numa_conf.c @@ -846,7 +846,7 @@ virDomainNumaDefCPUParseXML(virDomainNumaPtr def, xmlXPathContextPtr ctxt) { xmlNodePtr *nodes =3D NULL; - xmlNodePtr oldNode =3D ctxt->node; + VIR_XPATH_NODE_AUTORESTORE(ctxt); char *tmp =3D NULL; int n; size_t i, j; @@ -963,7 +963,6 @@ virDomainNumaDefCPUParseXML(virDomainNumaPtr def, ret =3D 0; =20 cleanup: - ctxt->node =3D oldNode; VIR_FREE(nodes); VIR_FREE(tmp); return ret; diff --git a/src/conf/snapshot_conf.c b/src/conf/snapshot_conf.c index 98c296b276..857d04c476 100644 --- a/src/conf/snapshot_conf.c +++ b/src/conf/snapshot_conf.c @@ -144,7 +144,7 @@ virDomainSnapshotDiskDefParseXML(xmlNodePtr node, char *type =3D NULL; char *driver =3D NULL; xmlNodePtr cur; - xmlNodePtr saved =3D ctxt->node; + VIR_XPATH_NODE_AUTORESTORE(ctxt); =20 ctxt->node =3D node; =20 @@ -205,7 +205,6 @@ virDomainSnapshotDiskDefParseXML(xmlNodePtr node, =20 ret =3D 0; cleanup: - ctxt->node =3D saved; =20 VIR_FREE(driver); VIR_FREE(snapshot); diff --git a/src/conf/storage_adapter_conf.c b/src/conf/storage_adapter_con= f.c index 18bcb5eb9e..015e572630 100644 --- a/src/conf/storage_adapter_conf.c +++ b/src/conf/storage_adapter_conf.c @@ -178,7 +178,7 @@ virStorageAdapterParseXML(virStorageAdapterPtr adapter, xmlXPathContextPtr ctxt) { int ret =3D -1; - xmlNodePtr relnode =3D ctxt->node; + VIR_XPATH_NODE_AUTORESTORE(ctxt); char *adapter_type =3D NULL; =20 ctxt->node =3D node; @@ -208,7 +208,6 @@ virStorageAdapterParseXML(virStorageAdapterPtr adapter, ret =3D 0; =20 cleanup: - ctxt->node =3D relnode; VIR_FREE(adapter_type); return ret; } diff --git a/src/conf/storage_conf.c b/src/conf/storage_conf.c index 626ddd9528..5669b92f8d 100644 --- a/src/conf/storage_conf.c +++ b/src/conf/storage_conf.c @@ -727,7 +727,7 @@ virStorageDefParsePerms(xmlXPathContextPtr ctxt, { long long val; int ret =3D -1; - xmlNodePtr relnode; + VIR_XPATH_NODE_AUTORESTORE(ctxt); xmlNodePtr node; g_autofree char *mode =3D NULL; =20 @@ -741,7 +741,6 @@ virStorageDefParsePerms(xmlXPathContextPtr ctxt, return 0; } =20 - relnode =3D ctxt->node; ctxt->node =3D node; =20 if ((mode =3D virXPathString("string(./mode)", ctxt))) { @@ -791,7 +790,6 @@ virStorageDefParsePerms(xmlXPathContextPtr ctxt, =20 ret =3D 0; error: - ctxt->node =3D relnode; return ret; } =20 diff --git a/src/conf/virsavecookie.c b/src/conf/virsavecookie.c index bdc22bb324..7fc951afe2 100644 --- a/src/conf/virsavecookie.c +++ b/src/conf/virsavecookie.c @@ -57,7 +57,7 @@ virSaveCookieParse(xmlXPathContextPtr ctxt, virObjectPtr *obj, virSaveCookieCallbacksPtr saveCookie) { - xmlNodePtr node =3D ctxt->node; + VIR_XPATH_NODE_AUTORESTORE(ctxt); int ret =3D -1; =20 *obj =3D NULL; @@ -70,7 +70,6 @@ virSaveCookieParse(xmlXPathContextPtr ctxt, ret =3D virSaveCookieParseNode(ctxt, obj, saveCookie); =20 cleanup: - ctxt->node =3D node; return ret; } =20 diff --git a/src/cpu/cpu_map.c b/src/cpu/cpu_map.c index dffb6ea7e8..4465ebfa7b 100644 --- a/src/cpu/cpu_map.c +++ b/src/cpu/cpu_map.c @@ -40,14 +40,12 @@ loadData(const char *mapfile, void *data) { int ret =3D -1; - xmlNodePtr ctxt_node; + VIR_XPATH_NODE_AUTORESTORE(ctxt); xmlNodePtr *nodes =3D NULL; int n; size_t i; int rv; =20 - ctxt_node =3D ctxt->node; - if ((n =3D virXPathNodeSet(element, ctxt, &nodes)) < 0) goto cleanup; =20 @@ -58,7 +56,6 @@ loadData(const char *mapfile, } =20 for (i =3D 0; i < n; i++) { - xmlNodePtr old =3D ctxt->node; char *name =3D virXMLPropString(nodes[i], "name"); if (!name) { virReportError(VIR_ERR_INTERNAL_ERROR, @@ -68,7 +65,6 @@ loadData(const char *mapfile, VIR_DEBUG("Load %s name %s", element, name); ctxt->node =3D nodes[i]; rv =3D callback(ctxt, name, data); - ctxt->node =3D old; VIR_FREE(name); if (rv < 0) goto cleanup; @@ -77,7 +73,6 @@ loadData(const char *mapfile, ret =3D 0; =20 cleanup: - ctxt->node =3D ctxt_node; VIR_FREE(nodes); =20 return ret; @@ -135,13 +130,11 @@ loadIncludes(xmlXPathContextPtr ctxt, void *data) { int ret =3D -1; - xmlNodePtr ctxt_node; + VIR_XPATH_NODE_AUTORESTORE(ctxt); xmlNodePtr *nodes =3D NULL; int n; size_t i; =20 - ctxt_node =3D ctxt->node; - n =3D virXPathNodeSet("include", ctxt, &nodes); if (n < 0) goto cleanup; @@ -164,7 +157,6 @@ loadIncludes(xmlXPathContextPtr ctxt, ret =3D 0; =20 cleanup: - ctxt->node =3D ctxt_node; VIR_FREE(nodes); =20 return ret; diff --git a/src/cpu/cpu_x86.c b/src/cpu/cpu_x86.c index e3c553e943..bf26cf4e76 100644 --- a/src/cpu/cpu_x86.c +++ b/src/cpu/cpu_x86.c @@ -1486,7 +1486,7 @@ x86ModelParseSignatures(virCPUx86ModelPtr model, xmlXPathContextPtr ctxt) { g_autofree xmlNodePtr *nodes =3D NULL; - xmlNodePtr root =3D ctxt->node; + VIR_XPATH_NODE_AUTORESTORE(ctxt); size_t i; int n; =20 @@ -1527,7 +1527,6 @@ x86ModelParseSignatures(virCPUx86ModelPtr model, return -1; } =20 - ctxt->node =3D root; return 0; } =20 diff --git a/src/lxc/lxc_domain.c b/src/lxc/lxc_domain.c index 59f803837a..145997d8dc 100644 --- a/src/lxc/lxc_domain.c +++ b/src/lxc/lxc_domain.c @@ -211,7 +211,7 @@ lxcDomainDefNamespaceParse(xmlXPathContextPtr ctxt, lxcDomainDefPtr lxcDef =3D NULL; xmlNodePtr *nodes =3D NULL; bool uses_lxc_ns =3D false; - xmlNodePtr node; + VIR_XPATH_NODE_AUTORESTORE(ctxt); int feature; int n; char *tmp =3D NULL; @@ -220,7 +220,6 @@ lxcDomainDefNamespaceParse(xmlXPathContextPtr ctxt, if (VIR_ALLOC(lxcDef) < 0) return -1; =20 - node =3D ctxt->node; if ((n =3D virXPathNodeSet("./lxc:namespace/*", ctxt, &nodes)) < 0) goto error; uses_lxc_ns |=3D n > 0; @@ -259,7 +258,6 @@ lxcDomainDefNamespaceParse(xmlXPathContextPtr ctxt, } } VIR_FREE(nodes); - ctxt->node =3D node; if (uses_lxc_ns) *data =3D lxcDef; else diff --git a/src/util/virstorageencryption.c b/src/util/virstorageencryptio= n.c index 6765fdc23a..34c356b5a3 100644 --- a/src/util/virstorageencryption.c +++ b/src/util/virstorageencryption.c @@ -143,7 +143,7 @@ static virStorageEncryptionSecretPtr virStorageEncryptionSecretParse(xmlXPathContextPtr ctxt, xmlNodePtr node) { - xmlNodePtr old_node; + VIR_XPATH_NODE_AUTORESTORE(ctxt); virStorageEncryptionSecretPtr ret; char *type_str =3D NULL; char *uuidstr =3D NULL; @@ -152,7 +152,6 @@ virStorageEncryptionSecretParse(xmlXPathContextPtr ctxt, if (VIR_ALLOC(ret) < 0) return NULL; =20 - old_node =3D ctxt->node; ctxt->node =3D node; =20 if (!(type_str =3D virXPathString("string(./@type)", ctxt))) { @@ -173,7 +172,6 @@ virStorageEncryptionSecretParse(xmlXPathContextPtr ctxt, =20 VIR_FREE(type_str); =20 - ctxt->node =3D old_node; return ret; =20 cleanup: @@ -181,7 +179,6 @@ virStorageEncryptionSecretParse(xmlXPathContextPtr ctxt, virStorageEncryptionSecretFree(ret); VIR_FREE(uuidstr); VIR_FREE(usagestr); - ctxt->node =3D old_node; return NULL; } =20 @@ -244,7 +241,7 @@ virStorageEncryptionPtr virStorageEncryptionParseNode(xmlNodePtr node, xmlXPathContextPtr ctxt) { - xmlNodePtr saveNode =3D ctxt->node; + VIR_XPATH_NODE_AUTORESTORE(ctxt); xmlNodePtr *nodes =3D NULL; virStorageEncryptionPtr encdef =3D NULL; virStorageEncryptionPtr ret =3D NULL; @@ -313,7 +310,6 @@ virStorageEncryptionParseNode(xmlNodePtr node, VIR_FREE(format_str); VIR_FREE(nodes); virStorageEncryptionFree(encdef); - ctxt->node =3D saveNode; =20 return ret; } diff --git a/src/util/virstoragefile.c b/src/util/virstoragefile.c index 535a94e239..a6357abb08 100644 --- a/src/util/virstoragefile.c +++ b/src/util/virstoragefile.c @@ -1781,7 +1781,7 @@ virStorageAuthDefPtr virStorageAuthDefParse(xmlNodePtr node, xmlXPathContextPtr ctxt) { - xmlNodePtr saveNode =3D ctxt->node; + VIR_XPATH_NODE_AUTORESTORE(ctxt); virStorageAuthDefPtr ret =3D NULL; xmlNodePtr secretnode =3D NULL; g_autoptr(virStorageAuthDef) authdef =3D NULL; @@ -1832,7 +1832,6 @@ virStorageAuthDefParse(xmlNodePtr node, ret =3D g_steal_pointer(&authdef); =20 cleanup: - ctxt->node =3D saveNode; =20 return ret; } diff --git a/tools/virsh-domain.c b/tools/virsh-domain.c index 61cd72f714..069e3de064 100644 --- a/tools/virsh-domain.c +++ b/tools/virsh-domain.c @@ -6818,7 +6818,7 @@ virshDomainGetVcpuBitmap(vshControl *ctl, xmlDocPtr xml =3D NULL; xmlXPathContextPtr ctxt =3D NULL; xmlNodePtr *nodes =3D NULL; - xmlNodePtr old; + VIR_XPATH_NODE_AUTORESTORE(ctxt); int nnodes; size_t i; unsigned int curvcpus =3D 0; @@ -6853,8 +6853,6 @@ virshDomainGetVcpuBitmap(vshControl *ctl, goto cleanup; } =20 - old =3D ctxt->node; - for (i =3D 0; i < nnodes; i++) { ctxt->node =3D nodes[i]; =20 @@ -6868,8 +6866,6 @@ virshDomainGetVcpuBitmap(vshControl *ctl, VIR_FREE(online); } =20 - ctxt->node =3D old; - if (virBitmapCountBits(ret) !=3D curvcpus) { vshError(ctl, "%s", _("Failed to retrieve vcpu state bitmap")); virBitmapFree(ret); --=20 2.26.2