Skip to content

Commit 64f4480

Browse files
authored
Fix Vmware to KVM migration (apache#8485)
This PR fixes the Vmware to KVM migration issue on main branch Fixes: apache#8473
1 parent c43b7c0 commit 64f4480

1 file changed

Lines changed: 4 additions & 4 deletions

File tree

server/src/main/java/org/apache/cloudstack/vm/UnmanagedVMsManagerImpl.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1064,7 +1064,7 @@ private UserVm importVirtualMachineInternal(final UnmanagedInstanceTO unmanagedI
10641064
final VirtualMachineTemplate template, final String displayName, final String hostName, final Account caller, final Account owner, final Long userId,
10651065
final ServiceOfferingVO serviceOffering, final Map<String, Long> dataDiskOfferingMap,
10661066
final Map<String, Long> nicNetworkMap, final Map<String, Network.IpAddresses> callerNicIpAddressMap,
1067-
final Map<String, String> details, final boolean migrateAllowed, final boolean forced) {
1067+
final Map<String, String> details, final boolean migrateAllowed, final boolean forced, final boolean isImportUnmanagedFromSameHypervisor) {
10681068
LOGGER.debug(LogUtils.logGsonWithoutException("Trying to import VM [%s] with name [%s], in zone [%s], cluster [%s], and host [%s], using template [%s], service offering [%s], disks map [%s], NICs map [%s] and details [%s].",
10691069
unmanagedInstance, instanceName, zone, cluster, host, template, serviceOffering, dataDiskOfferingMap, nicNetworkMap, details));
10701070
UserVm userVm = null;
@@ -1112,7 +1112,7 @@ private UserVm importVirtualMachineInternal(final UnmanagedInstanceTO unmanagedI
11121112
}
11131113
}
11141114
allDetails.put(VmDetailConstants.ROOT_DISK_CONTROLLER, rootDisk.getController());
1115-
if (cluster.getHypervisorType() != Hypervisor.HypervisorType.VMware) {
1115+
if (cluster.getHypervisorType() == Hypervisor.HypervisorType.KVM && isImportUnmanagedFromSameHypervisor) {
11161116
allDetails.put(VmDetailConstants.ROOT_DISK_SIZE, String.valueOf(rootDisk.getCapacity() / Resource.ResourceType.bytesToGiB));
11171117
}
11181118

@@ -1512,7 +1512,7 @@ private UserVm importUnmanagedInstanceFromHypervisor(DataCenter zone, Cluster cl
15121512
template, displayName, hostName, CallContext.current().getCallingAccount(), owner, userId,
15131513
serviceOffering, dataDiskOfferingMap,
15141514
nicNetworkMap, nicIpAddressMap,
1515-
details, migrateAllowed, forced);
1515+
details, migrateAllowed, forced, true);
15161516
break;
15171517
}
15181518
if (userVm != null) {
@@ -1582,7 +1582,7 @@ protected UserVm importUnmanagedInstanceFromVmwareToKvm(DataCenter zone, Cluster
15821582
template, displayName, hostName, caller, owner, userId,
15831583
serviceOffering, dataDiskOfferingMap,
15841584
nicNetworkMap, nicIpAddressMap,
1585-
details, false, forced);
1585+
details, false, forced, false);
15861586
LOGGER.debug(String.format("VM %s imported successfully", sourceVM));
15871587
return userVm;
15881588
} catch (CloudRuntimeException e) {

0 commit comments

Comments
 (0)