Updated Branches: refs/heads/4.3 3744deab1 -> 2794a9398
CLOUDSTACK-5172. Detaching VM volume is not allowed if there are VM snapshots because any changes to the disk layout will break the semantics of VM-based snapshot Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/2794a939 Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/2794a939 Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/2794a939 Branch: refs/heads/4.3 Commit: 2794a9398f4dd224ce34e49a2318d1b92b234915 Parents: 3744dea Author: Likitha Shetty <[email protected]> Authored: Mon Dec 2 15:42:25 2013 +0530 Committer: Likitha Shetty <[email protected]> Committed: Wed Dec 4 20:17:58 2013 +0530 ---------------------------------------------------------------------- server/src/com/cloud/storage/VolumeApiServiceImpl.java | 6 ++++++ 1 file changed, 6 insertions(+) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/cloudstack/blob/2794a939/server/src/com/cloud/storage/VolumeApiServiceImpl.java ---------------------------------------------------------------------- diff --git a/server/src/com/cloud/storage/VolumeApiServiceImpl.java b/server/src/com/cloud/storage/VolumeApiServiceImpl.java index c830e3d..7630567 100644 --- a/server/src/com/cloud/storage/VolumeApiServiceImpl.java +++ b/server/src/com/cloud/storage/VolumeApiServiceImpl.java @@ -1219,6 +1219,12 @@ public class VolumeApiServiceImpl extends ManagerBase implements VolumeApiServic throw new InvalidParameterValueException("Please specify a VM that is either running or stopped."); } + // Don't allow detach if target VM has associated VM snapshots + List<VMSnapshotVO> vmSnapshots = _vmSnapshotDao.findByVm(vmId); + if (vmSnapshots.size() > 0) { + throw new InvalidParameterValueException("Unable to detach volume, please specify a VM that does not have VM snapshots"); + } + AsyncJobExecutionContext asyncExecutionContext = AsyncJobExecutionContext.getCurrentExecutionContext(); if (asyncExecutionContext != null) { AsyncJob job = asyncExecutionContext.getJob();
