]> git.ipfire.org Git - thirdparty/libvirt.git/commit
storage: Fix issues in storageVolResize
authorJohn Ferlan <jferlan@redhat.com>
Fri, 27 Mar 2015 13:48:59 +0000 (09:48 -0400)
committerJohn Ferlan <jferlan@redhat.com>
Thu, 9 Apr 2015 23:04:18 +0000 (19:04 -0400)
commit1095230dee8e1bf184248b087695f45f867a4143
tree82a800a2c95c306ebf31a5091ee6e050d943282e
parenta45ef3a9cdfe7a1f847da68ab3d7313595c0bc05
storage: Fix issues in storageVolResize

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

When creating a volume in a pool, the creation allows the 'capacity'
value to be larger than the available space in the pool. As long as
the 'allocation' value will fit in the space, the volume will be created.

However, resizing the volume checks were made with the new absolute
capacity value against existing capacity + the available space without
regard for whether the new absolute capacity was actually allocating
space or not.  For example, a pool with 75G of available space creates
a volume of 10G using a capacity of 100G and allocation of 10G will succeed;
however, if the allocation used a capacity of 10G instead and then tried
to resize the allocation to 100G the code would fail to allow the backend
to try the resize.

Furthermore, when updating the pool "available" and "allocation" values,
the resize code would just "blindly" adjust them regardless of whether
space was "allocated" or just "capacity" was being adjusted.  This left
a scenario whereby a resize to 100G would fail; however, a resize to 50G
followed by one to 100G would both succeed.  Again, neither was adjusting
the allocation value, just the "capacity" value.

This patch adds more logic to the resize code to understand whether the
new capacity value is actually "allocating" space as well and whether it
shrinking or expanding. Since unsigned arithmatic is involved, the possibility
that we adjust the pool size values incorrectly is probable.

This patch also ensures that updates to the pool values only occur if we
actually performed the allocation.

NB: The storageVolDelete, storageVolCreateXML, and storageVolCreateXMLFrom
each only updates the pool allocation/availability values by the target
volume allocation value.
src/storage/storage_driver.c