mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-03 11:35:19 +00:00
Add flags argument to virStorageVolDefParse*
Allow the callers to pass down libvirt-internal flags.
This commit is contained in:
parent
c7b9f20666
commit
cbd788eba6
@ -1245,7 +1245,8 @@ virStorageSize(const char *unit,
|
|||||||
|
|
||||||
static virStorageVolDefPtr
|
static virStorageVolDefPtr
|
||||||
virStorageVolDefParseXML(virStoragePoolDefPtr pool,
|
virStorageVolDefParseXML(virStoragePoolDefPtr pool,
|
||||||
xmlXPathContextPtr ctxt)
|
xmlXPathContextPtr ctxt,
|
||||||
|
unsigned int flags)
|
||||||
{
|
{
|
||||||
virStorageVolDefPtr ret;
|
virStorageVolDefPtr ret;
|
||||||
virStorageVolOptionsPtr options;
|
virStorageVolOptionsPtr options;
|
||||||
@ -1259,6 +1260,8 @@ virStorageVolDefParseXML(virStoragePoolDefPtr pool,
|
|||||||
size_t i;
|
size_t i;
|
||||||
int n;
|
int n;
|
||||||
|
|
||||||
|
virCheckFlags(0, NULL);
|
||||||
|
|
||||||
options = virStorageVolOptionsForPoolType(pool->type);
|
options = virStorageVolOptionsForPoolType(pool->type);
|
||||||
if (options == NULL)
|
if (options == NULL)
|
||||||
return NULL;
|
return NULL;
|
||||||
@ -1429,7 +1432,8 @@ virStorageVolDefParseXML(virStoragePoolDefPtr pool,
|
|||||||
virStorageVolDefPtr
|
virStorageVolDefPtr
|
||||||
virStorageVolDefParseNode(virStoragePoolDefPtr pool,
|
virStorageVolDefParseNode(virStoragePoolDefPtr pool,
|
||||||
xmlDocPtr xml,
|
xmlDocPtr xml,
|
||||||
xmlNodePtr root)
|
xmlNodePtr root,
|
||||||
|
unsigned int flags)
|
||||||
{
|
{
|
||||||
xmlXPathContextPtr ctxt = NULL;
|
xmlXPathContextPtr ctxt = NULL;
|
||||||
virStorageVolDefPtr def = NULL;
|
virStorageVolDefPtr def = NULL;
|
||||||
@ -1449,7 +1453,7 @@ virStorageVolDefParseNode(virStoragePoolDefPtr pool,
|
|||||||
}
|
}
|
||||||
|
|
||||||
ctxt->node = root;
|
ctxt->node = root;
|
||||||
def = virStorageVolDefParseXML(pool, ctxt);
|
def = virStorageVolDefParseXML(pool, ctxt, flags);
|
||||||
cleanup:
|
cleanup:
|
||||||
xmlXPathFreeContext(ctxt);
|
xmlXPathFreeContext(ctxt);
|
||||||
return def;
|
return def;
|
||||||
@ -1458,13 +1462,14 @@ virStorageVolDefParseNode(virStoragePoolDefPtr pool,
|
|||||||
static virStorageVolDefPtr
|
static virStorageVolDefPtr
|
||||||
virStorageVolDefParse(virStoragePoolDefPtr pool,
|
virStorageVolDefParse(virStoragePoolDefPtr pool,
|
||||||
const char *xmlStr,
|
const char *xmlStr,
|
||||||
const char *filename)
|
const char *filename,
|
||||||
|
unsigned int flags)
|
||||||
{
|
{
|
||||||
virStorageVolDefPtr ret = NULL;
|
virStorageVolDefPtr ret = NULL;
|
||||||
xmlDocPtr xml;
|
xmlDocPtr xml;
|
||||||
|
|
||||||
if ((xml = virXMLParse(filename, xmlStr, _("(storage_volume_definition)")))) {
|
if ((xml = virXMLParse(filename, xmlStr, _("(storage_volume_definition)")))) {
|
||||||
ret = virStorageVolDefParseNode(pool, xml, xmlDocGetRootElement(xml));
|
ret = virStorageVolDefParseNode(pool, xml, xmlDocGetRootElement(xml), flags);
|
||||||
xmlFreeDoc(xml);
|
xmlFreeDoc(xml);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1473,16 +1478,18 @@ virStorageVolDefParse(virStoragePoolDefPtr pool,
|
|||||||
|
|
||||||
virStorageVolDefPtr
|
virStorageVolDefPtr
|
||||||
virStorageVolDefParseString(virStoragePoolDefPtr pool,
|
virStorageVolDefParseString(virStoragePoolDefPtr pool,
|
||||||
const char *xmlStr)
|
const char *xmlStr,
|
||||||
|
unsigned int flags)
|
||||||
{
|
{
|
||||||
return virStorageVolDefParse(pool, xmlStr, NULL);
|
return virStorageVolDefParse(pool, xmlStr, NULL, flags);
|
||||||
}
|
}
|
||||||
|
|
||||||
virStorageVolDefPtr
|
virStorageVolDefPtr
|
||||||
virStorageVolDefParseFile(virStoragePoolDefPtr pool,
|
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
|
static void
|
||||||
|
@ -347,14 +347,17 @@ char *virStoragePoolDefFormat(virStoragePoolDefPtr def);
|
|||||||
|
|
||||||
virStorageVolDefPtr
|
virStorageVolDefPtr
|
||||||
virStorageVolDefParseString(virStoragePoolDefPtr pool,
|
virStorageVolDefParseString(virStoragePoolDefPtr pool,
|
||||||
const char *xml);
|
const char *xml,
|
||||||
|
unsigned int flags);
|
||||||
virStorageVolDefPtr
|
virStorageVolDefPtr
|
||||||
virStorageVolDefParseFile(virStoragePoolDefPtr pool,
|
virStorageVolDefParseFile(virStoragePoolDefPtr pool,
|
||||||
const char *filename);
|
const char *filename,
|
||||||
|
unsigned int flags);
|
||||||
virStorageVolDefPtr
|
virStorageVolDefPtr
|
||||||
virStorageVolDefParseNode(virStoragePoolDefPtr pool,
|
virStorageVolDefParseNode(virStoragePoolDefPtr pool,
|
||||||
xmlDocPtr xml,
|
xmlDocPtr xml,
|
||||||
xmlNodePtr root);
|
xmlNodePtr root,
|
||||||
|
unsigned int flags);
|
||||||
char *virStorageVolDefFormat(virStoragePoolDefPtr pool,
|
char *virStorageVolDefFormat(virStoragePoolDefPtr pool,
|
||||||
virStorageVolDefPtr def);
|
virStorageVolDefPtr def);
|
||||||
|
|
||||||
|
@ -864,7 +864,7 @@ esxStorageVolCreateXML(virStoragePoolPtr pool,
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Parse config */
|
/* Parse config */
|
||||||
def = virStorageVolDefParseString(&poolDef, xmldesc);
|
def = virStorageVolDefParseString(&poolDef, xmldesc, 0);
|
||||||
|
|
||||||
if (!def)
|
if (!def)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
@ -1085,7 +1085,7 @@ esxStorageVolCreateXMLFrom(virStoragePoolPtr pool,
|
|||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
/* Parse config */
|
/* Parse config */
|
||||||
def = virStorageVolDefParseString(&poolDef, xmldesc);
|
def = virStorageVolDefParseString(&poolDef, xmldesc, 0);
|
||||||
|
|
||||||
if (!def)
|
if (!def)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
@ -1208,9 +1208,9 @@ parallelsStorageVolDefineXML(virStoragePoolObjPtr pool,
|
|||||||
char *xml_path = NULL;
|
char *xml_path = NULL;
|
||||||
|
|
||||||
if (xmlfile)
|
if (xmlfile)
|
||||||
privvol = virStorageVolDefParseFile(pool->def, xmlfile);
|
privvol = virStorageVolDefParseFile(pool->def, xmlfile, 0);
|
||||||
else
|
else
|
||||||
privvol = virStorageVolDefParseString(pool->def, xmldesc);
|
privvol = virStorageVolDefParseString(pool->def, xmldesc, 0);
|
||||||
|
|
||||||
if (privvol == NULL)
|
if (privvol == NULL)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
@ -1335,7 +1335,7 @@ parallelsStorageVolCreateXMLFrom(virStoragePoolPtr pool,
|
|||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
privvol = virStorageVolDefParseString(privpool->def, xmldesc);
|
privvol = virStorageVolDefParseString(privpool->def, xmldesc, 0);
|
||||||
if (privvol == NULL)
|
if (privvol == NULL)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
|
@ -2026,7 +2026,7 @@ phypStorageVolCreateXML(virStoragePoolPtr pool,
|
|||||||
goto err;
|
goto err;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((voldef = virStorageVolDefParseString(spdef, xml)) == NULL) {
|
if ((voldef = virStorageVolDefParseString(spdef, xml, 0)) == NULL) {
|
||||||
VIR_ERROR(_("Error parsing volume XML."));
|
VIR_ERROR(_("Error parsing volume XML."));
|
||||||
goto err;
|
goto err;
|
||||||
}
|
}
|
||||||
|
@ -1649,7 +1649,7 @@ storageVolCreateXML(virStoragePoolPtr obj,
|
|||||||
if ((backend = virStorageBackendForType(pool->def->type)) == NULL)
|
if ((backend = virStorageBackendForType(pool->def->type)) == NULL)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
voldef = virStorageVolDefParseString(pool->def, xmldesc);
|
voldef = virStorageVolDefParseString(pool->def, xmldesc, 0);
|
||||||
if (voldef == NULL)
|
if (voldef == NULL)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
@ -1810,7 +1810,7 @@ storageVolCreateXMLFrom(virStoragePoolPtr obj,
|
|||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
newvol = virStorageVolDefParseString(pool->def, xmldesc);
|
newvol = virStorageVolDefParseString(pool->def, xmldesc, 0);
|
||||||
if (newvol == NULL)
|
if (newvol == NULL)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
|
@ -1230,7 +1230,7 @@ testOpenVolumesForPool(const char *file,
|
|||||||
if (!node)
|
if (!node)
|
||||||
goto error;
|
goto error;
|
||||||
|
|
||||||
def = virStorageVolDefParseNode(pool->def, ctxt->doc, node);
|
def = virStorageVolDefParseNode(pool->def, ctxt->doc, node, 0);
|
||||||
if (!def)
|
if (!def)
|
||||||
goto error;
|
goto error;
|
||||||
|
|
||||||
@ -5430,7 +5430,7 @@ testStorageVolCreateXML(virStoragePoolPtr pool,
|
|||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
privvol = virStorageVolDefParseString(privpool->def, xmldesc);
|
privvol = virStorageVolDefParseString(privpool->def, xmldesc, 0);
|
||||||
if (privvol == NULL)
|
if (privvol == NULL)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
@ -5504,7 +5504,7 @@ testStorageVolCreateXMLFrom(virStoragePoolPtr pool,
|
|||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
privvol = virStorageVolDefParseString(privpool->def, xmldesc);
|
privvol = virStorageVolDefParseString(privpool->def, xmldesc, 0);
|
||||||
if (privvol == NULL)
|
if (privvol == NULL)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
|
@ -430,7 +430,7 @@ vboxStorageVolCreateXML(virStoragePoolPtr pool,
|
|||||||
memset(&poolDef, 0, sizeof(poolDef));
|
memset(&poolDef, 0, sizeof(poolDef));
|
||||||
poolDef.type = VIR_STORAGE_POOL_DIR;
|
poolDef.type = VIR_STORAGE_POOL_DIR;
|
||||||
|
|
||||||
if ((def = virStorageVolDefParseString(&poolDef, xml)) == NULL)
|
if ((def = virStorageVolDefParseString(&poolDef, xml, 0)) == NULL)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
if (!def->name ||
|
if (!def->name ||
|
||||||
|
@ -100,7 +100,7 @@ test_vdi_list_parser(collie_test test, char *poolxml, char *volxml)
|
|||||||
if (!(pool = virStoragePoolDefParseString(poolXmlData)))
|
if (!(pool = virStoragePoolDefParseString(poolXmlData)))
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
if (!(vol = virStorageVolDefParseString(pool, volXmlData)))
|
if (!(vol = virStorageVolDefParseString(pool, volXmlData, 0)))
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
if (VIR_STRDUP(output, test.output) < 0)
|
if (VIR_STRDUP(output, test.output) < 0)
|
||||||
|
@ -84,11 +84,11 @@ testCompareXMLToArgvFiles(bool shouldFail,
|
|||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!(vol = virStorageVolDefParseString(pool, volXmlData)))
|
if (!(vol = virStorageVolDefParseString(pool, volXmlData, 0)))
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
if (inputvolxml &&
|
if (inputvolxml &&
|
||||||
!(inputvol = virStorageVolDefParseString(inputpool, inputvolXmlData)))
|
!(inputvol = virStorageVolDefParseString(inputpool, inputvolXmlData, 0)))
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
testSetVolumeType(vol, pool);
|
testSetVolumeType(vol, pool);
|
||||||
|
@ -18,7 +18,7 @@
|
|||||||
|
|
||||||
static int
|
static int
|
||||||
testCompareXMLToXMLFiles(const char *poolxml, const char *inxml,
|
testCompareXMLToXMLFiles(const char *poolxml, const char *inxml,
|
||||||
const char *outxml)
|
const char *outxml, unsigned int flags)
|
||||||
{
|
{
|
||||||
char *poolXmlData = NULL;
|
char *poolXmlData = NULL;
|
||||||
char *inXmlData = NULL;
|
char *inXmlData = NULL;
|
||||||
@ -38,7 +38,7 @@ testCompareXMLToXMLFiles(const char *poolxml, const char *inxml,
|
|||||||
if (!(pool = virStoragePoolDefParseString(poolXmlData)))
|
if (!(pool = virStoragePoolDefParseString(poolXmlData)))
|
||||||
goto fail;
|
goto fail;
|
||||||
|
|
||||||
if (!(dev = virStorageVolDefParseString(pool, inXmlData)))
|
if (!(dev = virStorageVolDefParseString(pool, inXmlData, flags)))
|
||||||
goto fail;
|
goto fail;
|
||||||
|
|
||||||
if (!(actual = virStorageVolDefFormat(pool, dev)))
|
if (!(actual = virStorageVolDefFormat(pool, dev)))
|
||||||
@ -64,6 +64,7 @@ testCompareXMLToXMLFiles(const char *poolxml, const char *inxml,
|
|||||||
struct testInfo {
|
struct testInfo {
|
||||||
const char *pool;
|
const char *pool;
|
||||||
const char *name;
|
const char *name;
|
||||||
|
unsigned int flags;
|
||||||
};
|
};
|
||||||
|
|
||||||
static int
|
static int
|
||||||
@ -84,7 +85,7 @@ testCompareXMLToXMLHelper(const void *data)
|
|||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
result = testCompareXMLToXMLFiles(poolxml, inxml, outxml);
|
result = testCompareXMLToXMLFiles(poolxml, inxml, outxml, info->flags);
|
||||||
|
|
||||||
cleanup:
|
cleanup:
|
||||||
VIR_FREE(poolxml);
|
VIR_FREE(poolxml);
|
||||||
@ -100,15 +101,17 @@ mymain(void)
|
|||||||
{
|
{
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
|
|
||||||
#define DO_TEST(pool, name) \
|
#define DO_TEST_FULL(pool, name, flags) \
|
||||||
do { \
|
do { \
|
||||||
struct testInfo info = { pool, name }; \
|
struct testInfo info = { pool, name, flags }; \
|
||||||
if (virtTestRun("Storage Vol XML-2-XML " name, \
|
if (virtTestRun("Storage Vol XML-2-XML " name, \
|
||||||
testCompareXMLToXMLHelper, &info) < 0) \
|
testCompareXMLToXMLHelper, &info) < 0) \
|
||||||
ret = -1; \
|
ret = -1; \
|
||||||
} \
|
} \
|
||||||
while (0);
|
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");
|
||||||
DO_TEST("pool-dir", "vol-file-naming");
|
DO_TEST("pool-dir", "vol-file-naming");
|
||||||
DO_TEST("pool-dir", "vol-file-backing");
|
DO_TEST("pool-dir", "vol-file-backing");
|
||||||
|
Loading…
Reference in New Issue
Block a user