[PATCH 5/5] qemu: Use VIR_XPATH_NODE_AUTORESTORE when XPath context is modified

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Use the new helper when moving around the current node of the XPath
context.

Signed-off-by: Peter Krempa <pkrempa@xxxxxxxxxx>
---
 src/qemu/qemu_capabilities.c     | 3 +--
 src/qemu/qemu_domain.c           | 6 ++----
 src/qemu/qemu_migration_cookie.c | 9 +++------
 3 files changed, 6 insertions(+), 12 deletions(-)

diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c
index b48bcbebee..1d1bb80b39 100644
--- a/src/qemu/qemu_capabilities.c
+++ b/src/qemu/qemu_capabilities.c
@@ -3042,7 +3042,7 @@ virQEMUCapsLoadHostCPUModelInfo(virQEMUCapsPtr qemuCaps,
     char *str = NULL;
     xmlNodePtr hostCPUNode;
     xmlNodePtr *nodes = NULL;
-    xmlNodePtr oldnode = ctxt->node;
+    VIR_XPATH_NODE_AUTORESTORE(ctxt);
     qemuMonitorCPUModelInfoPtr hostCPU = NULL;
     int ret = -1;
     size_t i;
@@ -3160,7 +3160,6 @@ virQEMUCapsLoadHostCPUModelInfo(virQEMUCapsPtr qemuCaps,
     ret = 0;

  cleanup:
-    ctxt->node = oldnode;
     VIR_FREE(str);
     VIR_FREE(nodes);
     qemuMonitorCPUModelInfoFree(hostCPU);
diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
index 59fe1eb401..690a57521e 100644
--- a/src/qemu/qemu_domain.c
+++ b/src/qemu/qemu_domain.c
@@ -2717,7 +2717,7 @@ qemuDomainObjPrivateXMLParseJobNBDSource(xmlNodePtr node,
                                          xmlXPathContextPtr ctxt,
                                          virDomainDiskDefPtr disk)
 {
-    xmlNodePtr savedNode = ctxt->node;
+    VIR_XPATH_NODE_AUTORESTORE(ctxt);
     qemuDomainDiskPrivatePtr diskPriv = QEMU_DOMAIN_DISK_PRIVATE(disk);
     char *format = NULL;
     char *type = NULL;
@@ -2772,7 +2772,6 @@ qemuDomainObjPrivateXMLParseJobNBDSource(xmlNodePtr node,
  cleanup:
     VIR_FREE(format);
     VIR_FREE(type);
-    ctxt->node = savedNode;
     return ret;
 }

@@ -2827,7 +2826,7 @@ qemuDomainObjPrivateXMLParseJob(virDomainObjPtr vm,
                                 qemuDomainObjPrivatePtr priv,
                                 xmlXPathContextPtr ctxt)
 {
-    xmlNodePtr savedNode = ctxt->node;
+    VIR_XPATH_NODE_AUTORESTORE(ctxt);
     char *tmp = NULL;
     int ret = -1;

@@ -2884,7 +2883,6 @@ qemuDomainObjPrivateXMLParseJob(virDomainObjPtr vm,
     ret = 0;

  cleanup:
-    ctxt->node = savedNode;
     VIR_FREE(tmp);
     return ret;
 }
diff --git a/src/qemu/qemu_migration_cookie.c b/src/qemu/qemu_migration_cookie.c
index ae2546f98b..74b8575a91 100644
--- a/src/qemu/qemu_migration_cookie.c
+++ b/src/qemu/qemu_migration_cookie.c
@@ -946,7 +946,7 @@ qemuMigrationCookieNetworkXMLParse(xmlXPathContextPtr ctxt)
     int n;
     xmlNodePtr *interfaces = NULL;
     char *vporttype;
-    xmlNodePtr save_ctxt = ctxt->node;
+    VIR_XPATH_NODE_AUTORESTORE(ctxt);

     if (VIR_ALLOC(optr) < 0)
         goto error;
@@ -978,7 +978,6 @@ qemuMigrationCookieNetworkXMLParse(xmlXPathContextPtr ctxt)
     VIR_FREE(interfaces);

  cleanup:
-    ctxt->node = save_ctxt;
     return optr;

  error:
@@ -997,7 +996,7 @@ qemuMigrationCookieNBDXMLParse(xmlXPathContextPtr ctxt)
     size_t i;
     int n;
     xmlNodePtr *disks = NULL;
-    xmlNodePtr save_ctxt = ctxt->node;
+    VIR_XPATH_NODE_AUTORESTORE(ctxt);

     if (VIR_ALLOC(ret) < 0)
         goto error;
@@ -1044,7 +1043,6 @@ qemuMigrationCookieNBDXMLParse(xmlXPathContextPtr ctxt)
     VIR_FREE(port);
     VIR_FREE(capacity);
     VIR_FREE(disks);
-    ctxt->node = save_ctxt;
     return ret;
  error:
     qemuMigrationCookieNBDFree(ret);
@@ -1058,7 +1056,7 @@ qemuMigrationCookieStatisticsXMLParse(xmlXPathContextPtr ctxt)
 {
     qemuDomainJobInfoPtr jobInfo = NULL;
     qemuMonitorMigrationStats *stats;
-    xmlNodePtr save_ctxt = ctxt->node;
+    VIR_XPATH_NODE_AUTORESTORE(ctxt);

     if (!(ctxt->node = virXPathNode("./statistics", ctxt)))
         goto cleanup;
@@ -1136,7 +1134,6 @@ qemuMigrationCookieStatisticsXMLParse(xmlXPathContextPtr ctxt)
     virXPathInt("string(./" VIR_DOMAIN_JOB_AUTO_CONVERGE_THROTTLE "[1])",
                 ctxt, &stats->cpu_throttle_percentage);
  cleanup:
-    ctxt->node = save_ctxt;
     return jobInfo;
 }

-- 
2.20.1

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list



[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]

  Powered by Linux