Add flags argument to virStorageVolDefParse*

Allow the callers to pass down libvirt-internal flags.
This commit is contained in:
Ján Tomko 2015-02-05 16:20:17 +01:00
parent c7b9f20666
commit cbd788eba6
11 changed files with 45 additions and 32 deletions

View File

@ -1245,7 +1245,8 @@ virStorageSize(const char *unit,
static virStorageVolDefPtr
virStorageVolDefParseXML(virStoragePoolDefPtr pool,
xmlXPathContextPtr ctxt)
xmlXPathContextPtr ctxt,
unsigned int 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 int 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 int 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 int flags)
{
return virStorageVolDefParse(pool, xmlStr, NULL);
return virStorageVolDefParse(pool, xmlStr, NULL, flags);
}
virStorageVolDefPtr
virStorageVolDefParseFile(virStoragePoolDefPtr pool,
const char *filename)
const char *filename,
unsigned int flags)
{
return virStorageVolDefParse(pool, NULL, filename);
return virStorageVolDefParse(pool, NULL, filename, flags);
}
static void

View File

@ -347,14 +347,17 @@ char *virStoragePoolDefFormat(virStoragePoolDefPtr def);
virStorageVolDefPtr
virStorageVolDefParseString(virStoragePoolDefPtr pool,
const char *xml);
const char *xml,
unsigned int flags);
virStorageVolDefPtr
virStorageVolDefParseFile(virStoragePoolDefPtr pool,
const char *filename);
const char *filename,
unsigned int flags);
virStorageVolDefPtr
virStorageVolDefParseNode(virStoragePoolDefPtr pool,
xmlDocPtr xml,
xmlNodePtr root);
xmlNodePtr root,
unsigned int flags);
char *virStorageVolDefFormat(virStoragePoolDefPtr pool,
virStorageVolDefPtr def);

View File

@ -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;

View File

@ -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;

View File

@ -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;
}

View File

@ -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;

View File

@ -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;

View File

@ -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 ||

View File

@ -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)

View File

@ -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);

View File

@ -18,7 +18,7 @@
static int
testCompareXMLToXMLFiles(const char *poolxml, const char *inxml,
const char *outxml)
const char *outxml, unsigned int 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 int 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");