Add a @flags argument when parsing the storage pool definition
via the virStoragePoolDefParse{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/domain_conf.c | 2 +-
src/conf/storage_conf.c | 25 ++++++++++++++++---------
src/conf/storage_conf.h | 12 ++++++++----
src/conf/virstorageobj.c | 4 ++--
src/phyp/phyp_driver.c | 2 +-
src/storage/storage_driver.c | 4 ++--
src/test/test_driver.c | 6 +++---
tests/storagebackendsheepdogtest.c | 4 ++--
tests/storagepoolxml2xmltest.c | 2 +-
tests/storagevolxml2argvtest.c | 4 ++--
tests/storagevolxml2xmltest.c | 2 +-
11 files changed, 39 insertions(+), 28 deletions(-)
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index eff8af20e7..42b55f01d4 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -30183,7 +30183,7 @@ virDomainDiskTranslateSourcePool(virDomainDiskDefPtr def)
if (!(poolxml = virStoragePoolGetXMLDesc(pool, 0)))
goto cleanup;
- if (!(pooldef = virStoragePoolDefParseString(poolxml)))
+ if (!(pooldef = virStoragePoolDefParseString(poolxml, 0)))
goto cleanup;
def->src->srcpool->pooltype = pooldef->type;
diff --git a/src/conf/storage_conf.c b/src/conf/storage_conf.c
index 5036ab9ef8..e5d35cd254 100644
--- a/src/conf/storage_conf.c
+++ b/src/conf/storage_conf.c
@@ -671,7 +671,8 @@ virStorageDefParsePerms(xmlXPathContextPtr ctxt,
virStoragePoolDefPtr
-virStoragePoolDefParseXML(xmlXPathContextPtr ctxt)
+virStoragePoolDefParseXML(xmlXPathContextPtr ctxt,
+ unsigned int flags)
{
virStoragePoolOptionsPtr options;
virStoragePoolDefPtr ret;
@@ -680,6 +681,8 @@ virStoragePoolDefParseXML(xmlXPathContextPtr ctxt)
char *uuid = NULL;
char *target_path = NULL;
+ virCheckFlags(0, NULL);
+
if (VIR_ALLOC(ret) < 0)
return NULL;
@@ -818,7 +821,8 @@ virStoragePoolDefParseXML(xmlXPathContextPtr ctxt)
virStoragePoolDefPtr
virStoragePoolDefParseNode(xmlDocPtr xml,
- xmlNodePtr root)
+ xmlNodePtr root,
+ unsigned int flags)
{
xmlXPathContextPtr ctxt = NULL;
virStoragePoolDefPtr def = NULL;
@@ -838,7 +842,7 @@ virStoragePoolDefParseNode(xmlDocPtr xml,
}
ctxt->node = root;
- def = virStoragePoolDefParseXML(ctxt);
+ def = virStoragePoolDefParseXML(ctxt, flags);
cleanup:
xmlXPathFreeContext(ctxt);
return def;
@@ -847,13 +851,14 @@ virStoragePoolDefParseNode(xmlDocPtr xml,
static virStoragePoolDefPtr
virStoragePoolDefParse(const char *xmlStr,
- const char *filename)
+ const char *filename,
+ unsigned int flags)
{
virStoragePoolDefPtr ret = NULL;
xmlDocPtr xml;
if ((xml = virXMLParse(filename, xmlStr, _("(storage_pool_definition)"))))
{
- ret = virStoragePoolDefParseNode(xml, xmlDocGetRootElement(xml));
+ ret = virStoragePoolDefParseNode(xml, xmlDocGetRootElement(xml), flags);
xmlFreeDoc(xml);
}
@@ -862,16 +867,18 @@ virStoragePoolDefParse(const char *xmlStr,
virStoragePoolDefPtr
-virStoragePoolDefParseString(const char *xmlStr)
+virStoragePoolDefParseString(const char *xmlStr,
+ unsigned int flags)
{
- return virStoragePoolDefParse(xmlStr, NULL);
+ return virStoragePoolDefParse(xmlStr, NULL, flags);
}
virStoragePoolDefPtr
-virStoragePoolDefParseFile(const char *filename)
+virStoragePoolDefParseFile(const char *filename,
+ unsigned int flags)
{
- return virStoragePoolDefParse(NULL, filename);
+ return virStoragePoolDefParse(NULL, filename, flags);
}
diff --git a/src/conf/storage_conf.h b/src/conf/storage_conf.h
index 15dfd8becf..d6886ad6ca 100644
--- a/src/conf/storage_conf.h
+++ b/src/conf/storage_conf.h
@@ -236,17 +236,21 @@ struct _virStoragePoolSourceList {
};
virStoragePoolDefPtr
-virStoragePoolDefParseXML(xmlXPathContextPtr ctxt);
+virStoragePoolDefParseXML(xmlXPathContextPtr ctxt,
+ unsigned int flags);
virStoragePoolDefPtr
-virStoragePoolDefParseString(const char *xml);
+virStoragePoolDefParseString(const char *xml,
+ unsigned int flags);
virStoragePoolDefPtr
-virStoragePoolDefParseFile(const char *filename);
+virStoragePoolDefParseFile(const char *filename,
+ unsigned int flags);
virStoragePoolDefPtr
virStoragePoolDefParseNode(xmlDocPtr xml,
- xmlNodePtr root);
+ xmlNodePtr root,
+ unsigned int flags);
char *
virStoragePoolDefFormat(virStoragePoolDefPtr def);
diff --git a/src/conf/virstorageobj.c b/src/conf/virstorageobj.c
index e66b2ebfb2..47209fae96 100644
--- a/src/conf/virstorageobj.c
+++ b/src/conf/virstorageobj.c
@@ -1110,7 +1110,7 @@ virStoragePoolObjLoad(virStoragePoolObjListPtr pools,
virStoragePoolDefPtr def;
virStoragePoolObjPtr obj;
- if (!(def = virStoragePoolDefParseFile(path)))
+ if (!(def = virStoragePoolDefParseFile(path, 0)))
return NULL;
if (!virFileMatchesNameSuffix(file, def->name, ".xml")) {
@@ -1172,7 +1172,7 @@ virStoragePoolObjLoadState(virStoragePoolObjListPtr pools,
}
ctxt->node = node;
- if (!(def = virStoragePoolDefParseXML(ctxt)))
+ if (!(def = virStoragePoolDefParseXML(ctxt, 0)))
goto error;
if (STRNEQ(name, def->name)) {
diff --git a/src/phyp/phyp_driver.c b/src/phyp/phyp_driver.c
index d78de83231..99d5dedd81 100644
--- a/src/phyp/phyp_driver.c
+++ b/src/phyp/phyp_driver.c
@@ -2635,7 +2635,7 @@ phypStoragePoolCreateXML(virConnectPtr conn,
virStoragePoolPtr dup_sp = NULL;
virStoragePoolPtr sp = NULL;
- if (!(def = virStoragePoolDefParseString(xml)))
+ if (!(def = virStoragePoolDefParseString(xml, 0)))
goto err;
/* checking if this name already exists on this system */
diff --git a/src/storage/storage_driver.c b/src/storage/storage_driver.c
index 8070d159ea..491c4fab9b 100644
--- a/src/storage/storage_driver.c
+++ b/src/storage/storage_driver.c
@@ -699,7 +699,7 @@ storagePoolCreateXML(virConnectPtr conn,
VIR_EXCLUSIVE_FLAGS_RET(VIR_STORAGE_POOL_BUILD_OVERWRITE,
VIR_STORAGE_POOL_BUILD_NO_OVERWRITE, NULL);
- if (!(newDef = virStoragePoolDefParseString(xml)))
+ if (!(newDef = virStoragePoolDefParseString(xml, 0)))
goto cleanup;
if (virStoragePoolCreateXMLEnsureACL(conn, newDef) < 0)
@@ -790,7 +790,7 @@ storagePoolDefineXML(virConnectPtr conn,
virCheckFlags(0, NULL);
- if (!(newDef = virStoragePoolDefParseString(xml)))
+ if (!(newDef = virStoragePoolDefParseString(xml, 0)))
goto cleanup;
if (virXMLCheckIllegalChars("name", newDef->name, "\n") <
0)
diff --git a/src/test/test_driver.c b/src/test/test_driver.c
index dfca95c981..1a42a4f74b 100644
--- a/src/test/test_driver.c
+++ b/src/test/test_driver.c
@@ -1104,7 +1104,7 @@ testParseStorage(testDriverPtr privconn,
if (!node)
goto error;
- def = virStoragePoolDefParseNode(ctxt->doc, node);
+ def = virStoragePoolDefParseNode(ctxt->doc, node, 0);
if (!def)
goto error;
@@ -4519,7 +4519,7 @@ testStoragePoolCreateXML(virConnectPtr conn,
virCheckFlags(0, NULL);
testDriverLock(privconn);
- if (!(newDef = virStoragePoolDefParseString(xml)))
+ if (!(newDef = virStoragePoolDefParseString(xml, 0)))
goto cleanup;
if (virStoragePoolObjIsDuplicate(privconn->pools, newDef, true) < 0)
@@ -4589,7 +4589,7 @@ testStoragePoolDefineXML(virConnectPtr conn,
virCheckFlags(0, NULL);
testDriverLock(privconn);
- if (!(newDef = virStoragePoolDefParseString(xml)))
+ if (!(newDef = virStoragePoolDefParseString(xml, 0)))
goto cleanup;
newDef->capacity = defaultPoolCap;
diff --git a/tests/storagebackendsheepdogtest.c b/tests/storagebackendsheepdogtest.c
index cc7b163241..c9b80127b8 100644
--- a/tests/storagebackendsheepdogtest.c
+++ b/tests/storagebackendsheepdogtest.c
@@ -65,7 +65,7 @@ test_node_info_parser(const void *opaque)
char *output = NULL;
virStoragePoolDefPtr pool = NULL;
- if (!(pool = virStoragePoolDefParseFile(data->poolxml)))
+ if (!(pool = virStoragePoolDefParseFile(data->poolxml, 0)))
goto cleanup;
if (VIR_STRDUP(output, test.output) < 0)
@@ -100,7 +100,7 @@ test_vdi_list_parser(const void *opaque)
virStoragePoolDefPtr pool = NULL;
virStorageVolDefPtr vol = NULL;
- if (!(pool = virStoragePoolDefParseFile(data->poolxml)))
+ if (!(pool = virStoragePoolDefParseFile(data->poolxml, 0)))
goto cleanup;
if (!(vol = virStorageVolDefParseFile(pool, data->volxml, 0)))
diff --git a/tests/storagepoolxml2xmltest.c b/tests/storagepoolxml2xmltest.c
index 974f0afe39..84f2bfb9ec 100644
--- a/tests/storagepoolxml2xmltest.c
+++ b/tests/storagepoolxml2xmltest.c
@@ -23,7 +23,7 @@ testCompareXMLToXMLFiles(const char *inxml, const char *outxml)
int ret = -1;
virStoragePoolDefPtr dev = NULL;
- if (!(dev = virStoragePoolDefParseFile(inxml)))
+ if (!(dev = virStoragePoolDefParseFile(inxml, 0)))
goto fail;
if (!(actual = virStoragePoolDefFormat(dev)))
diff --git a/tests/storagevolxml2argvtest.c b/tests/storagevolxml2argvtest.c
index b795f83aee..aa55e4dbad 100644
--- a/tests/storagevolxml2argvtest.c
+++ b/tests/storagevolxml2argvtest.c
@@ -53,7 +53,7 @@ testCompareXMLToArgvFiles(bool shouldFail,
virStoragePoolDefPtr inputpool = NULL;
virStoragePoolObjPtr obj = NULL;
- if (!(def = virStoragePoolDefParseFile(poolxml)))
+ if (!(def = virStoragePoolDefParseFile(poolxml, 0)))
goto cleanup;
if (!(obj = virStoragePoolObjNew())) {
@@ -63,7 +63,7 @@ testCompareXMLToArgvFiles(bool shouldFail,
virStoragePoolObjSetDef(obj, def);
if (inputpoolxml) {
- if (!(inputpool = virStoragePoolDefParseFile(inputpoolxml)))
+ if (!(inputpool = virStoragePoolDefParseFile(inputpoolxml, 0)))
goto cleanup;
}
diff --git a/tests/storagevolxml2xmltest.c b/tests/storagevolxml2xmltest.c
index 7bac4974ae..0ff25451bc 100644
--- a/tests/storagevolxml2xmltest.c
+++ b/tests/storagevolxml2xmltest.c
@@ -25,7 +25,7 @@ testCompareXMLToXMLFiles(const char *poolxml, const char *inxml,
virStoragePoolDefPtr pool = NULL;
virStorageVolDefPtr dev = NULL;
- if (!(pool = virStoragePoolDefParseFile(poolxml)))
+ if (!(pool = virStoragePoolDefParseFile(poolxml, 0)))
goto fail;
if (!(dev = virStorageVolDefParseFile(pool, inxml, flags)))
--
2.17.1