From 813e4b7f83ef3fb966260db6d59ac54e9ede903f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A1n=20Tomko?= Date: Tue, 17 Feb 2015 16:55:59 +0100 Subject: [PATCH] Allow omitting volume capacity when backing store is specified Add VIR_VOL_XML_PARSE_OPT_CAPACITY flag to virStorageVolDefParseXML. With this flag, no error is reported when the capacity is missing if there is a backing store. --- src/conf/storage_conf.c | 6 ++++-- src/conf/storage_conf.h | 2 ++ 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/conf/storage_conf.c b/src/conf/storage_conf.c index f4e68a7338..4c1f05dd8a 100644 --- a/src/conf/storage_conf.c +++ b/src/conf/storage_conf.c @@ -1260,7 +1260,8 @@ virStorageVolDefParseXML(virStoragePoolDefPtr pool, size_t i; int n; - virCheckFlags(VIR_VOL_XML_PARSE_NO_CAPACITY, NULL); + virCheckFlags(VIR_VOL_XML_PARSE_NO_CAPACITY | + VIR_VOL_XML_PARSE_OPT_CAPACITY, NULL); options = virStorageVolOptionsForPoolType(pool->type); if (options == NULL) @@ -1325,7 +1326,8 @@ virStorageVolDefParseXML(virStoragePoolDefPtr pool, if (capacity) { if (virStorageSize(unit, capacity, &ret->target.capacity) < 0) goto error; - } else if (!(flags & VIR_VOL_XML_PARSE_NO_CAPACITY)) { + } else if (!(flags & VIR_VOL_XML_PARSE_NO_CAPACITY) && + !((flags & VIR_VOL_XML_PARSE_OPT_CAPACITY) && ret->target.backingStore)) { virReportError(VIR_ERR_XML_ERROR, "%s", _("missing capacity element")); goto error; } diff --git a/src/conf/storage_conf.h b/src/conf/storage_conf.h index c28e2dd37b..4584075ce6 100644 --- a/src/conf/storage_conf.h +++ b/src/conf/storage_conf.h @@ -348,6 +348,8 @@ char *virStoragePoolDefFormat(virStoragePoolDefPtr def); typedef enum { /* do not require volume capacity at all */ VIR_VOL_XML_PARSE_NO_CAPACITY = 1 << 0, + /* do not require volume capacity if the volume has a backing store */ + VIR_VOL_XML_PARSE_OPT_CAPACITY = 1 << 1, } virStorageVolDefParseFlags; virStorageVolDefPtr virStorageVolDefParseString(virStoragePoolDefPtr pool,