From 64f4480ef4155e946ac257f78879e9c8002afe3d Mon Sep 17 00:00:00 2001 From: Nicolas Vazquez Date: Thu, 11 Jan 2024 03:32:02 -0300 Subject: [PATCH] Fix Vmware to KVM migration (#8485) This PR fixes the Vmware to KVM migration issue on main branch Fixes: #8473 --- .../org/apache/cloudstack/vm/UnmanagedVMsManagerImpl.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/server/src/main/java/org/apache/cloudstack/vm/UnmanagedVMsManagerImpl.java b/server/src/main/java/org/apache/cloudstack/vm/UnmanagedVMsManagerImpl.java index 85f2119b4ca3..3179bf12fea5 100644 --- a/server/src/main/java/org/apache/cloudstack/vm/UnmanagedVMsManagerImpl.java +++ b/server/src/main/java/org/apache/cloudstack/vm/UnmanagedVMsManagerImpl.java @@ -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 dataDiskOfferingMap, final Map nicNetworkMap, final Map callerNicIpAddressMap, - final Map details, final boolean migrateAllowed, final boolean forced) { + final Map 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; @@ -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)); } @@ -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) { @@ -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) {