]> xenbits.xensource.com Git - people/liuw/libxenctrl-split/libvirt.git/commitdiff
Update pool allocation with new values on volume creation
authorJán Tomko <jtomko@redhat.com>
Thu, 24 Sep 2015 15:01:40 +0000 (17:01 +0200)
committerJán Tomko <jtomko@redhat.com>
Tue, 29 Sep 2015 08:45:01 +0000 (10:45 +0200)
Since commit e0139e3, we update the pool allocation with
the user-provided allocation values.

For qcow2, the allocation is ignored for volume building,
but we still subtracted it from pool's allocation.
This can result in interesting values if the user-provided
allocation is large enough:

Capacity:       104.71 GiB
Allocation:     109.13 GiB
Available:      16.00 EiB

We already do a VolRefresh on volume creation. Also refresh
the volume after creating and use the new value to update the pool.

https://bugzilla.redhat.com/show_bug.cgi?id=1163091

src/storage/storage_driver.c

index 0494e5d7a0695612631a20ac09e92e67f0ef2c42..16d0b6c71f3857b5b90df4749eb060f040183c64 100644 (file)
@@ -1878,8 +1878,8 @@ storageVolCreateXML(virStoragePoolPtr obj,
      * it updates the pool values.
      */
     if (pool->def->type != VIR_STORAGE_POOL_DISK) {
-        pool->def->allocation += buildvoldef->target.allocation;
-        pool->def->available -= buildvoldef->target.allocation;
+        pool->def->allocation += voldef->target.allocation;
+        pool->def->available -= voldef->target.allocation;
     }
 
     VIR_INFO("Creating volume '%s' in storage pool '%s'",
@@ -2057,25 +2057,27 @@ storageVolCreateXMLFrom(virStoragePoolPtr obj,
         origpool = NULL;
     }
 
-    if (buildret < 0) {
+    if (buildret < 0 ||
+        (backend->refreshVol &&
+         backend->refreshVol(obj->conn, pool, newvol) < 0)) {
         storageVolDeleteInternal(volobj, backend, pool, newvol, 0, false);
         newvol = NULL;
         goto cleanup;
     }
-    newvol = NULL;
 
     /* Updating pool metadata ignoring the disk backend since
      * it updates the pool values
      */
     if (pool->def->type != VIR_STORAGE_POOL_DISK) {
-        pool->def->allocation += shadowvol->target.allocation;
-        pool->def->available -= shadowvol->target.allocation;
+        pool->def->allocation += newvol->target.allocation;
+        pool->def->available -= newvol->target.allocation;
     }
 
     VIR_INFO("Creating volume '%s' in storage pool '%s'",
              volobj->name, pool->def->name);
     ret = volobj;
     volobj = NULL;
+    newvol = NULL;
 
  cleanup:
     virObjectUnref(volobj);