mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-12-22 05:35:25 +00:00
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:
parent
be43d74b63
commit
e56e82a654
@ -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)
|
||||
|
@ -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,
|
||||
|
@ -829,7 +829,6 @@ virNetworkDefFree;
|
||||
virNetworkDefGetIPByIndex;
|
||||
virNetworkDefGetRouteByIndex;
|
||||
virNetworkDefParseFile;
|
||||
virNetworkDefParseNode;
|
||||
virNetworkDefParseString;
|
||||
virNetworkDefParseXML;
|
||||
virNetworkDefUpdateSection;
|
||||
|
@ -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)))
|
||||
|
Loading…
Reference in New Issue
Block a user