[PATCH 30/43] conf: network: Remove virNetworkDefParseNode

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

 



Both callers can be easily converted to call virNetworkDefParseXML
directly.

Signed-off-by: Peter Krempa <pkrempa@xxxxxxxxxx>
---
 src/conf/network_conf.c  | 37 ++++++++-----------------------------
 src/conf/network_conf.h  |  5 -----
 src/libvirt_private.syms |  1 -
 src/test/test_driver.c   |  8 ++++----
 4 files changed, 12 insertions(+), 39 deletions(-)

diff --git a/src/conf/network_conf.c b/src/conf/network_conf.c
index b1d77a80c3..3574c0214b 100644
--- a/src/conf/network_conf.c
+++ b/src/conf/network_conf.c
@@ -2032,15 +2032,17 @@ virNetworkDefParse(const char *xmlStr,
                    bool validate)
 {
     g_autoptr(xmlDoc) xml = NULL;
-    virNetworkDef *def = NULL;
+    g_autoptr(xmlXPathContext) ctxt = NULL;
     int keepBlanksDefault = xmlKeepBlanksDefault(0);

-    if ((xml = virXMLParse(filename, xmlStr, _("(network_definition)"),
-                           NULL, NULL, "network.rng", validate)))
-        def = virNetworkDefParseNode(xml, xmlDocGetRootElement(xml), xmlopt);
-
+    xml = virXMLParse(filename, xmlStr, _("(network_definition)"),
+                      "network", &ctxt, "network.rng", validate);
     xmlKeepBlanksDefault(keepBlanksDefault);
-    return def;
+
+    if (!xml)
+        return NULL;
+
+    return virNetworkDefParseXML(ctxt, xmlopt);
 }


@@ -2061,29 +2063,6 @@ virNetworkDefParseFile(const char *filename,
 }


-virNetworkDef *
-virNetworkDefParseNode(xmlDocPtr xml,
-                       xmlNodePtr root,
-                       virNetworkXMLOption *xmlopt)
-{
-    g_autoptr(xmlXPathContext) ctxt = NULL;
-
-    if (!virXMLNodeNameEqual(root, "network")) {
-        virReportError(VIR_ERR_XML_ERROR,
-                       _("unexpected root element <%s>, "
-                         "expecting <network>"),
-                       root->name);
-        return NULL;
-    }
-
-    if (!(ctxt = virXMLXPathContextNew(xml)))
-        return NULL;
-
-    ctxt->node = root;
-    return virNetworkDefParseXML(ctxt, xmlopt);
-}
-
-
 static int
 virNetworkDNSDefFormat(virBuffer *buf,
                        const virNetworkDNSDef *def)
diff --git a/src/conf/network_conf.h b/src/conf/network_conf.h
index 48b07ea13c..49d3ce6b30 100644
--- a/src/conf/network_conf.h
+++ b/src/conf/network_conf.h
@@ -333,11 +333,6 @@ virNetworkDef *
 virNetworkDefParseFile(const char *filename,
                        virNetworkXMLOption *xmlopt);

-virNetworkDef *
-virNetworkDefParseNode(xmlDocPtr xml,
-                       xmlNodePtr root,
-                       virNetworkXMLOption *xmlopt);
-
 char *
 virNetworkDefFormat(const virNetworkDef *def,
                     virNetworkXMLOption *xmlopt,
diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
index a24e0db5d7..3ce2cc1a7e 100644
--- a/src/libvirt_private.syms
+++ b/src/libvirt_private.syms
@@ -829,7 +829,6 @@ virNetworkDefFree;
 virNetworkDefGetIPByIndex;
 virNetworkDefGetRouteByIndex;
 virNetworkDefParseFile;
-virNetworkDefParseNode;
 virNetworkDefParseString;
 virNetworkDefParseXML;
 virNetworkDefUpdateSection;
diff --git a/src/test/test_driver.c b/src/test/test_driver.c
index 5f98c05c34..4c4eabc9fc 100644
--- a/src/test/test_driver.c
+++ b/src/test/test_driver.c
@@ -1074,6 +1074,7 @@ testParseNetworks(testDriver *privconn,
                   const char *file,
                   xmlXPathContextPtr ctxt)
 {
+    VIR_XPATH_NODE_AUTORESTORE(ctxt)
     int num;
     size_t i;
     virNetworkObj *obj;
@@ -1085,12 +1086,11 @@ testParseNetworks(testDriver *privconn,

     for (i = 0; i < num; i++) {
         g_autoptr(virNetworkDef) def = NULL;
-        xmlNodePtr node = testParseXMLDocFromFile(nodes[i], file);
-        if (!node)
+
+        if (!(ctxt->node = testParseXMLDocFromFile(nodes[i], file)))
             return -1;

-        def = virNetworkDefParseNode(ctxt->doc, node, NULL);
-        if (!def)
+        if (!(def = virNetworkDefParseXML(ctxt, NULL)))
             return -1;

         if (!(obj = virNetworkObjAssignDef(privconn->networks, def, 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