Skip to content

Commit e32111a

Browse files
author
GutoVeronezi
committed
Enable system VM's volume migration for KVM in API
1 parent 8871531 commit e32111a

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);
@@ -6084,16 +6086,18 @@ private VMInstanceVO preVmStorageMigrationCheck(Long vmId) {
60846086
throw ex;
60856087
}
60866088

6087-
if (vm.getType() != VirtualMachine.Type.User && !HypervisorType.VMware.equals(vm.getHypervisorType())) {
6088-
throw new InvalidParameterValueException("cannot do storage migration on non-user vm for hypervisor: " + vm.getHypervisorType().toString() + ", only supported for VMware");
6089+
HypervisorType hypervisorType = vm.getHypervisorType();
6090+
if (vm.getType() != VirtualMachine.Type.User && !HYPERVISORS_THAT_CAN_DO_STORAGE_MIGRATION_ON_NON_USER_VMS.contains(hypervisorType)) {
6091+
throw new InvalidParameterValueException(String.format("Unable to migrate storage of non-user VMs for hypervisor [%s]. Operation only supported for the following"
6092+
+ " hypervisors: [%s].", hypervisorType, HYPERVISORS_THAT_CAN_DO_STORAGE_MIGRATION_ON_NON_USER_VMS));
60896093
}
60906094

60916095
List<VolumeVO> vols = _volsDao.findByInstance(vm.getId());
60926096
if (vols.size() > 1) {
60936097
// OffLineVmwareMigration: data disks are not permitted, here!
60946098
if (vols.size() > 1 &&
60956099
// OffLineVmwareMigration: allow multiple disks for vmware
6096-
!HypervisorType.VMware.equals(vm.getHypervisorType())) {
6100+
!HypervisorType.VMware.equals(hypervisorType)) {
60976101
throw new InvalidParameterValueException("Data disks attached to the vm, can not migrate. Need to detach data disks first");
60986102
}
60996103
}

0 commit comments

Comments
 (0)