Return-Path: X-Original-To: apmail-cloudstack-commits-archive@www.apache.org Delivered-To: apmail-cloudstack-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 406971094D for ; Wed, 21 Aug 2013 23:41:59 +0000 (UTC) Received: (qmail 73764 invoked by uid 500); 21 Aug 2013 23:41:59 -0000 Delivered-To: apmail-cloudstack-commits-archive@cloudstack.apache.org Received: (qmail 73746 invoked by uid 500); 21 Aug 2013 23:41:59 -0000 Mailing-List: contact commits-help@cloudstack.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@cloudstack.apache.org Delivered-To: mailing list commits@cloudstack.apache.org Received: (qmail 73737 invoked by uid 99); 21 Aug 2013 23:41:59 -0000 Received: from tyr.zones.apache.org (HELO tyr.zones.apache.org) (140.211.11.114) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 21 Aug 2013 23:41:59 +0000 Received: by tyr.zones.apache.org (Postfix, from userid 65534) id DCF3D8C22F6; Wed, 21 Aug 2013 23:41:58 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: alena1108@apache.org To: commits@cloudstack.apache.org Message-Id: X-Mailer: ASF-Git Admin Mailer Subject: git commit: updated refs/heads/master to 96a17cc Date: Wed, 21 Aug 2013 23:41:58 +0000 (UTC) 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 Authored: Wed Aug 21 16:11:11 2013 -0700 Committer: Alena Prokharchyk 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()); } }