diff --git a/server/src/com/cloud/storage/snapshot/SnapshotManagerImpl.java b/server/src/com/cloud/storage/snapshot/SnapshotManagerImpl.java index d24d5df9e20..8773ae8ba1d 100755 --- a/server/src/com/cloud/storage/snapshot/SnapshotManagerImpl.java +++ b/server/src/com/cloud/storage/snapshot/SnapshotManagerImpl.java @@ -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 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");