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)
Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/eb447f14
Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/eb447f14
Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/eb447f14
Branch: refs/heads/master
Commit: eb447f14e2c7fb1c72501a644ce07e09e2644bd9
Parents: 372ad94
Author: Sanjay Tripathi <sanjay.tripathi@citrix.com>
Authored: Wed Oct 8 19:18:44 2014 +0530
Committer: David Nalley <david@gnsa.us>
Committed: Mon Oct 13 00:35:13 2014 -0400
----------------------------------------------------------------------
server/src/com/cloud/vm/snapshot/VMSnapshotManagerImpl.java | 8 ++++++++
server/test/com/cloud/vm/snapshot/VMSnapshotManagerTest.java | 5 +++++
ui/scripts/instances.js | 8 +++++++-
3 files changed, 20 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/eb447f14/server/src/com/cloud/vm/snapshot/VMSnapshotManagerImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/vm/snapshot/VMSnapshotManagerImpl.java b/server/src/com/cloud/vm/snapshot/VMSnapshotManagerImpl.java
index c7d7a8c..f85f6c8 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());
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/eb447f14/server/test/com/cloud/vm/snapshot/VMSnapshotManagerTest.java
----------------------------------------------------------------------
diff --git a/server/test/com/cloud/vm/snapshot/VMSnapshotManagerTest.java b/server/test/com/cloud/vm/snapshot/VMSnapshotManagerTest.java
index 9d5c2b4..9d1ed4f 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<VMSnapshotVO>());
when(_hypervisorCapabilitiesDao.isVmSnapshotEnabled(Hypervisor.HypervisorType.XenServer,
"default")).thenReturn(true);
+ when(_serviceOfferingDetailsDao.findDetail(anyLong(), anyString())).thenReturn(null);
List<VolumeVO> mockVolumeList = new ArrayList<VolumeVO>();
mockVolumeList.add(volumeMock);
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/eb447f14/ui/scripts/instances.js
----------------------------------------------------------------------
diff --git a/ui/scripts/instances.js b/ui/scripts/instances.js
index a15fcd9..7653a18 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',
|