Federico Simoncelli has uploaded a new change for review.
Change subject: vm: pre-validate disks for snapshot ......................................................................
vm: pre-validate disks for snapshot
This patch divides the snapshot disks validation from the path preparation in order to limit the rollback scenarios.
Change-Id: I4fb507c2f7268bb688af5fd187dcd033d0a068a2 Signed-off-by: Federico Simoncelli fsimonce@redhat.com --- M vdsm/vm.py 1 file changed, 15 insertions(+), 13 deletions(-)
git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/29/20029/1
diff --git a/vdsm/vm.py b/vdsm/vm.py index c85dc10..7945d5d 100644 --- a/vdsm/vm.py +++ b/vdsm/vm.py @@ -3618,11 +3618,11 @@ vmDrive = self._findDriveByUUIDs(baseDrv) except LookupError: # The volume we want to snapshot doesn't exist - _rollbackDrives(newDrives) self.log.error("The base volume doesn't exist: %s", baseDrv) return errCode['snapshotErr']
if vmDrive.hasVolumeLeases: + self.log.error("Disk %s has volume leases", vmDrive.name) return errCode['noimpl']
vmDevName = vmDrive.name @@ -3632,23 +3632,25 @@ newDrives[vmDevName]["name"] = vmDevName newDrives[vmDevName]["format"] = "cow"
- try: - newDrives[vmDevName]["path"] = \ - self.cif.prepareVolumePath(newDrives[vmDevName]) - except Exception: - _rollbackDrives(newDrives) - self.log.error("Unable to prepare the volume path " - "for the disk: %s", vmDevName, exc_info=True) - return errCode['snapshotErr'] - - snapelem = _diskSnapshot(vmDevName, newDrives[vmDevName]["path"]) - disks.appendChild(snapelem) - # If all the drives are the current ones, return success if len(newDrives) == 0: self.log.debug("All the drives are already in use, success") return {'status': doneCode}
+ for vmDevName in newDrives.keys(): + try: + newDrives[vmDevName]["path"] = \ + self.cif.prepareVolumePath(newDrives[vmDevName]) + except Exception: + self.log.error("Unable to prepare the volume path " + "for the disk: %s", vmDevName, exc_info=True) + # Trying to rollback (teardown) all drives + _rollbackDrives(newDrives) + return errCode['snapshotErr'] + + snapelem = _diskSnapshot(vmDevName, newDrives[vmDevName]["path"]) + disks.appendChild(snapelem) + snap.appendChild(disks)
snapFlags = (libvirt.VIR_DOMAIN_SNAPSHOT_CREATE_REUSE_EXT |