virDomainObjParseFile is the only caller of virDomainObjParseNode.
The code can be merged into it, simplified by using virXMLParse and
the function removed.

Signed-off-by: Peter Krempa <pkre...@redhat.com>
---
 src/conf/domain_conf.c   | 36 ++++++------------------------------
 src/conf/domain_conf.h   |  4 ----
 src/libvirt_private.syms |  1 -
 3 files changed, 6 insertions(+), 35 deletions(-)

diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 5bb5cfa500..03f4b2fe33 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -19155,48 +19155,24 @@ virDomainDefParseNode(xmlDocPtr xml,


 virDomainObj *
-virDomainObjParseNode(xmlDocPtr xml,
-                      xmlNodePtr root,
+virDomainObjParseFile(const char *filename,
                       virDomainXMLOption *xmlopt,
                       unsigned int flags)
 {
+    g_autoptr(xmlDoc) xml = NULL;
     g_autoptr(xmlXPathContext) ctxt = NULL;
+    int keepBlanksDefault = xmlKeepBlanksDefault(0);

-    if (!virXMLNodeNameEqual(root, "domstatus")) {
-        virReportError(VIR_ERR_XML_ERROR,
-                       _("unexpected root element <%s>, "
-                         "expecting <domstatus>"),
-                       root->name);
-        return NULL;
-    }
+    xml = virXMLParse(filename, NULL, NULL, "domstatus", &ctxt, NULL, false);
+    xmlKeepBlanksDefault(keepBlanksDefault);

-    if (!(ctxt = virXMLXPathContextNew(xml)))
+    if (!xml)
         return NULL;

-    ctxt->node = root;
     return virDomainObjParseXML(ctxt, xmlopt, flags);
 }


-virDomainObj *
-virDomainObjParseFile(const char *filename,
-                      virDomainXMLOption *xmlopt,
-                      unsigned int flags)
-{
-    g_autoptr(xmlDoc) xml = NULL;
-    virDomainObj *obj = NULL;
-    int keepBlanksDefault = xmlKeepBlanksDefault(0);
-
-    if ((xml = virXMLParseFile(filename))) {
-        obj = virDomainObjParseNode(xml, xmlDocGetRootElement(xml),
-                                    xmlopt, flags);
-    }
-
-    xmlKeepBlanksDefault(keepBlanksDefault);
-    return obj;
-}
-
-
 static bool
 virDomainTimerDefCheckABIStability(virDomainTimerDef *src,
                                    virDomainTimerDef *dst)
diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h
index 352b88eae5..6eab1056c1 100644
--- a/src/conf/domain_conf.h
+++ b/src/conf/domain_conf.h
@@ -3617,10 +3617,6 @@ virDomainDef *virDomainDefParseNode(xmlDocPtr doc,
                                     virDomainXMLOption *xmlopt,
                                     void *parseOpaque,
                                     unsigned int flags);
-virDomainObj *virDomainObjParseNode(xmlDocPtr xml,
-                                    xmlNodePtr root,
-                                    virDomainXMLOption *xmlopt,
-                                    unsigned int flags);
 virDomainObj *virDomainObjParseFile(const char *filename,
                                     virDomainXMLOption *xmlopt,
                                     unsigned int flags);
diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
index 5714e0c114..00cb07709d 100644
--- a/src/libvirt_private.syms
+++ b/src/libvirt_private.syms
@@ -582,7 +582,6 @@ virDomainObjIsFailedPostcopy;
 virDomainObjIsPostcopy;
 virDomainObjNew;
 virDomainObjParseFile;
-virDomainObjParseNode;
 virDomainObjRemoveTransientDef;
 virDomainObjSave;
 virDomainObjSetDefTransient;
-- 
2.37.3

Reply via email to