]> xenbits.xensource.com Git - people/liuw/libxenctrl-split/libvirt.git/commitdiff
storage: Fix problem with disk backend pool allocation calculation
authorJohn Ferlan <jferlan@redhat.com>
Fri, 22 May 2015 01:10:56 +0000 (21:10 -0400)
committerJohn Ferlan <jferlan@redhat.com>
Thu, 28 May 2015 17:32:16 +0000 (13:32 -0400)
https://bugzilla.redhat.com/show_bug.cgi?id=1224018

The disk pool recalculates the pool allocation, capacity, and available
values each time through processing a newly created disk partition. This
created an issue with the allocation setting since the code used is shared
with the refresh path. Each path calls virStorageBackendDiskReadPartitions
which initializes the pool values and then processes the partition table
from the 'libvirt_parthelper' utility output with the only difference being
create passes a specific volume to be processed while refresh pass a NULL
indicating to process all volumes. That passed volume is check during the
virStorageBackendDiskMakeVol call to see if the current partition described
by the volume key already exists. If it exists, then no adjustments are
made to the allocation and the next entry in the output is checked.

For the create path this resulted in only the most recently created
partition size would be accounted for in the 'allocation' setting. This
patch thus checks whether the incoming volume is NULL before clearing
the pool allocation value.

src/storage/storage_backend_disk.c

index 4dc63d753e1e06ed6b305cad2466ac1f1d72f144..c4bd6fe2c501d089b75322c3e1f927d473f7512c 100644 (file)
@@ -309,7 +309,12 @@ virStorageBackendDiskReadPartitions(virStoragePoolObjPtr pool,
                                pool->def->source.devices[0].path,
                                NULL);
 
-    pool->def->allocation = pool->def->capacity = pool->def->available = 0;
+    /* If a volume is passed, virStorageBackendDiskMakeVol only updates the
+     * pool allocation for that single volume.
+     */
+    if (!vol)
+        pool->def->allocation = 0;
+    pool->def->capacity = pool->def->available = 0;
 
     ret = virCommandRunNul(cmd,
                            6,