]> xenbits.xensource.com Git - people/liuw/libxenctrl-split/libvirt.git/commitdiff
Allow omitting volume capacity when backing store is specified
authorJán Tomko <jtomko@redhat.com>
Tue, 17 Feb 2015 15:55:59 +0000 (16:55 +0100)
committerJán Tomko <jtomko@redhat.com>
Mon, 2 Mar 2015 07:07:11 +0000 (08:07 +0100)
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
src/conf/storage_conf.h

index f4e68a7338fe4751c626c4e5eda6604db0b3fd85..4c1f05dd8a5097b0f986413a440fdf423ca393a1 100644 (file)
@@ -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;
     }
index c28e2dd37bef6995d51d1bfb8ac22fb8e20f9f33..4584075ce6b6f0f3e869f7322923f8f50054250e 100644 (file)
@@ -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,