Updated Branches:
  refs/heads/master dfff362c1 -> f37057a21

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/f37057a2
Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/f37057a2
Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/f37057a2

Branch: refs/heads/master
Commit: f37057a215c886369924c81352449bf4f5a27d2c
Parents: dfff362
Author: Likitha Shetty <[email protected]>
Authored: Mon Dec 2 15:42:25 2013 +0530
Committer: Likitha Shetty <[email protected]>
Committed: Wed Dec 4 20:19:17 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/f37057a2/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 e60d204..fdd5db5 100644
--- a/server/src/com/cloud/storage/VolumeApiServiceImpl.java
+++ b/server/src/com/cloud/storage/VolumeApiServiceImpl.java
@@ -1236,6 +1236,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();

Reply via email to