[PATCH 04/43] vbox: snapshot_conf: Don't allocate XPath context explicitly

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

 



Use the one provided via virXMLParse.

Signed-off-by: Peter Krempa <pkrempa@xxxxxxxxxx>
---
 src/vbox/vbox_snapshot_conf.c | 19 +++----------------
 1 file changed, 3 insertions(+), 16 deletions(-)

diff --git a/src/vbox/vbox_snapshot_conf.c b/src/vbox/vbox_snapshot_conf.c
index 6dce9cdf0f..e175f1964e 100644
--- a/src/vbox/vbox_snapshot_conf.c
+++ b/src/vbox/vbox_snapshot_conf.c
@@ -584,15 +584,12 @@ virVBoxSnapshotConfLoadVboxFile(const char *filePath,

     machineDescription = g_new0(virVBoxSnapshotConfMachine, 1);

-    xml = virXMLParse(filePath, NULL, NULL, NULL, NULL, NULL, false);
+    xml = virXMLParse(filePath, NULL, NULL, NULL, &xPathContext, NULL, false);
     if (xml == NULL) {
         virReportError(VIR_ERR_XML_ERROR, "%s",
                        _("Unable to parse the xml"));
         goto cleanup;
     }
-    if (!(xPathContext = virXMLXPathContextNew(xml)))
-        goto cleanup;
-
     if (xmlXPathRegisterNs(xPathContext,
                            BAD_CAST "vbox",
                            BAD_CAST VBOX_SETTINGS_NS) < 0) {
@@ -603,8 +600,6 @@ virVBoxSnapshotConfLoadVboxFile(const char *filePath,
     }

     /* Retrieve MachineNode */
-    cur = xmlDocGetRootElement(xml);
-    xPathContext->node = cur;
     machineNode = virXPathNode("./vbox:Machine", xPathContext);
     if (machineNode == NULL) {
         virReportError(VIR_ERR_XML_ERROR, "%s",
@@ -1214,17 +1209,13 @@ virVBoxSnapshotConfGetRWDisksPathsFromLibvirtXML(const char *filePath,
                        _("filePath is null"));
         goto cleanup;
     }
-    xml = virXMLParse(filePath, NULL, NULL, NULL, NULL, NULL, false);
+    xml = virXMLParse(filePath, NULL, NULL, NULL, &xPathContext, NULL, false);
     if (xml == NULL) {
         virReportError(VIR_ERR_XML_ERROR, "%s",
                        _("Unable to parse the xml"));
         goto cleanup;
     }

-    if (!(xPathContext = virXMLXPathContextNew(xml)))
-        goto cleanup;
-
-    xPathContext->node = xmlDocGetRootElement(xml);
     if ((nodeSize = virXPathNodeSet("/domainsnapshot/disks/disk",
                                     xPathContext, &nodes)) < 0)
         goto cleanup;
@@ -1271,17 +1262,13 @@ virVBoxSnapshotConfGetRODisksPathsFromLibvirtXML(const char *filePath,
                        _("filePath is null"));
         goto cleanup;
     }
-    xml = virXMLParse(filePath, NULL, NULL, NULL, NULL, NULL, false);
+    xml = virXMLParse(filePath, NULL, NULL, NULL, &xPathContext, NULL, false);
     if (xml == NULL) {
         virReportError(VIR_ERR_XML_ERROR, "%s",
                        _("Unable to parse the xml"));
         goto cleanup;
     }

-    if (!(xPathContext = virXMLXPathContextNew(xml)))
-        goto cleanup;
-
-    xPathContext->node = xmlDocGetRootElement(xml);
     if ((nodeSize = virXPathNodeSet("/domainsnapshot/domain/devices/disk",
                                     xPathContext,
                                     &nodes)) < 0)
-- 
2.37.3




[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