Allow the callers to pass down libvirt-internal flags.
---
src/conf/storage_conf.c | 25 ++++++++++++++++---------
src/conf/storage_conf.h | 9 ++++++---
src/esx/esx_storage_backend_vmfs.c | 4 ++--
src/parallels/parallels_storage.c | 6 +++---
src/phyp/phyp_driver.c | 2 +-
src/storage/storage_driver.c | 4 ++--
src/test/test_driver.c | 6 +++---
src/vbox/vbox_storage.c | 2 +-
tests/storagebackendsheepdogtest.c | 2 +-
tests/storagevolxml2argvtest.c | 4 ++--
tests/storagevolxml2xmltest.c | 13 ++++++++-----
11 files changed, 45 insertions(+), 32 deletions(-)
diff --git a/src/conf/storage_conf.c b/src/conf/storage_conf.c
index e9aaa8a..c8a860b 100644
--- a/src/conf/storage_conf.c
+++ b/src/conf/storage_conf.c
@@ -1245,7 +1245,8 @@ virStorageSize(const char *unit,
static virStorageVolDefPtr
virStorageVolDefParseXML(virStoragePoolDefPtr pool,
- xmlXPathContextPtr ctxt)
+ xmlXPathContextPtr ctxt,
+ unsigned long flags)
{
virStorageVolDefPtr ret;
virStorageVolOptionsPtr options;
@@ -1259,6 +1260,8 @@ virStorageVolDefParseXML(virStoragePoolDefPtr pool,
size_t i;
int n;
+ virCheckFlags(0, NULL);
+
options = virStorageVolOptionsForPoolType(pool->type);
if (options == NULL)
return NULL;
@@ -1429,7 +1432,8 @@ virStorageVolDefParseXML(virStoragePoolDefPtr pool,
virStorageVolDefPtr
virStorageVolDefParseNode(virStoragePoolDefPtr pool,
xmlDocPtr xml,
- xmlNodePtr root)
+ xmlNodePtr root,
+ unsigned long flags)
{
xmlXPathContextPtr ctxt = NULL;
virStorageVolDefPtr def = NULL;
@@ -1449,7 +1453,7 @@ virStorageVolDefParseNode(virStoragePoolDefPtr pool,
}
ctxt->node = root;
- def = virStorageVolDefParseXML(pool, ctxt);
+ def = virStorageVolDefParseXML(pool, ctxt, flags);
cleanup:
xmlXPathFreeContext(ctxt);
return def;
@@ -1458,13 +1462,14 @@ virStorageVolDefParseNode(virStoragePoolDefPtr pool,
static virStorageVolDefPtr
virStorageVolDefParse(virStoragePoolDefPtr pool,
const char *xmlStr,
- const char *filename)
+ const char *filename,
+ unsigned long flags)
{
virStorageVolDefPtr ret = NULL;
xmlDocPtr xml;
if ((xml = virXMLParse(filename, xmlStr,
_("(storage_volume_definition)")))) {
- ret = virStorageVolDefParseNode(pool, xml, xmlDocGetRootElement(xml));
+ ret = virStorageVolDefParseNode(pool, xml, xmlDocGetRootElement(xml), flags);
xmlFreeDoc(xml);
}
@@ -1473,16 +1478,18 @@ virStorageVolDefParse(virStoragePoolDefPtr pool,
virStorageVolDefPtr
virStorageVolDefParseString(virStoragePoolDefPtr pool,
- const char *xmlStr)
+ const char *xmlStr,
+ unsigned long flags)
{
- return virStorageVolDefParse(pool, xmlStr, NULL);
+ return virStorageVolDefParse(pool, xmlStr, NULL, flags);
}
virStorageVolDefPtr
virStorageVolDefParseFile(virStoragePoolDefPtr pool,
- const char *filename)
+ const char *filename,
+ unsigned long flags)
{
- return virStorageVolDefParse(pool, NULL, filename);
+ return virStorageVolDefParse(pool, NULL, filename, flags);
}
static void
diff --git a/src/conf/storage_conf.h b/src/conf/storage_conf.h
index 2c9eaed..2162426 100644
--- a/src/conf/storage_conf.h
+++ b/src/conf/storage_conf.h
@@ -347,14 +347,17 @@ char *virStoragePoolDefFormat(virStoragePoolDefPtr def);
virStorageVolDefPtr
virStorageVolDefParseString(virStoragePoolDefPtr pool,
- const char *xml);
+ const char *xml,
+ unsigned long flags);
virStorageVolDefPtr
virStorageVolDefParseFile(virStoragePoolDefPtr pool,
- const char *filename);
+ const char *filename,
+ unsigned long flags);
virStorageVolDefPtr
virStorageVolDefParseNode(virStoragePoolDefPtr pool,
xmlDocPtr xml,
- xmlNodePtr root);
+ xmlNodePtr root,
+ unsigned long flags);
char *virStorageVolDefFormat(virStoragePoolDefPtr pool,
virStorageVolDefPtr def);
diff --git a/src/esx/esx_storage_backend_vmfs.c b/src/esx/esx_storage_backend_vmfs.c
index fa423e9..0dcf419 100644
--- a/src/esx/esx_storage_backend_vmfs.c
+++ b/src/esx/esx_storage_backend_vmfs.c
@@ -864,7 +864,7 @@ esxStorageVolCreateXML(virStoragePoolPtr pool,
}
/* Parse config */
- def = virStorageVolDefParseString(&poolDef, xmldesc);
+ def = virStorageVolDefParseString(&poolDef, xmldesc, 0);
if (!def)
goto cleanup;
@@ -1085,7 +1085,7 @@ esxStorageVolCreateXMLFrom(virStoragePoolPtr pool,
goto cleanup;
/* Parse config */
- def = virStorageVolDefParseString(&poolDef, xmldesc);
+ def = virStorageVolDefParseString(&poolDef, xmldesc, 0);
if (!def)
goto cleanup;
diff --git a/src/parallels/parallels_storage.c b/src/parallels/parallels_storage.c
index d2c5bf2..a6980a4 100644
--- a/src/parallels/parallels_storage.c
+++ b/src/parallels/parallels_storage.c
@@ -1208,9 +1208,9 @@ parallelsStorageVolDefineXML(virStoragePoolObjPtr pool,
char *xml_path = NULL;
if (xmlfile)
- privvol = virStorageVolDefParseFile(pool->def, xmlfile);
+ privvol = virStorageVolDefParseFile(pool->def, xmlfile, 0);
else
- privvol = virStorageVolDefParseString(pool->def, xmldesc);
+ privvol = virStorageVolDefParseString(pool->def, xmldesc, 0);
if (privvol == NULL)
goto cleanup;
@@ -1335,7 +1335,7 @@ parallelsStorageVolCreateXMLFrom(virStoragePoolPtr pool,
goto cleanup;
}
- privvol = virStorageVolDefParseString(privpool->def, xmldesc);
+ privvol = virStorageVolDefParseString(privpool->def, xmldesc, 0);
if (privvol == NULL)
goto cleanup;
diff --git a/src/phyp/phyp_driver.c b/src/phyp/phyp_driver.c
index d05f897..dbf76e2 100644
--- a/src/phyp/phyp_driver.c
+++ b/src/phyp/phyp_driver.c
@@ -2026,7 +2026,7 @@ phypStorageVolCreateXML(virStoragePoolPtr pool,
goto err;
}
- if ((voldef = virStorageVolDefParseString(spdef, xml)) == NULL) {
+ if ((voldef = virStorageVolDefParseString(spdef, xml, 0)) == NULL) {
VIR_ERROR(_("Error parsing volume XML."));
goto err;
}
diff --git a/src/storage/storage_driver.c b/src/storage/storage_driver.c
index ad92c9b..bc16e87 100644
--- a/src/storage/storage_driver.c
+++ b/src/storage/storage_driver.c
@@ -1649,7 +1649,7 @@ storageVolCreateXML(virStoragePoolPtr obj,
if ((backend = virStorageBackendForType(pool->def->type)) == NULL)
goto cleanup;
- voldef = virStorageVolDefParseString(pool->def, xmldesc);
+ voldef = virStorageVolDefParseString(pool->def, xmldesc, 0);
if (voldef == NULL)
goto cleanup;
@@ -1810,7 +1810,7 @@ storageVolCreateXMLFrom(virStoragePoolPtr obj,
goto cleanup;
}
- newvol = virStorageVolDefParseString(pool->def, xmldesc);
+ newvol = virStorageVolDefParseString(pool->def, xmldesc, 0);
if (newvol == NULL)
goto cleanup;
diff --git a/src/test/test_driver.c b/src/test/test_driver.c
index a386270..718e84a 100644
--- a/src/test/test_driver.c
+++ b/src/test/test_driver.c
@@ -1230,7 +1230,7 @@ testOpenVolumesForPool(const char *file,
if (!node)
goto error;
- def = virStorageVolDefParseNode(pool->def, ctxt->doc, node);
+ def = virStorageVolDefParseNode(pool->def, ctxt->doc, node, 0);
if (!def)
goto error;
@@ -5430,7 +5430,7 @@ testStorageVolCreateXML(virStoragePoolPtr pool,
goto cleanup;
}
- privvol = virStorageVolDefParseString(privpool->def, xmldesc);
+ privvol = virStorageVolDefParseString(privpool->def, xmldesc, 0);
if (privvol == NULL)
goto cleanup;
@@ -5504,7 +5504,7 @@ testStorageVolCreateXMLFrom(virStoragePoolPtr pool,
goto cleanup;
}
- privvol = virStorageVolDefParseString(privpool->def, xmldesc);
+ privvol = virStorageVolDefParseString(privpool->def, xmldesc, 0);
if (privvol == NULL)
goto cleanup;
diff --git a/src/vbox/vbox_storage.c b/src/vbox/vbox_storage.c
index 599f917..4367009 100644
--- a/src/vbox/vbox_storage.c
+++ b/src/vbox/vbox_storage.c
@@ -430,7 +430,7 @@ vboxStorageVolCreateXML(virStoragePoolPtr pool,
memset(&poolDef, 0, sizeof(poolDef));
poolDef.type = VIR_STORAGE_POOL_DIR;
- if ((def = virStorageVolDefParseString(&poolDef, xml)) == NULL)
+ if ((def = virStorageVolDefParseString(&poolDef, xml, 0)) == NULL)
goto cleanup;
if (!def->name ||
diff --git a/tests/storagebackendsheepdogtest.c b/tests/storagebackendsheepdogtest.c
index 14fc76d..c85a9b4 100644
--- a/tests/storagebackendsheepdogtest.c
+++ b/tests/storagebackendsheepdogtest.c
@@ -100,7 +100,7 @@ test_vdi_list_parser(collie_test test, char *poolxml, char *volxml)
if (!(pool = virStoragePoolDefParseString(poolXmlData)))
goto cleanup;
- if (!(vol = virStorageVolDefParseString(pool, volXmlData)))
+ if (!(vol = virStorageVolDefParseString(pool, volXmlData, 0)))
goto cleanup;
if (VIR_STRDUP(output, test.output) < 0)
diff --git a/tests/storagevolxml2argvtest.c b/tests/storagevolxml2argvtest.c
index f9d2d2d..c1f8a9d 100644
--- a/tests/storagevolxml2argvtest.c
+++ b/tests/storagevolxml2argvtest.c
@@ -84,11 +84,11 @@ testCompareXMLToArgvFiles(bool shouldFail,
goto cleanup;
}
- if (!(vol = virStorageVolDefParseString(pool, volXmlData)))
+ if (!(vol = virStorageVolDefParseString(pool, volXmlData, 0)))
goto cleanup;
if (inputvolxml &&
- !(inputvol = virStorageVolDefParseString(inputpool, inputvolXmlData)))
+ !(inputvol = virStorageVolDefParseString(inputpool, inputvolXmlData, 0)))
goto cleanup;
testSetVolumeType(vol, pool);
diff --git a/tests/storagevolxml2xmltest.c b/tests/storagevolxml2xmltest.c
index cf4d401..ee0495b 100644
--- a/tests/storagevolxml2xmltest.c
+++ b/tests/storagevolxml2xmltest.c
@@ -18,7 +18,7 @@
static int
testCompareXMLToXMLFiles(const char *poolxml, const char *inxml,
- const char *outxml)
+ const char *outxml, unsigned long flags)
{
char *poolXmlData = NULL;
char *inXmlData = NULL;
@@ -38,7 +38,7 @@ testCompareXMLToXMLFiles(const char *poolxml, const char *inxml,
if (!(pool = virStoragePoolDefParseString(poolXmlData)))
goto fail;
- if (!(dev = virStorageVolDefParseString(pool, inXmlData)))
+ if (!(dev = virStorageVolDefParseString(pool, inXmlData, flags)))
goto fail;
if (!(actual = virStorageVolDefFormat(pool, dev)))
@@ -64,6 +64,7 @@ testCompareXMLToXMLFiles(const char *poolxml, const char *inxml,
struct testInfo {
const char *pool;
const char *name;
+ unsigned long flags;
};
static int
@@ -84,7 +85,7 @@ testCompareXMLToXMLHelper(const void *data)
goto cleanup;
}
- result = testCompareXMLToXMLFiles(poolxml, inxml, outxml);
+ result = testCompareXMLToXMLFiles(poolxml, inxml, outxml, info->flags);
cleanup:
VIR_FREE(poolxml);
@@ -100,15 +101,17 @@ mymain(void)
{
int ret = 0;
-#define DO_TEST(pool, name) \
+#define DO_TEST_FULL(pool, name, flags) \
do { \
- struct testInfo info = { pool, name }; \
+ struct testInfo info = { pool, name, flags }; \
if (virtTestRun("Storage Vol XML-2-XML " name, \
testCompareXMLToXMLHelper, &info) < 0) \
ret = -1; \
} \
while (0);
+#define DO_TEST(pool, name) DO_TEST_FULL(pool, name, 0)
+
DO_TEST("pool-dir", "vol-file");
DO_TEST("pool-dir", "vol-file-naming");
DO_TEST("pool-dir", "vol-file-backing");
--
2.0.5