Skip to content

Commit

Permalink
Fix Vmware to KVM migration (apache#8485)
Browse files Browse the repository at this point in the history
This PR fixes the Vmware to KVM migration issue on main branch

Fixes: apache#8473
  • Loading branch information
nvazquez authored Jan 11, 2024
1 parent c43b7c0 commit 64f4480
Showing 1 changed file with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1064,7 +1064,7 @@ private UserVm importVirtualMachineInternal(final UnmanagedInstanceTO unmanagedI
final VirtualMachineTemplate template, final String displayName, final String hostName, final Account caller, final Account owner, final Long userId,
final ServiceOfferingVO serviceOffering, final Map<String, Long> dataDiskOfferingMap,
final Map<String, Long> nicNetworkMap, final Map<String, Network.IpAddresses> callerNicIpAddressMap,
final Map<String, String> details, final boolean migrateAllowed, final boolean forced) {
final Map<String, String> details, final boolean migrateAllowed, final boolean forced, final boolean isImportUnmanagedFromSameHypervisor) {
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].",
unmanagedInstance, instanceName, zone, cluster, host, template, serviceOffering, dataDiskOfferingMap, nicNetworkMap, details));
UserVm userVm = null;
Expand Down Expand Up @@ -1112,7 +1112,7 @@ private UserVm importVirtualMachineInternal(final UnmanagedInstanceTO unmanagedI
}
}
allDetails.put(VmDetailConstants.ROOT_DISK_CONTROLLER, rootDisk.getController());
if (cluster.getHypervisorType() != Hypervisor.HypervisorType.VMware) {
if (cluster.getHypervisorType() == Hypervisor.HypervisorType.KVM && isImportUnmanagedFromSameHypervisor) {
allDetails.put(VmDetailConstants.ROOT_DISK_SIZE, String.valueOf(rootDisk.getCapacity() / Resource.ResourceType.bytesToGiB));
}

Expand Down Expand Up @@ -1512,7 +1512,7 @@ private UserVm importUnmanagedInstanceFromHypervisor(DataCenter zone, Cluster cl
template, displayName, hostName, CallContext.current().getCallingAccount(), owner, userId,
serviceOffering, dataDiskOfferingMap,
nicNetworkMap, nicIpAddressMap,
details, migrateAllowed, forced);
details, migrateAllowed, forced, true);
break;
}
if (userVm != null) {
Expand Down Expand Up @@ -1582,7 +1582,7 @@ protected UserVm importUnmanagedInstanceFromVmwareToKvm(DataCenter zone, Cluster
template, displayName, hostName, caller, owner, userId,
serviceOffering, dataDiskOfferingMap,
nicNetworkMap, nicIpAddressMap,
details, false, forced);
details, false, forced, false);
LOGGER.debug(String.format("VM %s imported successfully", sourceVM));
return userVm;
} catch (CloudRuntimeException e) {
Expand Down

0 comments on commit 64f4480

Please sign in to comment.