conf: Avoid checking root element name in virDomainDefParseNode

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

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
This commit is contained in:
Jiri Denemark 2019-09-09 22:26:12 +02:00
parent 9bcbc52ef1
commit 29307fa84d

View File

@ -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();