if ((backend = virStorageBackendForType(pool->def->type)) == NULL)
goto cleanup;
- voldef = virStorageVolDefParseString(pool->def, xmldesc, 0);
+ voldef = virStorageVolDefParseString(pool->def, xmldesc,
+ VIR_VOL_XML_PARSE_OPT_CAPACITY);
if (voldef == NULL)
goto cleanup;
+ if (!voldef->target.capacity && !backend->buildVol) {
+ virReportError(VIR_ERR_NO_SUPPORT,
+ "%s", _("volume capacity required for this "
+ "storage pool"));
+ goto cleanup;
+ }
+
if (virStorageVolCreateXMLEnsureACL(obj->conn, pool->def, voldef) < 0)
goto cleanup;
}
+ if (backend->refreshVol &&
+ backend->refreshVol(obj->conn, pool, voldef) < 0)
+ goto cleanup;
+
/* Update pool metadata */
pool->def->allocation += buildvoldef->target.allocation;
pool->def->available -= buildvoldef->target.allocation;
const char *inputvolxml,
const char *cmdline,
unsigned int flags,
- int imgformat)
+ int imgformat,
+ unsigned long parse_flags)
{
char *volXmlData = NULL;
char *poolXmlData = NULL;
char *expectedCmdline = NULL;
char *actualCmdline = NULL;
int ret = -1;
- unsigned long parse_flags = 0;
int len;
const char *cmdline;
unsigned int flags;
int imgformat;
+ unsigned long parseflags;
};
static int
result = testCompareXMLToArgvFiles(info->shouldFail, poolxml, volxml,
inputpoolxml, inputvolxml,
cmdline, info->flags,
- info->imgformat);
+ info->imgformat, info->parseflags);
cleanup:
VIR_FREE(poolxml);
int ret = 0;
unsigned int flags = VIR_STORAGE_VOL_CREATE_PREALLOC_METADATA;
-#define DO_TEST_FULL(shouldFail, pool, vol, inputpool, inputvol, cmdline, \
- flags, imgformat) \
+#define DO_TEST_FULL(shouldFail, parseflags, pool, vol, inputpool, inputvol, \
+ cmdline, flags, imgformat) \
do { \
struct testInfo info = { shouldFail, pool, vol, inputpool, inputvol, \
- cmdline, flags, imgformat }; \
+ cmdline, flags, imgformat, parseflags }; \
if (virtTestRun("Storage Vol XML-2-argv " cmdline, \
testCompareXMLToArgvHelper, &info) < 0) \
ret = -1; \
while (0);
#define DO_TEST(pool, ...) \
- DO_TEST_FULL(false, pool, __VA_ARGS__)
+ DO_TEST_FULL(false, 0, pool, __VA_ARGS__)
#define DO_TEST_FAIL(pool, ...) \
- DO_TEST_FULL(true, pool, __VA_ARGS__)
+ DO_TEST_FULL(true, 0, pool, __VA_ARGS__)
DO_TEST("pool-dir", "vol-qcow2",
NULL, NULL,
DO_TEST("pool-dir", "vol-qcow2-nocapacity",
"pool-dir", "vol-file",
"qcow2-nocapacity-convert-prealloc", flags, FMT_OPTIONS);
+ DO_TEST_FULL(false, VIR_VOL_XML_PARSE_OPT_CAPACITY,
+ "pool-dir", "vol-qcow2-nocapacity-backing", NULL, NULL,
+ "qcow2-nocapacity", 0, FMT_OPTIONS);
return ret == 0 ? EXIT_SUCCESS : EXIT_FAILURE;
}