Change in vdsm[ovirt-3.5]: virt: Resolve snapshot type after prepareVolumePath
alitke at redhat.com
alitke at redhat.com
Tue Sep 2 17:20:44 UTC 2014
Hello Federico Simoncelli, Francesco Romani,
I'd like you to do a code review. Please visit
http://gerrit.ovirt.org/32327
to review the following change.
Change subject: virt: Resolve snapshot type after prepareVolumePath
......................................................................
virt: Resolve snapshot type after prepareVolumePath
The Drive.blockDev property depends on the presence of the volume path
locally. Therefore, it is not safe to call until after the new snapshot
volume path has been prepared. Use a lambda function to delay the call
until the information is needed.
Change-Id: Ia4726702eb329bf65f1f9c658067f7a01c2179e4
Signed-off-by: Adam Litke <alitke at redhat.com>
Reviewed-on: http://gerrit.ovirt.org/32066
Reviewed-by: Francesco Romani <fromani at redhat.com>
Reviewed-by: Federico Simoncelli <fsimonce at redhat.com>
---
M vdsm/virt/vm.py
1 file changed, 7 insertions(+), 3 deletions(-)
git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/27/32327/1
diff --git a/vdsm/virt/vm.py b/vdsm/virt/vm.py
index 94a6b76..9e4437a 100644
--- a/vdsm/virt/vm.py
+++ b/vdsm/virt/vm.py
@@ -4221,7 +4221,7 @@
snap = xml.dom.minidom.Element('domainsnapshot')
disks = xml.dom.minidom.Element('disks')
newDrives = {}
- snapTypes = {}
+ vmDrives = {}
if self.isMigrating():
return errCode['migInProgress']
@@ -4261,7 +4261,10 @@
newDrives[vmDevName]["poolID"] = vmDrive.poolID
newDrives[vmDevName]["name"] = vmDevName
newDrives[vmDevName]["format"] = "cow"
- snapTypes[vmDevName] = ('file', 'block')[vmDrive.blockDev]
+
+ # We need to keep track of the drive object because we cannot
+ # safely access the blockDev property until after prepareVolumePath
+ vmDrives[vmDevName] = vmDrive
# If all the drives are the current ones, return success
if len(newDrives) == 0:
@@ -4284,8 +4287,9 @@
_rollbackDrives(preparedDrives)
return errCode['snapshotErr']
+ snapType = 'block' if vmDrives[vmDevName].blockDev else 'file'
snapelem = _diskSnapshot(vmDevName, newDrives[vmDevName]["path"],
- snapTypes[vmDevName])
+ snapType)
disks.appendChild(snapelem)
snap.appendChild(disks)
--
To view, visit http://gerrit.ovirt.org/32327
To unsubscribe, visit http://gerrit.ovirt.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: Ia4726702eb329bf65f1f9c658067f7a01c2179e4
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: ovirt-3.5
Gerrit-Owner: Adam Litke <alitke at redhat.com>
Gerrit-Reviewer: Federico Simoncelli <fsimonce at redhat.com>
Gerrit-Reviewer: Francesco Romani <fromani at redhat.com>
More information about the vdsm-patches
mailing list