do not need to hold a vm lock when taking snapshot

This commit is contained in:
Edison Su 2012-01-16 10:37:44 -08:00
parent aa2433cc14
commit 312df2ffac
1 changed files with 2 additions and 11 deletions

View File

@ -349,16 +349,7 @@ public class SnapshotManagerImpl implements SnapshotManager, SnapshotService, Ma
// does the caller have the authority to act on this volume
_accountMgr.checkAccess(UserContext.current().getCaller(), null, v);
try {
if (v != null && _volsDao.getHypervisorType(v.getId()).equals(HypervisorType.KVM)) {
/* KVM needs to lock on the vm of volume, because it takes snapshot on behalf of vm, not volume */
UserVmVO uservm = _vmDao.findById(v.getInstanceId());
if (uservm != null) {
UserVmVO vm = _vmDao.acquireInLockTable(uservm.getId(), 10);
if (vm == null) {
throw new CloudRuntimeException("Creating snapshot failed due to volume:" + volumeId + " is being used, try it later ");
}
}
}
Long poolId = v.getPoolId();
if (poolId == null) {
throw new CloudRuntimeException("You cannot take a snapshot of a volume until it has been attached to an instance");
@ -387,7 +378,7 @@ public class SnapshotManagerImpl implements SnapshotManager, SnapshotService, Ma
+ userVm.getState().toString() + " state");
}
if(userVm.getHypervisorType() == HypervisorType.VMware) {
if(userVm.getHypervisorType() == HypervisorType.VMware || userVm.getHypervisorType() == HypervisorType.KVM) {
List<SnapshotVO> activeSnapshots = _snapshotDao.listByInstanceId(v.getInstanceId(), Snapshot.Status.Creating, Snapshot.Status.CreatedOnPrimary, Snapshot.Status.BackingUp);
if(activeSnapshots.size() > 1)
throw new CloudRuntimeException("There is other active snapshot tasks on the instance to which the volume is attached, please try again later");