storage: Fix issues in storageVolResize
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.

jardasgit/libvirt,zippy2/libvirt,eskultety/libvirt,fabianfreyer/libvirt,libvirt/libvirt,nertpinx/libvirt,andreabolognani/libvirt,fabianfreyer/libvirt,andreabolognani/libvirt,VenkatDatta/libvirt,jardasgit/libvirt,jfehlig/libvirt,andreabolognani/libvirt,agx/libvirt,crobinso/libvirt,libvirt/libvirt,fabianfreyer/libvirt,fabianfreyer/libvirt,datto/libvirt,eskultety/libvirt,nertpinx/libvirt,olafhering/libvirt,andreabolognani/libvirt,fabianfreyer/libvirt,VenkatDatta/libvirt,crobinso/libvirt,agx/libvirt,datto/libvirt,agx/libvirt,libvirt/libvirt,jardasgit/libvirt,zippy2/libvirt,jardasgit/libvirt,datto/libvirt,andreabolognani/libvirt,zippy2/libvirt,zippy2/libvirt,eskultety/libvirt,datto/libvirt,taget/libvirt,agx/libvirt,taget/libvirt,eskultety/libvirt,jfehlig/libvirt,rlaager/libvirt,agx/libvirt,VenkatDatta/libvirt,taget/libvirt,VenkatDatta/libvirt,VenkatDatta/libvirt,olafhering/libvirt,taget/libvirt,jfehlig/libvirt,crobinso/libvirt,jardasgit/libvirt,rlaager/libvirt,nertpinx/libvirt,rlaager/libvirt,rlaager/libvirt,nertpinx/libvirt,rlaager/libvirt,datto/libvirt,crobinso/libvirt,jfehlig/libvirt,olafhering/libvirt,libvirt/libvirt,nertpinx/libvirt,eskultety/libvirt,taget/libvirt,olafhering/libvirt