Change in vdsm[master]: virt: Add Derive.extendable property

nsoffer at redhat.com nsoffer at redhat.com
Sun Feb 8 08:02:14 UTC 2015


Nir Soffer has uploaded a new change for review.

Change subject: virt: Add Derive.extendable property
......................................................................

virt: Add Derive.extendable property

Previously the logic was extending a drive was part of the vm god-class.
This makes the code little more readable, and encapsulate the logic
in a better location.

Unfinished: need to use this property in few other locations that seems
to use wrong check (blockDev == True).

Change-Id: Iedbb9ea5e708cc606def799a78f7089bc80f77c9
Signed-off-by: Nir Soffer <nsoffer at redhat.com>
---
M tests/vmStorageTests.py
M vdsm/virt/vm.py
M vdsm/virt/vmdevices/storage.py
3 files changed, 32 insertions(+), 1 deletion(-)


  git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/70/37570/1

diff --git a/tests/vmStorageTests.py b/tests/vmStorageTests.py
index 307b0d8..d57c763 100644
--- a/tests/vmStorageTests.py
+++ b/tests/vmStorageTests.py
@@ -224,6 +224,26 @@
         self.assertFalse(drive.blockDev)
 
 
+ at expandPermutations
+class ExtendingTests(VdsmTestCase):
+
+    @permutations([
+        # device, blockDev, format, extendable
+        ('cdrom', True, 'raw', False),
+        ('cdrom', False, 'raw', False),
+        ('floppy', False, 'raw', False),
+        ('disk', False, 'raw', False),
+        ('disk', True, 'raw', False),
+        ('lun', True, 'raw', False),
+        ('disk', True, 'cow', True),
+    ])
+    def test_extendable(self, device, blockDev, format, extendable):
+        conf = drive_config(device=device, format=format)
+        drive = Drive({}, self.log, **conf)
+        drive._blockDev = blockDev
+        self.assertEqual(drive.extendable, extendable)
+
+
 def drive_config(**kw):
     """ Reutrn drive configuration updated from **kw """
     conf = {
diff --git a/vdsm/virt/vm.py b/vdsm/virt/vm.py
index c85b803..6c78238 100644
--- a/vdsm/virt/vm.py
+++ b/vdsm/virt/vm.py
@@ -1407,7 +1407,7 @@
         # once libvirt starts reporting watermark information for all volumes.
         mergeCandidates = {}
         for drive in self._devices[hwclass.DISK]:
-            if not drive.blockDev or drive.format != 'cow':
+            if not drive.extendable:
                 continue
 
             capacity, alloc, physical = self._dom.blockInfo(drive.path, 0)
diff --git a/vdsm/virt/vmdevices/storage.py b/vdsm/virt/vmdevices/storage.py
index 39c4a65..acc89ca 100644
--- a/vdsm/virt/vmdevices/storage.py
+++ b/vdsm/virt/vmdevices/storage.py
@@ -144,6 +144,17 @@
         return min(nextSize, self.truesize)
 
     @property
+    def extendable(self):
+        """
+        Return True if drive supports extending.
+
+        If a drive is extendable, current drive write watermark and
+        Drive.volExtensionChunk is used to detect if a drive should be
+        extended, and getNextVolumeSize to find the new size.
+        """
+        return self.blockDev and self.format == "cow"
+
+    @property
     def networkDev(self):
         try:
             return self.volumeInfo['volType'] == "network"


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

Gerrit-MessageType: newchange
Gerrit-Change-Id: Iedbb9ea5e708cc606def799a78f7089bc80f77c9
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