From eb447f14e2c7fb1c72501a644ce07e09e2644bd9 Mon Sep 17 00:00:00 2001 From: Sanjay Tripathi Date: Wed, 8 Oct 2014 19:18:44 +0530 Subject: [PATCH] CLOUDSTACK:7323: [vGPU] Creation of VM snapshot with "memory" is failing. VM snapshot with memory is not supported for VGPU VMs, so putting checks for same. (cherry picked from commit 123ec8b3d326b6bc743852a6bf113ac8b019f713) --- .../src/com/cloud/vm/snapshot/VMSnapshotManagerImpl.java | 8 ++++++++ .../test/com/cloud/vm/snapshot/VMSnapshotManagerTest.java | 5 +++++ ui/scripts/instances.js | 8 +++++++- 3 files changed, 20 insertions(+), 1 deletion(-) diff --git a/server/src/com/cloud/vm/snapshot/VMSnapshotManagerImpl.java b/server/src/com/cloud/vm/snapshot/VMSnapshotManagerImpl.java index c7d7a8c2131..f85f6c88f6f 100644 --- a/server/src/com/cloud/vm/snapshot/VMSnapshotManagerImpl.java +++ b/server/src/com/cloud/vm/snapshot/VMSnapshotManagerImpl.java @@ -55,9 +55,11 @@ import com.cloud.exception.InsufficientCapacityException; import com.cloud.exception.InvalidParameterValueException; import com.cloud.exception.ResourceAllocationException; import com.cloud.exception.ResourceUnavailableException; +import com.cloud.gpu.GPU; import com.cloud.hypervisor.Hypervisor.HypervisorType; import com.cloud.hypervisor.dao.HypervisorCapabilitiesDao; import com.cloud.projects.Project.ListProjectResourcesCriteria; +import com.cloud.service.dao.ServiceOfferingDetailsDao; import com.cloud.storage.Snapshot; import com.cloud.storage.SnapshotVO; import com.cloud.storage.VolumeVO; @@ -108,6 +110,7 @@ public class VMSnapshotManagerImpl extends ManagerBase implements VMSnapshotMana @Inject VMInstanceDao _vmInstanceDao; + @Inject ServiceOfferingDetailsDao _serviceOfferingDetailsDao; @Inject VMSnapshotDao _vmSnapshotDao; @Inject VolumeDao _volumeDao; @Inject AccountDao _accountDao; @@ -258,6 +261,11 @@ public class VMSnapshotManagerImpl extends ManagerBase implements VMSnapshotMana throw new InvalidParameterValueException("Creating VM snapshot failed due to VM:" + vmId + " is a system VM or does not exist"); } + // VM snapshot with memory is not supported for VGPU Vms + if (snapshotMemory && _serviceOfferingDetailsDao.findDetail(userVmVo.getServiceOfferingId(), GPU.Keys.vgpuType.toString()) != null) { + throw new InvalidParameterValueException("VM snapshot with MEMORY is not supported for VGU enabled VMs."); + } + // check hypervisor capabilities if (!_hypervisorCapabilitiesDao.isVmSnapshotEnabled(userVmVo.getHypervisorType(), "default")) throw new InvalidParameterValueException("VM snapshot is not enabled for hypervisor type: " + userVmVo.getHypervisorType()); diff --git a/server/test/com/cloud/vm/snapshot/VMSnapshotManagerTest.java b/server/test/com/cloud/vm/snapshot/VMSnapshotManagerTest.java index 9d5c2b42ea9..9d1ed4f6a74 100644 --- a/server/test/com/cloud/vm/snapshot/VMSnapshotManagerTest.java +++ b/server/test/com/cloud/vm/snapshot/VMSnapshotManagerTest.java @@ -47,6 +47,7 @@ import com.cloud.host.dao.HostDao; import com.cloud.hypervisor.Hypervisor; import com.cloud.hypervisor.HypervisorGuruManager; import com.cloud.hypervisor.dao.HypervisorCapabilitiesDao; +import com.cloud.service.dao.ServiceOfferingDetailsDao; import com.cloud.storage.GuestOSVO; import com.cloud.storage.Snapshot; import com.cloud.storage.SnapshotVO; @@ -104,6 +105,8 @@ public class VMSnapshotManagerTest { ConfigurationDao _configDao; @Mock HypervisorCapabilitiesDao _hypervisorCapabilitiesDao; + @Mock + ServiceOfferingDetailsDao _serviceOfferingDetailsDao; int _vmSnapshotMax = 10; private static final long TEST_VM_ID = 3L; @@ -124,6 +127,7 @@ public class VMSnapshotManagerTest { _vmSnapshotMgr._snapshotDao = _snapshotDao; _vmSnapshotMgr._guestOSDao = _guestOSDao; _vmSnapshotMgr._hypervisorCapabilitiesDao = _hypervisorCapabilitiesDao; + _vmSnapshotMgr._serviceOfferingDetailsDao = _serviceOfferingDetailsDao; doNothing().when(_accountMgr).checkAccess(any(Account.class), any(AccessType.class), any(Boolean.class), any(ControlledEntity.class)); @@ -133,6 +137,7 @@ public class VMSnapshotManagerTest { when(_vmSnapshotDao.findByName(anyLong(), anyString())).thenReturn(null); when(_vmSnapshotDao.findByVm(anyLong())).thenReturn(new ArrayList()); when(_hypervisorCapabilitiesDao.isVmSnapshotEnabled(Hypervisor.HypervisorType.XenServer, "default")).thenReturn(true); + when(_serviceOfferingDetailsDao.findDetail(anyLong(), anyString())).thenReturn(null); List mockVolumeList = new ArrayList(); mockVolumeList.add(volumeMock); diff --git a/ui/scripts/instances.js b/ui/scripts/instances.js index a15fcd95c5f..7653a182398 100644 --- a/ui/scripts/instances.js +++ b/ui/scripts/instances.js @@ -40,7 +40,13 @@ snapshotMemory: { label: 'label.vmsnapshot.memory', isBoolean: true, - isChecked: false + isChecked: false, + isHidden: function(args) { + if (args.context.instances[0].vgpu != undefined) { + return true; + } + return false; + } }, quiescevm: { label: 'label.quiesce.vm',