Add a @flags argument when parsing the nwfilter definition
via the virNWFilterDefParse{XML|Node|String|File} API's as
this will allow us to in the future make parsing decisions
based on the @flags.
Signed-off-by: John Ferlan <jferlan(a)redhat.com>
---
src/conf/nwfilter_conf.c | 25 ++++++++++++++++---------
src/conf/nwfilter_conf.h | 9 ++++++---
src/conf/virnwfilterobj.c | 2 +-
src/nwfilter/nwfilter_driver.c | 2 +-
tests/nwfilterxml2firewalltest.c | 2 +-
tests/nwfilterxml2xmltest.c | 2 +-
6 files changed, 26 insertions(+), 16 deletions(-)
diff --git a/src/conf/nwfilter_conf.c b/src/conf/nwfilter_conf.c
index 120ca5ec14..c1867fb946 100644
--- a/src/conf/nwfilter_conf.c
+++ b/src/conf/nwfilter_conf.c
@@ -2602,7 +2602,8 @@ virNWFilterIsAllowedChain(const char *chainname)
static virNWFilterDefPtr
-virNWFilterDefParseXML(xmlXPathContextPtr ctxt)
+virNWFilterDefParseXML(xmlXPathContextPtr ctxt,
+ unsigned int flags)
{
virNWFilterDefPtr ret;
xmlNodePtr curr = ctxt->node;
@@ -2613,6 +2614,8 @@ virNWFilterDefParseXML(xmlXPathContextPtr ctxt)
int chain_priority;
const char *name_prefix;
+ virCheckFlags(0, NULL);
+
if (VIR_ALLOC(ret) < 0)
return NULL;
@@ -2734,7 +2737,8 @@ virNWFilterDefParseXML(xmlXPathContextPtr ctxt)
virNWFilterDefPtr
virNWFilterDefParseNode(xmlDocPtr xml,
- xmlNodePtr root)
+ xmlNodePtr root,
+ unsigned int flags)
{
xmlXPathContextPtr ctxt = NULL;
virNWFilterDefPtr def = NULL;
@@ -2753,7 +2757,7 @@ virNWFilterDefParseNode(xmlDocPtr xml,
}
ctxt->node = root;
- def = virNWFilterDefParseXML(ctxt);
+ def = virNWFilterDefParseXML(ctxt, flags);
cleanup:
xmlXPathFreeContext(ctxt);
@@ -2763,13 +2767,14 @@ virNWFilterDefParseNode(xmlDocPtr xml,
static virNWFilterDefPtr
virNWFilterDefParse(const char *xmlStr,
- const char *filename)
+ const char *filename,
+ unsigned int flags)
{
virNWFilterDefPtr def = NULL;
xmlDocPtr xml;
if ((xml = virXMLParse(filename, xmlStr, _("(nwfilter_definition)")))) {
- def = virNWFilterDefParseNode(xml, xmlDocGetRootElement(xml));
+ def = virNWFilterDefParseNode(xml, xmlDocGetRootElement(xml), flags);
xmlFreeDoc(xml);
}
@@ -2778,16 +2783,18 @@ virNWFilterDefParse(const char *xmlStr,
virNWFilterDefPtr
-virNWFilterDefParseString(const char *xmlStr)
+virNWFilterDefParseString(const char *xmlStr,
+ unsigned int flags)
{
- return virNWFilterDefParse(xmlStr, NULL);
+ return virNWFilterDefParse(xmlStr, NULL, flags);
}
virNWFilterDefPtr
-virNWFilterDefParseFile(const char *filename)
+virNWFilterDefParseFile(const char *filename,
+ unsigned int flags)
{
- return virNWFilterDefParse(NULL, filename);
+ return virNWFilterDefParse(NULL, filename, flags);
}
diff --git a/src/conf/nwfilter_conf.h b/src/conf/nwfilter_conf.h
index 9f8ad51bf2..5ffdc07fab 100644
--- a/src/conf/nwfilter_conf.h
+++ b/src/conf/nwfilter_conf.h
@@ -561,7 +561,8 @@ virNWFilterDeleteDef(const char *configDir,
virNWFilterDefPtr
virNWFilterDefParseNode(xmlDocPtr xml,
- xmlNodePtr root);
+ xmlNodePtr root,
+ unsigned int flags);
char *
virNWFilterDefFormat(const virNWFilterDef *def);
@@ -571,10 +572,12 @@ virNWFilterSaveConfig(const char *configDir,
virNWFilterDefPtr def);
virNWFilterDefPtr
-virNWFilterDefParseString(const char *xml);
+virNWFilterDefParseString(const char *xml,
+ unsigned int flags);
virNWFilterDefPtr
-virNWFilterDefParseFile(const char *filename);
+virNWFilterDefParseFile(const char *filename,
+ unsigned int flags);
void
virNWFilterWriteLockFilterUpdates(void);
diff --git a/src/conf/virnwfilterobj.c b/src/conf/virnwfilterobj.c
index 0136a0d56c..3993be3874 100644
--- a/src/conf/virnwfilterobj.c
+++ b/src/conf/virnwfilterobj.c
@@ -503,7 +503,7 @@ virNWFilterObjListLoadConfig(virNWFilterObjListPtr nwfilters,
if (!(configFile = virFileBuildPath(configDir, name, ".xml")))
goto error;
- if (!(def = virNWFilterDefParseFile(configFile)))
+ if (!(def = virNWFilterDefParseFile(configFile, 0)))
goto error;
if (STRNEQ(name, def->name)) {
diff --git a/src/nwfilter/nwfilter_driver.c b/src/nwfilter/nwfilter_driver.c
index ac3a964388..d850a66b28 100644
--- a/src/nwfilter/nwfilter_driver.c
+++ b/src/nwfilter/nwfilter_driver.c
@@ -556,7 +556,7 @@ nwfilterDefineXML(virConnectPtr conn,
nwfilterDriverLock();
virNWFilterWriteLockFilterUpdates();
- if (!(def = virNWFilterDefParseString(xml)))
+ if (!(def = virNWFilterDefParseString(xml, 0)))
goto cleanup;
if (virNWFilterDefineXMLEnsureACL(conn, def) < 0)
diff --git a/tests/nwfilterxml2firewalltest.c b/tests/nwfilterxml2firewalltest.c
index 043b7d170e..786761a04e 100644
--- a/tests/nwfilterxml2firewalltest.c
+++ b/tests/nwfilterxml2firewalltest.c
@@ -275,7 +275,7 @@ virNWFilterDefToInst(const char *xml,
{
size_t i;
int ret = -1;
- virNWFilterDefPtr def = virNWFilterDefParseFile(xml);
+ virNWFilterDefPtr def = virNWFilterDefParseFile(xml, 0);
if (!def)
return -1;
diff --git a/tests/nwfilterxml2xmltest.c b/tests/nwfilterxml2xmltest.c
index 89f809ca8f..0c79afa8ee 100644
--- a/tests/nwfilterxml2xmltest.c
+++ b/tests/nwfilterxml2xmltest.c
@@ -29,7 +29,7 @@ testCompareXMLToXMLFiles(const char *inxml, const char *outxml,
virResetLastError();
- if (!(dev = virNWFilterDefParseFile(inxml))) {
+ if (!(dev = virNWFilterDefParseFile(inxml, 0))) {
if (expect_error) {
virResetLastError();
goto done;
--
2.17.1