Deepak C Shetty has uploaded a new change for review. Change subject: Add support for transient disk ......................................................................
Add support for transient disk Add support for transient disk Change-Id: I3dfec35e324c47d8c86a965947e3ae4ae48c7524 Signed-off-by: Deepak C Shetty <[email protected]> --- M vdsm/clientIF.py M vdsm/storage/hsm.py M vdsm/storage/volume.py M vdsm/vm.py 4 files changed, 75 insertions(+), 7 deletions(-) git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/26/18326/1 diff --git a/vdsm/clientIF.py b/vdsm/clientIF.py index c8b0ad3..5e90352 100644 --- a/vdsm/clientIF.py +++ b/vdsm/clientIF.py @@ -305,6 +305,7 @@ volPath = res['path'] drive['volumeChain'] = res['chain'] drive['volumeInfo'] = res['info'] + drive['transient'] = res['transient'] # GUID drive format elif "GUID" in drive: @@ -375,8 +376,12 @@ def teardownVolumePath(self, drive): res = {'status': doneCode} try: - res = self.irs.teardownImage(drive['domainID'], - drive['poolID'], drive['imageID']) + volID = drive['volumeID'] + except KeyError: + volID = None + try: + res = self.irs.teardownImage(drive['domainID'], drive['poolID'], + drive['imageID'], volID) except (KeyError, TypeError): # paths (strings) are not deactivated if not isinstance(drive, basestring): diff --git a/vdsm/storage/hsm.py b/vdsm/storage/hsm.py index c754ee8..35315f6 100644 --- a/vdsm/storage/hsm.py +++ b/vdsm/storage/hsm.py @@ -3233,7 +3233,8 @@ for vol in imgVolumes: volInfo = {'domainID': sdUUID, 'imageID': imgUUID, 'volumeID': vol.volUUID, 'path': vol.getVolumePath(), - 'vmVolInfo': vol.getVmVolumeInfo()} + 'vmVolInfo': vol.getVmVolumeInfo(), + 'transient': vol.isInternal()} if config.getboolean('irs', 'use_volume_leases'): leasePath, leaseOffset = dom.getVolumeLease(vol.imgUUID, @@ -3249,8 +3250,17 @@ chain.append(volInfo) + # If the volume is transient, create temp. volume + if chain[-1]['transient']: + tmpPath = imgVolumes[-1].createTransientVolume() + chain[-1]['path'] = tmpPath + + # Addnl volume info doesn't apply for transient volumes + chain[-1]['vmVolInfo'] = {} + oop.getProcessPool(sdUUID).os.chmod(tmpPath, 0660) + return {'path': chain[-1]['path'], 'info': chain[-1]['vmVolInfo'], - 'chain': chain} + 'transient': chain[-1]['transient'], 'chain': chain} @public def teardownImage(self, sdUUID, spUUID, imgUUID, volUUID=None): @@ -3269,6 +3279,11 @@ dom = sdCache.produce(sdUUID) dom.deactivateImage(imgUUID) + # Get image chain and remove transient volumes, if any + img = image.Image(os.path.join(self.storage_repository, spUUID)) + volChain = img.getChain(sdUUID, imgUUID, volUUID) + volChain[-1].removeTransientVolume() + @public def getVolumesList(self, sdUUID, spUUID, imgUUID=volume.BLANK_UUID, options=None): diff --git a/vdsm/storage/volume.py b/vdsm/storage/volume.py index 10b3363..cf2ce15 100644 --- a/vdsm/storage/volume.py +++ b/vdsm/storage/volume.py @@ -946,6 +946,26 @@ raise se.VolumeAccessError(self.volUUID) return self.volumePath + def _getTransientVolPath(self): + return os.path.join(constants.P_VDSM_RUN, + os.path.basename(self.getVolumePath())) + + def createTransientVolume(self): + parent = self.getVolumePath() + trPath = self._getTransientVolPath() + + size = int(self.getMetaParam(SIZE)) + parent_format = fmt2str(self.getFormat()) + createVolume(parent, parent_format, trPath, + size, COW_FORMAT, SPARSE_VOL, useRelPath=False) + + return trPath + + def removeTransientVolume(self): + fname = self._getTransientVolPath() + if os.path.exists(fname): + os.unlink(fname) + def getVmVolumeInfo(self): """ Get volume path/info as dict. @@ -1006,7 +1026,8 @@ pass -def createVolume(parent, parent_format, volume, size, format, prealloc): +def createVolume(parent, parent_format, volume, size, format, prealloc, + useRelPath=True): """ --- Create new volume. 'parent' - backing volume name @@ -1044,8 +1065,13 @@ # cmd += ["-b", parent, volume] # cwd = os.path.split(os.path.split(volume)[0])[0] - # Temporary fix for qemu-img creation problem - cmd += ["-F", parent_format, "-b", os.path.join("..", parent), volume] + if useRelPath: + # Temporary fix for qemu-img creation problem + cmd += ["-F", parent_format, "-b", os.path.join("..", parent), + volume] + else: + cmd += ["-F", parent_format, "-b", parent, volume] + cwd = os.path.split(volume)[0] else: size = int(size) diff --git a/vdsm/vm.py b/vdsm/vm.py index dc52909..99354a9 100644 --- a/vdsm/vm.py +++ b/vdsm/vm.py @@ -1379,6 +1379,8 @@ @property def networkDev(self): + if self.transientDisk: + return False try: return self.volumeInfo['volType'] == "network" except AttributeError: @@ -1389,6 +1391,8 @@ def blockDev(self): if self.networkDev: return False + if self.transientDisk: + return False if self._blockDev is None: try: @@ -1398,7 +1402,25 @@ "block device", self.path, exc_info=True) return self._blockDev + @property + def transientDisk(self): + try: + return self.transient + except AttributeError: + # To handle legacy and removable drives. + return False + def _customize(self): + if self.transientDisk: + # Force the cache to be writethrough, which is qemu's default. + # This is done to ensure that we don't ever use cache=none for + # transient disks, since we create them in /var/run/vdsm which + # may end up on tmpfs and don't support O_DIRECT, and qemu uses + # O_DIRECT when cache=none and hence hotplug might fail with + # error that one can take eternity to debug the reason behind it! + self.cache = "writethrough" + return + # Customize disk device if self.iface == 'virtio': try: -- To view, visit http://gerrit.ovirt.org/18326 To unsubscribe, visit http://gerrit.ovirt.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I3dfec35e324c47d8c86a965947e3ae4ae48c7524 Gerrit-PatchSet: 1 Gerrit-Project: vdsm Gerrit-Branch: master Gerrit-Owner: Deepak C Shetty <[email protected]> _______________________________________________ vdsm-patches mailing list [email protected] https://lists.fedorahosted.org/mailman/listinfo/vdsm-patches
