conf: network: Remove virNetworkDefParseNode

Both callers can be easily converted to call virNetworkDefParseXML
directly.

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:17:25 +02:00
parent be43d74b63
commit e56e82a654
4 changed files with 12 additions and 39 deletions

View File

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

View File

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

View File

@ -829,7 +829,6 @@ virNetworkDefFree;
virNetworkDefGetIPByIndex;
virNetworkDefGetRouteByIndex;
virNetworkDefParseFile;
virNetworkDefParseNode;
virNetworkDefParseString;
virNetworkDefParseXML;
virNetworkDefUpdateSection;

View File

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