Skip to content

Commit 919d34e

Browse files
author
GutoVeronezi
committed
Enable system VM's volume migration for KVM in API
1 parent 15c4dcf commit 919d34e

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

server/src/main/java/com/cloud/vm/UserVmManagerImpl.java

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -630,6 +630,8 @@ public class UserVmManagerImpl extends ManagerBase implements UserVmManager, Vir
630630
HypervisorType.Simulator
631631
));
632632

633+
private static final List<HypervisorType> HYPERVISORS_THAT_CAN_DO_STORAGE_MIGRATION_ON_NON_USER_VMS = Arrays.asList(HypervisorType.KVM, HypervisorType.VMware);
634+
633635
@Override
634636
public UserVmVO getVirtualMachine(long vmId) {
635637
return _vmDao.findById(vmId);
@@ -6093,16 +6095,18 @@ private VMInstanceVO preVmStorageMigrationCheck(Long vmId) {
60936095
throw ex;
60946096
}
60956097

6096-
if (vm.getType() != VirtualMachine.Type.User && !HypervisorType.VMware.equals(vm.getHypervisorType())) {
6097-
throw new InvalidParameterValueException("cannot do storage migration on non-user vm for hypervisor: " + vm.getHypervisorType().toString() + ", only supported for VMware");
6098+
HypervisorType hypervisorType = vm.getHypervisorType();
6099+
if (vm.getType() != VirtualMachine.Type.User && !HYPERVISORS_THAT_CAN_DO_STORAGE_MIGRATION_ON_NON_USER_VMS.contains(hypervisorType)) {
6100+
throw new InvalidParameterValueException(String.format("Unable to migrate storage of non-user VMs for hypervisor [%s]. Operation only supported for the following"
6101+
+ " hypervisors: [%s].", hypervisorType, HYPERVISORS_THAT_CAN_DO_STORAGE_MIGRATION_ON_NON_USER_VMS));
60986102
}
60996103

61006104
List<VolumeVO> vols = _volsDao.findByInstance(vm.getId());
61016105
if (vols.size() > 1) {
61026106
// OffLineVmwareMigration: data disks are not permitted, here!
61036107
if (vols.size() > 1 &&
61046108
// OffLineVmwareMigration: allow multiple disks for vmware
6105-
!HypervisorType.VMware.equals(vm.getHypervisorType())) {
6109+
!HypervisorType.VMware.equals(hypervisorType)) {
61066110
throw new InvalidParameterValueException("Data disks attached to the vm, can not migrate. Need to detach data disks first");
61076111
}
61086112
}

0 commit comments

Comments
 (0)