Change in vdsm[master]: vm: new parameter 'protected' for vm creation

fsimonce at redhat.com fsimonce at redhat.com
Tue Aug 6 13:39:48 UTC 2013


Federico Simoncelli has uploaded a new change for review.

Change subject: vm: new parameter 'protected' for vm creation
......................................................................

vm: new parameter 'protected' for vm creation

Setting the new parameter 'protected' to true when creating a VM
enables sanlock protection for the VM resources (disks).
As a result few operations on the VM are blocked as they're not
supported yet.

Change-Id: I9429ead45caac1178957a33393642817db59508f
Signed-off-by: Federico Simoncelli <fsimonce at redhat.com>
---
M client/vdsClient.py
M vdsm/storage/hsm.py
M vdsm/vm.py
M vdsm_api/vdsmapi-schema.json
4 files changed, 45 insertions(+), 22 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/14/17714/1

diff --git a/client/vdsClient.py b/client/vdsClient.py
index c52256a..c65531c 100644
--- a/client/vdsClient.py
+++ b/client/vdsClient.py
@@ -1822,7 +1822,9 @@
                     'name:val}]} : add a fully specified device',
                     'o   cpuPinning={vcpuid:pinning} cpu pinning in '
                     'libvirt-like format. see '
-                    'http://libvirt.org/formatdomain.html#elementsCPUTuning'
+                    'http://libvirt.org/formatdomain.html#elementsCPUTuning',
+                    'o   protected=<true/false> whether the vm resources '
+                    '(disks) should be protected using sanlock',
                     )),
         'vmUpdateDevice': (serv.vmUpdateDevice,
                            ('<vmId> <devicespec>',
diff --git a/vdsm/storage/hsm.py b/vdsm/storage/hsm.py
index c754ee8..2112693 100644
--- a/vdsm/storage/hsm.py
+++ b/vdsm/storage/hsm.py
@@ -3235,17 +3235,16 @@
                        'volumeID': vol.volUUID, 'path': vol.getVolumePath(),
                        'vmVolInfo': vol.getVmVolumeInfo()}
 
-            if config.getboolean('irs', 'use_volume_leases'):
-                leasePath, leaseOffset = dom.getVolumeLease(vol.imgUUID,
-                                                            vol.volUUID)
+            leasePath, leaseOffset = \
+                dom.getVolumeLease(vol.imgUUID, vol.volUUID)
 
-                if leasePath and leaseOffset is not None:
-                    volInfo.update({
-                        'leasePath': leasePath,
-                        'leaseOffset': leaseOffset,
-                        'shared': (vol.getVolType() ==
-                                   volume.type2name(volume.SHARED_VOL)),
-                    })
+            if leasePath and leaseOffset is not None:
+                volInfo.update({
+                    'leasePath': leasePath,
+                    'leaseOffset': leaseOffset,
+                    'shared': (vol.getVolType() ==
+                               volume.type2name(volume.SHARED_VOL)),
+                })
 
             chain.append(volInfo)
 
diff --git a/vdsm/vm.py b/vdsm/vm.py
index dc52909..1b86eb7 100644
--- a/vdsm/vm.py
+++ b/vdsm/vm.py
@@ -2073,6 +2073,9 @@
     def isDisksStatsCollectionEnabled(self):
         return self._volumesPrepared
 
+    def isProtected(self):
+        return utils.tobool(self.conf.get('protected', 'false'))
+
     def preparePaths(self, drives):
         domains = set()
         for drive in drives:
@@ -2685,21 +2688,19 @@
 
         self._appendDevices(domxml)
 
-        for drive in self._devices[DISK_DEVICES][:]:
-            if not hasattr(drive, 'volumeChain'):
-                continue
+        if (config.getboolean('irs', 'use_volume_leases')
+                or self.isProtected()):
 
-            for volInfo in drive.volumeChain:
-                if ('leasePath' not in volInfo or
-                        'leaseOffset' not in volInfo or
-                        volInfo['shared']):
+            for drive in self._devices[DISK_DEVICES][:]:
+                if not hasattr(drive, 'volumeChain'):
                     continue
 
-                leaseElem = self._buildLease(
-                    drive.domainID, volInfo['volumeID'], volInfo['leasePath'],
-                    volInfo['leaseOffset'])
+                for volInfo in drive.volumeChain:
+                    leaseElem = self._buildLease(
+                        drive.domainID, volInfo['volumeID'],
+                        volInfo['leasePath'], volInfo['leaseOffset'])
 
-                domxml._devices.appendChild(leaseElem)
+                    domxml._devices.appendChild(leaseElem)
 
         return domxml.toxml()
 
@@ -3224,6 +3225,9 @@
         return {'status': doneCode, 'vmList': self.status()}
 
     def hotplugDisk(self, params):
+        if self.isProtected():
+            return errCode['noimpl']
+
         if self.isMigrating():
             return errCode['migInProgress']
 
@@ -3271,6 +3275,9 @@
         return {'status': doneCode, 'vmList': self.status()}
 
     def hotunplugDisk(self, params):
+        if self.isProtected():
+            return errCode['noimpl']
+
         if self.isMigrating():
             return errCode['migInProgress']
 
@@ -3551,6 +3558,9 @@
         disks = xml.dom.minidom.Element('disks')
         newDrives = {}
 
+        if self.isProtected():
+            return errCode['noimpl']
+
         if self.isMigrating():
             return errCode['migInProgress']
 
@@ -3726,6 +3736,9 @@
     def merge(self, mergeDrives):
         """Live merge command"""
 
+        if self.isProtected():
+            return errCode['noimpl']
+
         # Check if there is a merge still in progress
         for mergeStatus in self.conf.get('liveMerge', []):
             if mergeStatus['status'] == MERGESTATUS.IN_PROGRESS:
@@ -3834,6 +3847,9 @@
         del srcDrive.diskReplicate
 
     def diskReplicateStart(self, srcDisk, dstDisk):
+        if self.isProtected():
+            return errCode['noimpl']
+
         try:
             srcDrive = self._findDriveByUUIDs(srcDisk)
         except LookupError:
@@ -3882,6 +3898,9 @@
         return {'status': doneCode}
 
     def diskReplicateFinish(self, srcDisk, dstDisk):
+        if self.isProtected():
+            return errCode['noimpl']
+
         try:
             srcDrive = self._findDriveByUUIDs(srcDisk)
         except LookupError:
diff --git a/vdsm_api/vdsmapi-schema.json b/vdsm_api/vdsmapi-schema.json
index 4495dc5..8a9d325 100644
--- a/vdsm_api/vdsmapi-schema.json
+++ b/vdsm_api/vdsmapi-schema.json
@@ -2717,6 +2717,9 @@
 #
 # @nice:                  The host scheduling priority
 #
+# @protected:             Whether the VM resources must be protected using
+#                         sanlock or not
+#
 # @smp:                   The number of CPUs presented to the VM
 #
 # @smpCoresPerSocket:     #optional Indicates the number of CPU cores per socket


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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I9429ead45caac1178957a33393642817db59508f
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Federico Simoncelli <fsimonce at redhat.com>


More information about the vdsm-patches mailing list