[PATCH 2/2] conf: Avoid checking root element name in virDomainDefParseNode

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

 



The only caller for which this check makes sense is virDomainDefParse.
Thus the check should be moved there.

Signed-off-by: Jiri Denemark <jdenemar@xxxxxxxxxx>
---
 src/conf/domain_conf.c | 21 +++++++++++----------
 1 file changed, 11 insertions(+), 10 deletions(-)

diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 17ddebb575..b3b8c543d5 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -21520,12 +21520,21 @@ virDomainDefParse(const char *xmlStr,
     xmlDocPtr xml = NULL;
     virDomainDefPtr def = NULL;
     int keepBlanksDefault = xmlKeepBlanksDefault(0);
+    xmlNodePtr root;
 
     if (!(xml = virXMLParse(filename, xmlStr, _("(domain_definition)"))))
         goto cleanup;
 
-    def = virDomainDefParseNode(xml, xmlDocGetRootElement(xml), caps,
-                                xmlopt, parseOpaque, flags);
+    root = xmlDocGetRootElement(xml);
+    if (!virXMLNodeNameEqual(root, "domain")) {
+        virReportError(VIR_ERR_XML_ERROR,
+                       _("unexpected root element <%s>, "
+                         "expecting <domain>"),
+                       root->name);
+        goto cleanup;
+    }
+
+    def = virDomainDefParseNode(xml, root, caps, xmlopt, parseOpaque, flags);
 
  cleanup:
     xmlFreeDoc(xml);
@@ -21566,14 +21575,6 @@ virDomainDefParseNode(xmlDocPtr xml,
     virDomainDefPtr def = NULL;
     virDomainDefPtr ret = NULL;
 
-    if (!virXMLNodeNameEqual(root, "domain")) {
-        virReportError(VIR_ERR_XML_ERROR,
-                       _("unexpected root element <%s>, "
-                         "expecting <domain>"),
-                       root->name);
-        goto cleanup;
-    }
-
     ctxt = xmlXPathNewContext(xml);
     if (ctxt == NULL) {
         virReportOOMError();
-- 
2.23.0

--
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