-
Notifications
You must be signed in to change notification settings - Fork 1.2k
[Vmware to KVM Migration] Preserve boot type and boot mode of instances to be migrated #10975
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
sureshanaparti
merged 5 commits into
apache:4.20
from
shapeblue:420-vmware2kvm-preserve-boot
Jul 25, 2025
Merged
Changes from 4 commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
c2b4dc2
[Vmware to KVM Migration] Preserve boot type and boot mode of instanc…
nvazquez 2168835
Merge branch '4.20' into 420-vmware2kvm-preserve-boot
nvazquez bce6578
Restore end of line
nvazquez 6f68eca
Extract lines to new method
nvazquez ce013d5
Address review comments
nvazquez File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1113,7 +1113,8 @@ | |
| 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 boolean isImportUnmanagedFromSameHypervisor) { | ||
| final Map<String, String> details, final boolean migrateAllowed, final boolean forced, final boolean isImportUnmanagedFromSameHypervisor, | ||
| final String bootType, final String bootMode) { | ||
| 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; | ||
|
|
@@ -1188,6 +1189,8 @@ | |
| allDetails.put(VmDetailConstants.KVM_VNC_PASSWORD, unmanagedInstance.getVncPassword()); | ||
| } | ||
|
|
||
| addImportingVMBootTypeAndModeDetails(bootType, bootMode, allDetails); | ||
|
|
||
| VirtualMachine.PowerState powerState = VirtualMachine.PowerState.PowerOff; | ||
| if (unmanagedInstance.getPowerState().equals(UnmanagedInstanceTO.PowerState.PowerOn)) { | ||
| powerState = VirtualMachine.PowerState.PowerOn; | ||
|
|
@@ -1259,6 +1262,12 @@ | |
| return userVm; | ||
| } | ||
|
|
||
| private void addImportingVMBootTypeAndModeDetails(String bootType, String bootMode, Map<String, String> allDetails) { | ||
| if (StringUtils.isNotBlank(bootType) && bootType.equalsIgnoreCase("uefi") && StringUtils.isNotBlank(bootMode)) { | ||
| allDetails.put("UEFI", bootMode); | ||
| } | ||
| } | ||
|
|
||
| private HashMap<String, UnmanagedInstanceTO> getUnmanagedInstancesForHost(HostVO host, String instanceName, List<String> managedVms) { | ||
| HashMap<String, UnmanagedInstanceTO> unmanagedInstances = new HashMap<>(); | ||
| if (host.isInMaintenanceStates()) { | ||
|
|
@@ -1564,7 +1573,8 @@ | |
| template, displayName, hostName, CallContext.current().getCallingAccount(), owner, userId, | ||
| serviceOffering, dataDiskOfferingMap, | ||
| nicNetworkMap, nicIpAddressMap, | ||
| details, migrateAllowed, forced, true); | ||
| details, migrateAllowed, forced, true, | ||
| unmanagedInstance.getBootType(), unmanagedInstance.getBootMode()); | ||
|
||
| break; | ||
| } | ||
| if (userVm != null) { | ||
|
|
@@ -1684,7 +1694,8 @@ | |
| template, displayName, hostName, caller, owner, userId, | ||
| serviceOffering, dataDiskOfferingMap, | ||
| nicNetworkMap, nicIpAddressMap, | ||
| details, false, forced, false); | ||
| details, false, forced, false, | ||
| sourceVMwareInstance.getBootType(), sourceVMwareInstance.getBootMode()); | ||
| long timeElapsedInSecs = (System.currentTimeMillis() - importStartTime) / 1000; | ||
| logger.debug(String.format("VMware VM %s imported successfully to CloudStack instance %s (%s), Time taken: %d secs, OVF files imported from %s, Source VMware VM details - OS: %s, PowerState: %s, Disks: %s, NICs: %s", | ||
| sourceVMName, instanceName, displayName, timeElapsedInSecs, (ovfTemplateOnConvertLocation != null)? "MS" : "KVM Host", sourceVMwareInstance.getOperatingSystem(), sourceVMwareInstance.getPowerState(), sourceVMwareInstance.getDisks(), sourceVMwareInstance.getNics())); | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we need to check if bootMode is blank or not?
In a similar code block in #11218, I added a deployasis check as I saw it in UserVmManagerImpl.commitUserVm, not sure if it is worth adding?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the deployasis check doesn't apply here, since Vmware to KVM migrations won't have that boolean enabled then converted VMs will never retain the boot mode and type. In case the VM is deploy as is then the boot mode and type will be preserved.
For the bootMode I think we do need to check if its not blank as that is the value we are adding as detail for the converted VM.