Change in vdsm[master]: Adding VM based locks to ovf modify functions.
ewarszaw at redhat.com
ewarszaw at redhat.com
Sun Nov 25 22:30:54 UTC 2012
Eduardo has uploaded a new change for review.
Change subject: Adding VM based locks to ovf modify functions.
......................................................................
Adding VM based locks to ovf modify functions.
Caveat Emptor:
Avoids concurrent runs, but not serializes.
Simultaneous updates or removes of ovf files (like removing many
disks from the same VM) may result in inconsistent ovf's.
Bug-url: https://bugzilla.redhat.com/show_bug.cgi?id=878894
Change-Id: I57d9f87a34e1d5659115b09530493824fcda94de
Signed-off-by: Eduardo <ewarszaw at redhat.com>
---
M vdsm/storage/hsm.py
M vdsm/storage/sp.py
2 files changed, 18 insertions(+), 17 deletions(-)
git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/56/9456/1
diff --git a/vdsm/storage/hsm.py b/vdsm/storage/hsm.py
index 05d11c2..7e321de 100644
--- a/vdsm/storage/hsm.py
+++ b/vdsm/storage/hsm.py
@@ -1215,13 +1215,19 @@
:type sdUUID: UUID
:param options: ?
"""
- #getSharedLock(spUUID...)
vars.task.getSharedLock(STORAGE, spUUID)
- #getExclusiveLock(vmList...)
+
pool = self.getPool(spUUID)
if sdUUID and sdUUID != sd.BLANK_UUID:
pool.validatePoolSD(sdUUID)
self.validateSdUUID(sdUUID)
+ else:
+ sdUUID = pool.masterDomain.sdUUID
+
+ vmUUIDs = [vmDesc['vm'] for vmDesc in vmList]
+ vmUUIDs.sort()
+ for vmUUID in vmUUIDs:
+ vars.task.getExclusiveLock(STORAGE, "%s_%s" % (vmUUID, sdUUID))
pool.updateVM(vmList=vmList, sdUUID=sdUUID)
@public
@@ -1240,11 +1246,13 @@
:param options: ?
"""
vars.task.getSharedLock(STORAGE, spUUID)
- #getExclusiveLock(vmList...)
pool = self.getPool(spUUID)
if sdUUID and sdUUID != sd.BLANK_UUID:
pool.validatePoolSD(sdUUID)
self.validateSdUUID(sdUUID)
+ else:
+ pool.masterDomain.sdUUID
+ vars.task.getExclusiveLock(STORAGE, "%s_%s" % (vmUUID, sdUUID))
pool.removeVM(vmUUID=vmUUID, sdUUID=sdUUID)
@public
diff --git a/vdsm/storage/sp.py b/vdsm/storage/sp.py
index 21ac4bf..816d4c3 100644
--- a/vdsm/storage/sp.py
+++ b/vdsm/storage/sp.py
@@ -1253,7 +1253,7 @@
self.__rebuild(msdUUID=msdUUID, masterVersion=masterVersion)
- def updateVM(self, vmList, sdUUID=None):
+ def updateVM(self, vmList, sdUUID):
"""
Update VMs.
'vmList' - [{'vm':vmUUID,'ovf','imglist':'imgUUID1,imgUUID2,...'},...]
@@ -1262,9 +1262,6 @@
If sdUUID is None, the update is on the pool, and therefore the
master domain will be updated.
"""
- if sdUUID is None:
- sdUUID = self.masterDomain.sdUUID
-
self.log.info("spUUID=%s sdUUID=%s", self.spUUID, sdUUID)
vms = self._getVMsPath(sdUUID)
# We should exclude 'masterd' link from IMG_METAPATTERN globing
@@ -1288,7 +1285,7 @@
raise se.MiscDirCleanupFailure(str(e))
try:
- os.mkdir(vmPath)
+ fileUtils.createdir(vmPath)
codecs.open(os.path.join(vmPath, vmUUID + '.ovf'), 'w',
encoding='utf8').write(ovf)
except OSError, ex:
@@ -1298,7 +1295,7 @@
raise
- def removeVM(self, vmUUID, sdUUID=None):
+ def removeVM(self, vmUUID, sdUUID):
"""
Remove VM.
'vmUUID' - Virtual machine UUID
@@ -1635,16 +1632,12 @@
@unsecured
def _getVMsPath(self, sdUUID):
"""
- Return general path of VMs from the pool.
- If 'sdUUID' is given then return VMs dir within it.
+ Return VMs dir within SD with sdUUID.
"""
- if sdUUID and sdUUID != sd.BLANK_UUID:
- if not self.isActive(sdUUID):
- raise se.StorageDomainNotActive(sdUUID)
- vmPath = sdCache.produce(sdUUID).getVMsDir()
+ if not self.isActive(sdUUID):
+ raise se.StorageDomainNotActive(sdUUID)
+ vmPath = sdCache.produce(sdUUID).getVMsDir()
# Get VMs path from the pool (from the master domain)
- else:
- vmPath = self.masterDomain.getVMsDir()
if not os.path.exists(vmPath):
raise se.VMPathNotExists(vmPath)
--
To view, visit http://gerrit.ovirt.org/9456
To unsubscribe, visit http://gerrit.ovirt.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I57d9f87a34e1d5659115b09530493824fcda94de
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Eduardo <ewarszaw at redhat.com>
More information about the vdsm-patches
mailing list