Change in vdsm[master]: vm: Support LSM in mixed storage domains

nsoffer at redhat.com nsoffer at redhat.com
Mon Jan 19 16:59:46 UTC 2015


Nir Soffer has uploaded a new change for review.

Change subject: vm: Support LSM in mixed storage domains
......................................................................

vm: Support LSM in mixed storage domains

Experimental patch for supporting LSM between mixed storage domains.

Change-Id: I94585d9a963b2734f76f6a82f8fbb4609665224c
Signed-off-by: Nir Soffer <nsoffer at redhat.com>
---
M vdsm/virt/vm.py
M vdsm/virt/vmdevices/storage.py
2 files changed, 35 insertions(+), 12 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/95/37095/1

diff --git a/vdsm/virt/vm.py b/vdsm/virt/vm.py
index bee1098..c341855 100644
--- a/vdsm/virt/vm.py
+++ b/vdsm/virt/vm.py
@@ -1409,9 +1409,11 @@
         # 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.supportsExtension():
                 continue
 
+            # TODO: Does this work for file based drives? If not, we need to
+            # check replicate path (one of them must be block based).
             capacity, alloc, physical = self._dom.blockInfo(drive.path, 0)
             ret.append((drive, drive.volumeID, capacity, alloc, physical))
 
@@ -1476,12 +1478,15 @@
         return len(extend) > 0
 
     def extendDriveVolume(self, vmDrive, volumeID, curSize):
-        if not vmDrive.blockDev:
+        if not vmDrive.supportsExtension()
             return
 
         newSize = vmDrive.getNextVolumeSize(curSize)  # newSize is in megabytes
 
-        if getattr(vmDrive, 'diskReplicate', None):
+        # TODO: Works but ugly
+        if getattr(vmDrive, 'diskReplicate', {})["blockDev"]:
+            # The replicate is a block device. We will handle the drive itself
+            # in __afterReplictionExtension.
             volInfo = {'poolID': vmDrive.diskReplicate['poolID'],
                        'domainID': vmDrive.diskReplicate['domainID'],
                        'imageID': vmDrive.diskReplicate['imageID'],
@@ -1493,6 +1498,7 @@
                                        newSize * constants.MEGAB,
                                        self.__afterReplicaExtension)
         else:
+            # This drive is a block device
             self.__extendDriveVolume(vmDrive, volumeID, newSize)
 
     def __refreshDriveVolume(self, volInfo):
@@ -1534,6 +1540,8 @@
     def __afterReplicaExtension(self, volInfo):
         self.__verifyVolumeExtension(volInfo)
         vmDrive = self._findDriveByName(volInfo['name'])
+        if not vmDrive.blockDev:
+            return
         self.log.debug("Requesting extension for the original drive: %s "
                        "(domainID: %s, volumeID: %s)",
                        vmDrive.name, vmDrive.domainID, vmDrive.volumeID)
@@ -3444,13 +3452,6 @@
         if srcDrive.transientDisk:
             return errCode['transientErr']
 
-        try:
-            self._setDiskReplica(srcDrive, dstDisk)
-        except Exception:
-            self.log.error("Unable to set the replication for disk '%s' with "
-                           "destination '%s'", srcDrive.name, dstDisk)
-            return errCode['replicaErr']
-
         dstDiskCopy = dstDisk.copy()
 
         # The device entry is enforced because stricly required by
@@ -3459,6 +3460,19 @@
 
         try:
             dstDiskCopy['path'] = self.cif.prepareVolumePath(dstDiskCopy)
+        except Exception:
+            self.log.exception("Error preparing destination volume")
+            return errCode['replicaErr']
+
+        try:
+            dstDisk["blockDev"] = utils.isBlockDevice(dstDiskCopy["path"])
+
+            try:
+                self._setDiskReplica(srcDrive, dstDisk)
+            except Exception:
+                self.log.error("Unable to set the replication for disk '%s' with "
+                               "destination '%s'", srcDrive.name, dstDisk)
+                raise
 
             try:
                 self._dom.blockRebase(srcDrive.name, dstDiskCopy['path'], 0, (
@@ -3470,11 +3484,12 @@
                 self.log.exception("Unable to start the replication"
                                    " for %s to %s",
                                    srcDrive.name, dstDiskCopy)
-                self.cif.teardownVolumePath(dstDiskCopy)
+                self._delDiskReplica(srcDrive)
                 raise
+
         except Exception:
             self.log.exception("Cannot complete the disk replication process")
-            self._delDiskReplica(srcDrive)
+            self.cif.teardownVolumePath(dstDiskCopy)
             return errCode['replicaErr']
 
         try:
diff --git a/vdsm/virt/vmdevices/storage.py b/vdsm/virt/vmdevices/storage.py
index 780ffc1..93f858d 100644
--- a/vdsm/virt/vmdevices/storage.py
+++ b/vdsm/virt/vmdevices/storage.py
@@ -134,6 +134,14 @@
         return (self.VOLWM_FREE_PCT * self.volExtensionChunk *
                 constants.MEGAB / 100)
 
+    def supportsExtension(self):
+        """
+        Return True if this disk or its replica support extension.
+        """
+        if self.format != "cow":
+            return False
+        return self.blockDev or getattr(self, "diskReplicate", {})["blockDev"]
+
     def getNextVolumeSize(self, curSize):
         """
         Returns the next volume size in megabytes. This value is based on the


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

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