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)
This commit is contained in:
Sanjay Tripathi 2014-10-08 19:18:44 +05:30 committed by David Nalley
parent 372ad94368
commit eb447f14e2
3 changed files with 20 additions and 1 deletions

View File

@ -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());

View File

@ -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);

View File

@ -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',