Add a @flags argument when parsing the secret definition
via the virSecretDefParse{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/secret_conf.c | 25 ++++++++++++++++---------
src/conf/secret_conf.h | 9 +++++++--
src/conf/virsecretobj.c | 2 +-
src/secret/secret_driver.c | 2 +-
tests/secretxml2xmltest.c | 2 +-
5 files changed, 26 insertions(+), 14 deletions(-)
diff --git a/src/conf/secret_conf.c b/src/conf/secret_conf.c
index faf44bccce..d98a4f2442 100644
--- a/src/conf/secret_conf.c
+++ b/src/conf/secret_conf.c
@@ -123,12 +123,15 @@ virSecretDefParseUsage(xmlXPathContextPtr ctxt,
static virSecretDefPtr
-virSecretDefParseXML(xmlXPathContextPtr ctxt)
+virSecretDefParseXML(xmlXPathContextPtr ctxt,
+ unsigned int flags)
{
virSecretDefPtr def = NULL, ret = NULL;
char *prop = NULL;
char *uuidstr = NULL;
+ virCheckFlags(0, NULL);
+
if (VIR_ALLOC(def) < 0)
goto cleanup;
@@ -192,7 +195,8 @@ virSecretDefParseXML(xmlXPathContextPtr ctxt)
static virSecretDefPtr
virSecretDefParseNode(xmlDocPtr xml,
- xmlNodePtr root)
+ xmlNodePtr root,
+ unsigned int flags)
{
xmlXPathContextPtr ctxt = NULL;
virSecretDefPtr def = NULL;
@@ -212,7 +216,7 @@ virSecretDefParseNode(xmlDocPtr xml,
}
ctxt->node = root;
- def = virSecretDefParseXML(ctxt);
+ def = virSecretDefParseXML(ctxt, flags);
cleanup:
xmlXPathFreeContext(ctxt);
@@ -222,13 +226,14 @@ virSecretDefParseNode(xmlDocPtr xml,
static virSecretDefPtr
virSecretDefParse(const char *xmlStr,
- const char *filename)
+ const char *filename,
+ unsigned int flags)
{
xmlDocPtr xml;
virSecretDefPtr ret = NULL;
if ((xml = virXMLParse(filename, xmlStr, _("(definition_of_secret)")))) {
- ret = virSecretDefParseNode(xml, xmlDocGetRootElement(xml));
+ ret = virSecretDefParseNode(xml, xmlDocGetRootElement(xml), flags);
xmlFreeDoc(xml);
}
@@ -236,15 +241,17 @@ virSecretDefParse(const char *xmlStr,
}
virSecretDefPtr
-virSecretDefParseString(const char *xmlStr)
+virSecretDefParseString(const char *xmlStr,
+ unsigned int flags)
{
- return virSecretDefParse(xmlStr, NULL);
+ return virSecretDefParse(xmlStr, NULL, flags);
}
virSecretDefPtr
-virSecretDefParseFile(const char *filename)
+virSecretDefParseFile(const char *filename,
+ unsigned int flags)
{
- return virSecretDefParse(NULL, filename);
+ return virSecretDefParse(NULL, filename, flags);
}
static int
diff --git a/src/conf/secret_conf.h b/src/conf/secret_conf.h
index 19f612b8fe..2a19629f54 100644
--- a/src/conf/secret_conf.h
+++ b/src/conf/secret_conf.h
@@ -38,8 +38,13 @@ struct _virSecretDef {
};
void virSecretDefFree(virSecretDefPtr def);
-virSecretDefPtr virSecretDefParseString(const char *xml);
-virSecretDefPtr virSecretDefParseFile(const char *filename);
+
+virSecretDefPtr virSecretDefParseString(const char *xml,
+ unsigned int flags);
+
+virSecretDefPtr virSecretDefParseFile(const char *filename,
+ unsigned int flags);
+
char *virSecretDefFormat(const virSecretDef *def);
# define VIR_CONNECT_LIST_SECRETS_FILTERS_EPHEMERAL \
diff --git a/src/conf/virsecretobj.c b/src/conf/virsecretobj.c
index 48ce3c8141..9527d7570e 100644
--- a/src/conf/virsecretobj.c
+++ b/src/conf/virsecretobj.c
@@ -909,7 +909,7 @@ virSecretLoad(virSecretObjListPtr secrets,
virSecretDefPtr def = NULL;
virSecretObjPtr obj = NULL;
- if (!(def = virSecretDefParseFile(path)))
+ if (!(def = virSecretDefParseFile(path, 0)))
goto cleanup;
if (virSecretLoadValidateUUID(def, file) < 0)
diff --git a/src/secret/secret_driver.c b/src/secret/secret_driver.c
index 3c3557947e..5e1f82a314 100644
--- a/src/secret/secret_driver.c
+++ b/src/secret/secret_driver.c
@@ -218,7 +218,7 @@ secretDefineXML(virConnectPtr conn,
virCheckFlags(0, NULL);
- if (!(def = virSecretDefParseString(xml)))
+ if (!(def = virSecretDefParseString(xml, 0)))
return NULL;
if (virSecretDefineXMLEnsureACL(conn, def) < 0)
diff --git a/tests/secretxml2xmltest.c b/tests/secretxml2xmltest.c
index 306f64c236..573edd6012 100644
--- a/tests/secretxml2xmltest.c
+++ b/tests/secretxml2xmltest.c
@@ -15,7 +15,7 @@ testCompareXMLToXMLFiles(const char *inxml, const char *outxml)
int ret = -1;
virSecretDefPtr secret = NULL;
- if (!(secret = virSecretDefParseFile(inxml)))
+ if (!(secret = virSecretDefParseFile(inxml, 0)))
goto fail;
if (!(actual = virSecretDefFormat(secret)))
--
2.17.1