diff --git a/core/src/com/cloud/agent/api/VMSnapshotTO.java b/core/src/com/cloud/agent/api/VMSnapshotTO.java index 473c39a595d..9bc8712f3aa 100644 --- a/core/src/com/cloud/agent/api/VMSnapshotTO.java +++ b/core/src/com/cloud/agent/api/VMSnapshotTO.java @@ -31,6 +31,7 @@ public class VMSnapshotTO { private String description; private VMSnapshotTO parent; private List volumes; + private boolean quiescevm; public Long getId() { return id; @@ -40,7 +41,8 @@ public class VMSnapshotTO { } public VMSnapshotTO(Long id, String snapshotName, VMSnapshot.Type type, Long createTime, - String description, Boolean current, VMSnapshotTO parent) { + String description, Boolean current, VMSnapshotTO parent, + boolean quiescevm) { super(); this.id = id; this.snapshotName = snapshotName; @@ -49,9 +51,10 @@ public class VMSnapshotTO { this.current = current; this.description = description; this.parent = parent; + this.quiescevm = quiescevm; } public VMSnapshotTO() { - + this.quiescevm = true; } public String getDescription() { return description; @@ -99,4 +102,12 @@ public class VMSnapshotTO { public void setVolumes(List volumes) { this.volumes = volumes; } + + public boolean getQuiescevm() { + return this.quiescevm; + } + + public void setQuiescevm(boolean quiescevm) { + this.quiescevm = quiescevm; + } } diff --git a/engine/storage/snapshot/src/org/apache/cloudstack/storage/vmsnapshot/DefaultVMSnapshotStrategy.java b/engine/storage/snapshot/src/org/apache/cloudstack/storage/vmsnapshot/DefaultVMSnapshotStrategy.java index be3cce94da9..3f5e4f78d64 100644 --- a/engine/storage/snapshot/src/org/apache/cloudstack/storage/vmsnapshot/DefaultVMSnapshotStrategy.java +++ b/engine/storage/snapshot/src/org/apache/cloudstack/storage/vmsnapshot/DefaultVMSnapshotStrategy.java @@ -25,6 +25,7 @@ import javax.inject.Inject; import javax.naming.ConfigurationException; import org.apache.cloudstack.engine.subsystem.api.storage.StrategyPriority; +import org.apache.cloudstack.engine.subsystem.api.storage.VMSnapshotOptions; import org.apache.cloudstack.engine.subsystem.api.storage.VMSnapshotStrategy; import org.apache.cloudstack.framework.config.dao.ConfigurationDao; import org.apache.cloudstack.storage.to.VolumeObjectTO; @@ -111,8 +112,12 @@ public class DefaultVMSnapshotStrategy extends ManagerBase implements VMSnapshot VMSnapshotVO currentSnapshot = vmSnapshotDao.findCurrentSnapshotByVmId(userVm.getId()); if (currentSnapshot != null) current = vmSnapshotHelper.getSnapshotWithParents(currentSnapshot); + VMSnapshotOptions options = ((VMSnapshotVO) vmSnapshot).getOptions(); + boolean quiescevm = true; + if (options != null) + quiescevm = options.needQuiesceVM(); VMSnapshotTO target = new VMSnapshotTO(vmSnapshot.getId(), vmSnapshot.getName(), vmSnapshot.getType(), null, vmSnapshot.getDescription(), false, - current); + current, quiescevm); if (current == null) vmSnapshotVO.setParent(null); else @@ -174,7 +179,7 @@ public class DefaultVMSnapshotStrategy extends ManagerBase implements VMSnapshot String vmInstanceName = userVm.getInstanceName(); VMSnapshotTO parent = vmSnapshotHelper.getSnapshotWithParents(vmSnapshotVO).getParent(); VMSnapshotTO vmSnapshotTO = new VMSnapshotTO(vmSnapshot.getId(), vmSnapshot.getName(), vmSnapshot.getType(), - vmSnapshot.getCreated().getTime(), vmSnapshot.getDescription(), vmSnapshot.getCurrent(), parent); + vmSnapshot.getCreated().getTime(), vmSnapshot.getDescription(), vmSnapshot.getCurrent(), parent, true); GuestOSVO guestOS = guestOSDao.findById(userVm.getGuestOSId()); DeleteVMSnapshotCommand deleteSnapshotCommand = new DeleteVMSnapshotCommand(vmInstanceName, vmSnapshotTO, volumeTOs,guestOS.getDisplayName()); @@ -330,7 +335,7 @@ public class DefaultVMSnapshotStrategy extends ManagerBase implements VMSnapshot VMSnapshotTO parent = vmSnapshotHelper.getSnapshotWithParents(snapshot).getParent(); VMSnapshotTO vmSnapshotTO = new VMSnapshotTO(snapshot.getId(), snapshot.getName(), snapshot.getType(), - snapshot.getCreated().getTime(), snapshot.getDescription(), snapshot.getCurrent(), parent); + snapshot.getCreated().getTime(), snapshot.getDescription(), snapshot.getCurrent(), parent, true); Long hostId = vmSnapshotHelper.pickRunningHost(vmSnapshot.getVmId()); GuestOSVO guestOS = guestOSDao.findById(userVm.getGuestOSId()); RevertToVMSnapshotCommand revertToSnapshotCommand = new RevertToVMSnapshotCommand(vmInstanceName, vmSnapshotTO, volumeTOs, guestOS.getDisplayName()); diff --git a/engine/storage/src/org/apache/cloudstack/storage/helper/HypervisorHelperImpl.java b/engine/storage/src/org/apache/cloudstack/storage/helper/HypervisorHelperImpl.java index 7dbd35cf254..eb29aa4d85b 100644 --- a/engine/storage/src/org/apache/cloudstack/storage/helper/HypervisorHelperImpl.java +++ b/engine/storage/src/org/apache/cloudstack/storage/helper/HypervisorHelperImpl.java @@ -111,7 +111,7 @@ public class HypervisorHelperImpl implements HypervisorHelper { int wait = NumbersUtil.parseInt(value, 1800); Long hostId = vmSnapshotHelper.pickRunningHost(virtualMachine.getId()); VMSnapshotTO vmSnapshotTO = new VMSnapshotTO(1L, UUID.randomUUID().toString(), VMSnapshot.Type.DiskAndMemory, null, null, false, - null); + null, true); GuestOSVO guestOS = guestOSDao.findById(virtualMachine.getGuestOSId()); List volumeTOs = vmSnapshotHelper.getVolumeTOList(virtualMachine.getId()); CreateVMSnapshotCommand ccmd = new CreateVMSnapshotCommand(virtualMachine.getInstanceName(),vmSnapshotTO ,volumeTOs, guestOS.getDisplayName(),virtualMachine.getState()); diff --git a/engine/storage/src/org/apache/cloudstack/storage/helper/VMSnapshotHelperImpl.java b/engine/storage/src/org/apache/cloudstack/storage/helper/VMSnapshotHelperImpl.java index 1200be89629..9693e914cd4 100644 --- a/engine/storage/src/org/apache/cloudstack/storage/helper/VMSnapshotHelperImpl.java +++ b/engine/storage/src/org/apache/cloudstack/storage/helper/VMSnapshotHelperImpl.java @@ -122,7 +122,7 @@ public class VMSnapshotHelperImpl implements VMSnapshotHelper { private VMSnapshotTO convert2VMSnapshotTO(VMSnapshotVO vo) { return new VMSnapshotTO(vo.getId(), vo.getName(), vo.getType(), vo.getCreated().getTime(), vo.getDescription(), - vo.getCurrent(), null); + vo.getCurrent(), null, true); } @Override diff --git a/plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/manager/VmwareStorageManagerImpl.java b/plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/manager/VmwareStorageManagerImpl.java index 4c34ebc365b..3519ca1c4dc 100644 --- a/plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/manager/VmwareStorageManagerImpl.java +++ b/plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/manager/VmwareStorageManagerImpl.java @@ -1275,6 +1275,7 @@ public class VmwareStorageManagerImpl implements VmwareStorageManager { String vmSnapshotName = cmd.getTarget().getSnapshotName(); String vmSnapshotDesc = cmd.getTarget().getDescription(); boolean snapshotMemory = cmd.getTarget().getType() == VMSnapshot.Type.DiskAndMemory; + boolean quiescevm = cmd.getTarget().getQuiescevm(); VirtualMachineMO vmMo = null; VmwareContext context = hostService.getServiceContext(cmd); Map mapNewDisk = new HashMap(); @@ -1303,7 +1304,7 @@ public class VmwareStorageManagerImpl implements VmwareStorageManager { } else { if (vmMo.getSnapshotMor(vmSnapshotName) != null){ s_logger.debug("VM snapshot " + vmSnapshotName + " already exists"); - }else if (!vmMo.createSnapshot(vmSnapshotName, vmSnapshotDesc, snapshotMemory, true)) { + }else if (!vmMo.createSnapshot(vmSnapshotName, vmSnapshotDesc, snapshotMemory, quiescevm)) { return new CreateVMSnapshotAnswer(cmd, false, "Unable to create snapshot due to esxi internal failed"); }