cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From alena1...@apache.org
Subject git commit: updated refs/heads/master to 96a17cc
Date Wed, 21 Aug 2013 23:41:58 GMT
Updated Branches:
  refs/heads/master 94849e274 -> 96a17cc03


CLOUDSTACK-4428: "kvm.snapshot.enabled" flag shouldn't affect detached volumes, or volumes
attached to the vm in Stopped/Destroyed state


Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/96a17cc0
Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/96a17cc0
Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/96a17cc0

Branch: refs/heads/master
Commit: 96a17cc036027a6f5709d35b9991b8d26a1bb09c
Parents: 94849e2
Author: Alena Prokharchyk <alena.prokharchyk@citrix.com>
Authored: Wed Aug 21 16:11:11 2013 -0700
Committer: Alena Prokharchyk <alena.prokharchyk@citrix.com>
Committed: Wed Aug 21 16:27:16 2013 -0700

----------------------------------------------------------------------
 .../storage/snapshot/SnapshotManagerImpl.java   | 24 ++++++++++++++------
 1 file changed, 17 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/96a17cc0/server/src/com/cloud/storage/snapshot/SnapshotManagerImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/storage/snapshot/SnapshotManagerImpl.java b/server/src/com/cloud/storage/snapshot/SnapshotManagerImpl.java
index e02ad12..a884b95 100755
--- a/server/src/com/cloud/storage/snapshot/SnapshotManagerImpl.java
+++ b/server/src/com/cloud/storage/snapshot/SnapshotManagerImpl.java
@@ -126,6 +126,7 @@ import com.cloud.utils.db.SearchCriteria;
 import com.cloud.utils.exception.CloudRuntimeException;
 import com.cloud.vm.UserVmVO;
 import com.cloud.vm.VMInstanceVO;
+import com.cloud.vm.VirtualMachine;
 import com.cloud.vm.VirtualMachine.State;
 import com.cloud.vm.dao.UserVmDao;
 import com.cloud.vm.snapshot.VMSnapshot;
@@ -905,16 +906,25 @@ public class SnapshotManagerImpl extends ManagerBase implements SnapshotManager,
 
 
 
-    private boolean hostSupportSnapsthot(HostVO host) {
+    private boolean hostSupportSnapsthotForVolume(HostVO host, VolumeInfo volume) {
 		if (host.getHypervisorType() != HypervisorType.KVM) {
 			return true;
 		}
 
-        //Turn off snapshot by default for KVM, unless it is set in the global flag
-        boolean snapshotEnabled = Boolean.parseBoolean(_configDao.getValue("kvm.snapshot.enabled"));
-        if (!snapshotEnabled) {
-             return false;
-        }
+        //Turn off snapshot by default for KVM if the volume attached to vm that is not in
the Stopped/Destroyed state,
+		//unless it is set in the global flag
+		Long vmId = volume.getInstanceId();
+		if (vmId != null) {
+		    VMInstanceVO vm = _vmDao.findById(vmId);
+		    if (vm.getState() != VirtualMachine.State.Stopped && vm.getState() != VirtualMachine.State.Destroyed)
{
+		        boolean snapshotEnabled = Boolean.parseBoolean(_configDao.getValue("kvm.snapshot.enabled"));
+	            if (!snapshotEnabled) {
+	                 s_logger.debug("Snapshot is not supported on host " + host + " for the
volume " + volume + " attached to the vm " + vm);
+	                 return false;
+	            }
+		    }
+		}
+        
 		// Determine host capabilities
 		String caps = host.getCapabilities();
 
@@ -953,7 +963,7 @@ public class SnapshotManagerImpl extends ManagerBase implements SnapshotManager,
             }
             if (hosts != null && !hosts.isEmpty()) {
                 HostVO host = hosts.get(0);
-                if (!hostSupportSnapsthot(host)) {
+                if (!hostSupportSnapsthotForVolume(host, volume)) {
                     throw new CloudRuntimeException("KVM Snapshot is not supported: " + host.getId());
                 }
             }


Mime
View raw message