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(a)redhat.com>
---
src/conf/nwfilter_conf.c | 32 +++++---------------------------
src/conf/nwfilter_conf.h | 4 ----
2 files changed, 5 insertions(+), 31 deletions(-)
diff --git a/src/conf/nwfilter_conf.c b/src/conf/nwfilter_conf.c
index 44ea056823..00728782d1 100644
--- a/src/conf/nwfilter_conf.c
+++ b/src/conf/nwfilter_conf.c
@@ -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);
}
diff --git a/src/conf/nwfilter_conf.h b/src/conf/nwfilter_conf.h
index b67364714a..b8a970f00b 100644
--- a/src/conf/nwfilter_conf.h
+++ b/src/conf/nwfilter_conf.h
@@ -533,10 +533,6 @@ int
virNWFilterDeleteDef(const char *configDir,
virNWFilterDef *def);
-virNWFilterDef *
-virNWFilterDefParseNode(xmlDocPtr xml,
- xmlNodePtr root);
-
char *
virNWFilterDefFormat(const virNWFilterDef *def);
--
2.37.3