Skip to content

Commit eb447f1

Browse files
sanjaytripathike4qqq
authored andcommitted
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 123ec8b)
1 parent 372ad94 commit eb447f1

3 files changed

Lines changed: 20 additions & 1 deletion

File tree

‎server/src/com/cloud/vm/snapshot/VMSnapshotManagerImpl.java‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,9 +55,11 @@
5555
import com.cloud.exception.InvalidParameterValueException;
5656
import com.cloud.exception.ResourceAllocationException;
5757
import com.cloud.exception.ResourceUnavailableException;
58+
import com.cloud.gpu.GPU;
5859
import com.cloud.hypervisor.Hypervisor.HypervisorType;
5960
import com.cloud.hypervisor.dao.HypervisorCapabilitiesDao;
6061
import com.cloud.projects.Project.ListProjectResourcesCriteria;
62+
import com.cloud.service.dao.ServiceOfferingDetailsDao;
6163
import com.cloud.storage.Snapshot;
6264
import com.cloud.storage.SnapshotVO;
6365
import com.cloud.storage.VolumeVO;
@@ -108,6 +110,7 @@ public class VMSnapshotManagerImpl extends ManagerBase implements VMSnapshotMana
108110

109111
@Inject
110112
VMInstanceDao _vmInstanceDao;
113+
@Inject ServiceOfferingDetailsDao _serviceOfferingDetailsDao;
111114
@Inject VMSnapshotDao _vmSnapshotDao;
112115
@Inject VolumeDao _volumeDao;
113116
@Inject AccountDao _accountDao;
@@ -258,6 +261,11 @@ public VMSnapshot allocVMSnapshot(Long vmId, String vsDisplayName, String vsDesc
258261
throw new InvalidParameterValueException("Creating VM snapshot failed due to VM:" + vmId + " is a system VM or does not exist");
259262
}
260263

264+
// VM snapshot with memory is not supported for VGPU Vms
265+
if (snapshotMemory && _serviceOfferingDetailsDao.findDetail(userVmVo.getServiceOfferingId(), GPU.Keys.vgpuType.toString()) != null) {
266+
throw new InvalidParameterValueException("VM snapshot with MEMORY is not supported for VGU enabled VMs.");
267+
}
268+
261269
// check hypervisor capabilities
262270
if (!_hypervisorCapabilitiesDao.isVmSnapshotEnabled(userVmVo.getHypervisorType(), "default"))
263271
throw new InvalidParameterValueException("VM snapshot is not enabled for hypervisor type: " + userVmVo.getHypervisorType());

‎server/test/com/cloud/vm/snapshot/VMSnapshotManagerTest.java‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@
4747
import com.cloud.hypervisor.Hypervisor;
4848
import com.cloud.hypervisor.HypervisorGuruManager;
4949
import com.cloud.hypervisor.dao.HypervisorCapabilitiesDao;
50+
import com.cloud.service.dao.ServiceOfferingDetailsDao;
5051
import com.cloud.storage.GuestOSVO;
5152
import com.cloud.storage.Snapshot;
5253
import com.cloud.storage.SnapshotVO;
@@ -104,6 +105,8 @@ public class VMSnapshotManagerTest {
104105
ConfigurationDao _configDao;
105106
@Mock
106107
HypervisorCapabilitiesDao _hypervisorCapabilitiesDao;
108+
@Mock
109+
ServiceOfferingDetailsDao _serviceOfferingDetailsDao;
107110
int _vmSnapshotMax = 10;
108111

109112
private static final long TEST_VM_ID = 3L;
@@ -124,6 +127,7 @@ public void setup() {
124127
_vmSnapshotMgr._snapshotDao = _snapshotDao;
125128
_vmSnapshotMgr._guestOSDao = _guestOSDao;
126129
_vmSnapshotMgr._hypervisorCapabilitiesDao = _hypervisorCapabilitiesDao;
130+
_vmSnapshotMgr._serviceOfferingDetailsDao = _serviceOfferingDetailsDao;
127131

128132
doNothing().when(_accountMgr).checkAccess(any(Account.class), any(AccessType.class), any(Boolean.class), any(ControlledEntity.class));
129133

@@ -133,6 +137,7 @@ public void setup() {
133137
when(_vmSnapshotDao.findByName(anyLong(), anyString())).thenReturn(null);
134138
when(_vmSnapshotDao.findByVm(anyLong())).thenReturn(new ArrayList<VMSnapshotVO>());
135139
when(_hypervisorCapabilitiesDao.isVmSnapshotEnabled(Hypervisor.HypervisorType.XenServer, "default")).thenReturn(true);
140+
when(_serviceOfferingDetailsDao.findDetail(anyLong(), anyString())).thenReturn(null);
136141

137142
List<VolumeVO> mockVolumeList = new ArrayList<VolumeVO>();
138143
mockVolumeList.add(volumeMock);

‎ui/scripts/instances.js‎

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,13 @@
4040
snapshotMemory: {
4141
label: 'label.vmsnapshot.memory',
4242
isBoolean: true,
43-
isChecked: false
43+
isChecked: false,
44+
isHidden: function(args) {
45+
if (args.context.instances[0].vgpu != undefined) {
46+
return true;
47+
}
48+
return false;
49+
}
4450
},
4551
quiescevm: {
4652
label: 'label.quiesce.vm',

0 commit comments

Comments
 (0)