Change in vdsm[master]: virt: Introduce Vm._setVolumeSize helper

nsoffer at redhat.com nsoffer at redhat.com
Thu Feb 19 09:38:43 UTC 2015


Nir Soffer has uploaded a new change for review.

Change subject: virt: Introduce Vm._setVolumeSize helper
......................................................................

virt: Introduce Vm._setVolumeSize helper

We have two place invoking self.cif.irs.setVolumeSize(), ignoring errors
without documenting the reason. This patch adds Vm._setVolumeSize()
helper that raises on errors, eliminating such code.

We use setVolumeSize() when extending a disk. First we set volume size to
0, marking it as in transaction. Then we update the guest about the new
size via libvirt, and finally we store the new size in the volume.

In the first setVolumeSize() call setting volume size to 0, it is clear
that we want to fail the operation, so using _setVolumeSize() the
request fails without additional error handling code.

The second setVolumeSize() call updating the volume to the actual new
size is done after the vm was updated and can use the new device, so it
is not clear if we should fail the request or just warn about the
incorrect meta data in the volume (size=0). This patches changes the
behavior to fail the request in this case.

Change-Id: I742fde77a23387f89fa746c2030e151237cb230f
Signed-off-by: Nir Soffer <nsoffer at redhat.com>
---
M vdsm/virt/vm.py
1 file changed, 12 insertions(+), 5 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/43/37943/1

diff --git a/vdsm/virt/vm.py b/vdsm/virt/vm.py
index 82cf92b..c3ca803 100644
--- a/vdsm/virt/vm.py
+++ b/vdsm/virt/vm.py
@@ -3587,8 +3587,8 @@
             return errCode['resizeErr']
 
         # Uncommit the current volume size (mark as in transaction)
-        self.cif.irs.setVolumeSize(drive.domainID, drive.poolID,
-                                   drive.imageID, drive.volumeID, 0)
+        self._setVolumeSize(drive.domainID, drive.poolID, drive.imageID,
+                            drive.volumeID, 0)
 
         try:
             self._dom.blockResize(drive.name, newSizeBytes,
@@ -3602,9 +3602,8 @@
             # In all cases we want to try and fix the size in the metadata.
             # Same as above, this is what libvirt would do, see BZ#963881
             sizeRoundedBytes = qemuimg.info(drive.path, "qcow2")['virtualsize']
-            self.cif.irs.setVolumeSize(
-                drive.domainID, drive.poolID, drive.imageID, drive.volumeID,
-                sizeRoundedBytes)
+            self._setVolumeSize(drive.domainID, drive.poolID, drive.imageID,
+                                drive.volumeID, sizeRoundedBytes)
 
         return {'status': doneCode, 'size': str(sizeRoundedBytes)}
 
@@ -4933,6 +4932,14 @@
                 (domainID, volumeID))
         return VolumeSize(int(res['apparentsize']), int(res['truesize']))
 
+    def _setVolumeSize(self, domainID, poolID, imageID, volumeID, size):
+        res = self.cif.irs.setVolumeSize(domainID, poolID, imageID, volumeID,
+                                         size)
+        if res['status']['code'] != 0:
+            raise StorageUnavailableError(
+                "Unable to set volume size to %s for domain %s volume %s" %
+                (size, domainID, volumeID))
+
 
 class LiveMergeCleanupThread(threading.Thread):
     def __init__(self, vm, jobId, drive, doPivot):


-- 
To view, visit http://gerrit.ovirt.org/37943
To unsubscribe, visit http://gerrit.ovirt.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I742fde77a23387f89fa746c2030e151237cb230f
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Nir Soffer <nsoffer at redhat.com>


More information about the vdsm-patches mailing list