mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-12-22 17:34:18 +03:00
conf: nwfilter: Remove virNWFilterDefParseNode
Use virXMLParse to fetch the XML context and validate the top level XML element name so that virNWFilterDefParseNode is no longer needed. Signed-off-by: Peter Krempa <pkrempa@redhat.com> Reviewed-by: Ján Tomko <jtomko@redhat.com>
This commit is contained in:
parent
573f764ee4
commit
2a8998d427
@ -2685,42 +2685,20 @@ virNWFilterDefParseXML(xmlXPathContextPtr ctxt)
|
||||
}
|
||||
|
||||
|
||||
virNWFilterDef *
|
||||
virNWFilterDefParseNode(xmlDocPtr xml,
|
||||
xmlNodePtr root)
|
||||
{
|
||||
g_autoptr(xmlXPathContext) ctxt = NULL;
|
||||
|
||||
if (STRNEQ((const char *)root->name, "filter")) {
|
||||
virReportError(VIR_ERR_XML_ERROR,
|
||||
"%s",
|
||||
_("unknown root element for nw filter"));
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (!(ctxt = virXMLXPathContextNew(xml)))
|
||||
return NULL;
|
||||
|
||||
ctxt->node = root;
|
||||
return virNWFilterDefParseXML(ctxt);
|
||||
}
|
||||
|
||||
|
||||
static virNWFilterDef *
|
||||
virNWFilterDefParse(const char *xmlStr,
|
||||
const char *filename,
|
||||
unsigned int flags)
|
||||
{
|
||||
virNWFilterDef *def = NULL;
|
||||
g_autoptr(xmlDoc) xml = NULL;
|
||||
g_autoptr(xmlXPathContext) ctxt = NULL;
|
||||
bool validate = flags & VIR_NWFILTER_DEFINE_VALIDATE;
|
||||
|
||||
if ((xml = virXMLParse(filename, xmlStr, _("(nwfilter_definition)"),
|
||||
NULL, NULL, "nwfilter.rng", validate))) {
|
||||
def = virNWFilterDefParseNode(xml, xmlDocGetRootElement(xml));
|
||||
}
|
||||
if (!(xml = virXMLParse(filename, xmlStr, _("(nwfilter_definition)"),
|
||||
"filter", &ctxt, "nwfilter.rng", validate)))
|
||||
return NULL;
|
||||
|
||||
return def;
|
||||
return virNWFilterDefParseXML(ctxt);
|
||||
}
|
||||
|
||||
|
||||
|
@ -533,10 +533,6 @@ int
|
||||
virNWFilterDeleteDef(const char *configDir,
|
||||
virNWFilterDef *def);
|
||||
|
||||
virNWFilterDef *
|
||||
virNWFilterDefParseNode(xmlDocPtr xml,
|
||||
xmlNodePtr root);
|
||||
|
||||
char *
|
||||
virNWFilterDefFormat(const virNWFilterDef *def);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user