Signed-off-by: Peter Krempa <pkrempa@xxxxxxxxxx> --- src/storage/storage_driver.c | 18 ++++++++++++++---- src/test/test_driver.c | 16 ++++++++++++---- src/vbox/vbox_storage.c | 8 ++++++-- 3 files changed, 32 insertions(+), 10 deletions(-) diff --git a/src/storage/storage_driver.c b/src/storage/storage_driver.c index c25d9ca1ad..d90c1c9ee8 100644 --- a/src/storage/storage_driver.c +++ b/src/storage/storage_driver.c @@ -1877,8 +1877,13 @@ storageVolCreateXML(virStoragePoolPtr pool, virStorageBackend *backend; virStorageVolPtr vol = NULL, newvol = NULL; g_autoptr(virStorageVolDef) voldef = NULL; + unsigned int parseFlags = VIR_VOL_XML_PARSE_OPT_CAPACITY; - virCheckFlags(VIR_STORAGE_VOL_CREATE_PREALLOC_METADATA, NULL); + virCheckFlags(VIR_STORAGE_VOL_CREATE_PREALLOC_METADATA | + VIR_STORAGE_VOL_CREATE_VALIDATE, NULL); + + if (flags & VIR_STORAGE_VOL_CREATE_VALIDATE) + parseFlags |= VIR_VOL_XML_PARSE_VALIDATE; if (!(obj = virStoragePoolObjFromStoragePool(pool))) return NULL; @@ -1893,7 +1898,7 @@ storageVolCreateXML(virStoragePoolPtr pool, if ((backend = virStorageBackendForType(def->type)) == NULL) goto cleanup; - voldef = virStorageVolDefParse(def, xmldesc, NULL, VIR_VOL_XML_PARSE_OPT_CAPACITY); + voldef = virStorageVolDefParse(def, xmldesc, NULL, parseFlags); if (voldef == NULL) goto cleanup; @@ -2012,11 +2017,16 @@ storageVolCreateXMLFrom(virStoragePoolPtr pool, virStorageVolPtr vol = NULL; int buildret; g_autoptr(virStorageVolDef) voldef = NULL; + unsigned int parseFlags = VIR_VOL_XML_PARSE_NO_CAPACITY; virCheckFlags(VIR_STORAGE_VOL_CREATE_PREALLOC_METADATA | - VIR_STORAGE_VOL_CREATE_REFLINK, + VIR_STORAGE_VOL_CREATE_REFLINK | + VIR_STORAGE_VOL_CREATE_VALIDATE, NULL); + if (flags & VIR_STORAGE_VOL_CREATE_VALIDATE) + parseFlags |= VIR_VOL_XML_PARSE_VALIDATE; + obj = virStoragePoolObjFindByUUID(driver->pools, pool->uuid); if (obj && STRNEQ(pool->name, volsrc->pool)) { virObjectUnlock(obj); @@ -2066,7 +2076,7 @@ storageVolCreateXMLFrom(virStoragePoolPtr pool, goto cleanup; } - voldef = virStorageVolDefParse(def, xmldesc, NULL, VIR_VOL_XML_PARSE_NO_CAPACITY); + voldef = virStorageVolDefParse(def, xmldesc, NULL, parseFlags); if (voldef == NULL) goto cleanup; diff --git a/src/test/test_driver.c b/src/test/test_driver.c index 58c2a02561..87c7d8cf65 100644 --- a/src/test/test_driver.c +++ b/src/test/test_driver.c @@ -7182,14 +7182,18 @@ testStorageVolCreateXML(virStoragePoolPtr pool, virStoragePoolDef *def; virStorageVolPtr ret = NULL; g_autoptr(virStorageVolDef) privvol = NULL; + unsigned int parseFlags = 0; - virCheckFlags(0, NULL); + virCheckFlags(VIR_STORAGE_VOL_CREATE_VALIDATE, NULL); + + if (flags & VIR_STORAGE_VOL_CREATE_VALIDATE) + parseFlags |= VIR_VOL_XML_PARSE_VALIDATE; if (!(obj = testStoragePoolObjFindActiveByName(privconn, pool->name))) return NULL; def = virStoragePoolObjGetDef(obj); - privvol = virStorageVolDefParse(def, xmldesc, NULL, 0); + privvol = virStorageVolDefParse(def, xmldesc, NULL, parseFlags); if (privvol == NULL) goto cleanup; @@ -7241,14 +7245,18 @@ testStorageVolCreateXMLFrom(virStoragePoolPtr pool, virStorageVolDef *origvol = NULL; virStorageVolPtr ret = NULL; g_autoptr(virStorageVolDef) privvol = NULL; + unsigned int parseFlags = 0; - virCheckFlags(0, NULL); + virCheckFlags(VIR_STORAGE_VOL_CREATE_VALIDATE, NULL); + + if (flags & VIR_STORAGE_VOL_CREATE_VALIDATE) + parseFlags |= VIR_VOL_XML_PARSE_VALIDATE; if (!(obj = testStoragePoolObjFindActiveByName(privconn, pool->name))) return NULL; def = virStoragePoolObjGetDef(obj); - privvol = virStorageVolDefParse(def, xmldesc, NULL, 0); + privvol = virStorageVolDefParse(def, xmldesc, NULL, parseFlags); if (privvol == NULL) goto cleanup; diff --git a/src/vbox/vbox_storage.c b/src/vbox/vbox_storage.c index 7d1cee562f..f6ede700f9 100644 --- a/src/vbox/vbox_storage.c +++ b/src/vbox/vbox_storage.c @@ -409,11 +409,15 @@ vboxStorageVolCreateXML(virStoragePoolPtr pool, virStorageVolPtr ret = NULL; g_autoptr(virStorageVolDef) def = NULL; g_autofree char *homedir = NULL; + unsigned int parseFlags = 0; if (!data->vboxObj) return ret; - virCheckFlags(0, NULL); + virCheckFlags(VIR_STORAGE_VOL_CREATE_VALIDATE, NULL); + + if (flags & VIR_STORAGE_VOL_CREATE_VALIDATE) + parseFlags |= VIR_VOL_XML_PARSE_VALIDATE; /* since there is currently one default pool now * and virStorageVolDefFormat() just checks it type @@ -423,7 +427,7 @@ vboxStorageVolCreateXML(virStoragePoolPtr pool, memset(&poolDef, 0, sizeof(poolDef)); poolDef.type = VIR_STORAGE_POOL_DIR; - if ((def = virStorageVolDefParse(&poolDef, xml, NULL, 0)) == NULL) + if ((def = virStorageVolDefParse(&poolDef, xml, NULL, parseFlags)) == NULL) goto cleanup; if (!def->name || -- 2.37.3