conf: domain: Remove virDomainObjParseNode

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 <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
This commit is contained in:
Peter Krempa 2022-09-23 13:34:36 +02:00
parent 1eb67d24de
commit d4b6496f24
3 changed files with 7 additions and 36 deletions

View File

@ -19154,46 +19154,22 @@ virDomainDefParseNode(xmlDocPtr xml,
}
virDomainObj *
virDomainObjParseNode(xmlDocPtr xml,
xmlNodePtr root,
virDomainXMLOption *xmlopt,
unsigned int flags)
{
g_autoptr(xmlXPathContext) ctxt = NULL;
if (!virXMLNodeNameEqual(root, "domstatus")) {
virReportError(VIR_ERR_XML_ERROR,
_("unexpected root element <%s>, "
"expecting <domstatus>"),
root->name);
return NULL;
}
if (!(ctxt = virXMLXPathContextNew(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;
g_autoptr(xmlXPathContext) ctxt = NULL;
int keepBlanksDefault = xmlKeepBlanksDefault(0);
if ((xml = virXMLParseFile(filename))) {
obj = virDomainObjParseNode(xml, xmlDocGetRootElement(xml),
xmlopt, flags);
}
xml = virXMLParse(filename, NULL, NULL, "domstatus", &ctxt, NULL, false);
xmlKeepBlanksDefault(keepBlanksDefault);
return obj;
if (!xml)
return NULL;
return virDomainObjParseXML(ctxt, xmlopt, flags);
}

View File

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

View File

@ -582,7 +582,6 @@ virDomainObjIsFailedPostcopy;
virDomainObjIsPostcopy;
virDomainObjNew;
virDomainObjParseFile;
virDomainObjParseNode;
virDomainObjRemoveTransientDef;
virDomainObjSave;
virDomainObjSetDefTransient;