Skip to content

Commit cd9929f

Browse files
committed
[KVM] Fix for UUID retrieval of Windows VMs on Ubuntu 24
1 parent db5b6a5 commit cd9929f

File tree

1 file changed

+27
-1
lines changed

1 file changed

+27
-1
lines changed

plugins/hypervisors/kvm/src/main/java/com/cloud/hypervisor/kvm/resource/LibvirtComputingResource.java

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -395,6 +395,7 @@ public class LibvirtComputingResource extends ServerResourceBase implements Serv
395395
private final static long HYPERVISOR_LIBVIRT_VERSION_SUPPORTS_IO_URING = 6003000;
396396
private final static long HYPERVISOR_QEMU_VERSION_SUPPORTS_IO_URING = 5000000;
397397
private final static long HYPERVISOR_QEMU_VERSION_IDE_DISCARD_FIXED = 7000000;
398+
private final static long HYPERVISOR_QEMU_VERSION_PC_MACHINE_TYPE_FIX = 8000000;
398399

399400
protected HypervisorType hypervisorType;
400401
protected String hypervisorURI;
@@ -2903,6 +2904,31 @@ private boolean isGuestAarch64() {
29032904
return AARCH64.equals(guestCpuArch);
29042905
}
29052906

2907+
private boolean isQemuVersionConflictingSMBiosForWindowsGuestVMs() {
2908+
if (!isUbuntuOrDebianHost()) {
2909+
return false;
2910+
}
2911+
return getHypervisorQemuVersion() > HYPERVISOR_QEMU_VERSION_PC_MACHINE_TYPE_FIX;
2912+
}
2913+
2914+
/**
2915+
* Observed the QEMU version included on Ubuntu 24 conflicts retrieval of UUID for Windows VMs
2916+
* References:
2917+
* - <a href="https://gitlab.com/libvirt/libvirt/-/issues/807">Reported issue with CloudStack created Windows VMs on Ubuntu 24</a>
2918+
* - <a href="https://gitlab.com/qemu-project/qemu/-/issues/2008">Reported Issue on QEMU</a>
2919+
* Workaround: Set an older OS type machine on the XML domain: 'pc-i440fx-8.0'
2920+
*/
2921+
private void setGuestMachineType(GuestDef guest) {
2922+
if (isGuestAarch64()) {
2923+
guest.setMachineType(VIRT);
2924+
} else if (isQemuVersionConflictingSMBiosForWindowsGuestVMs()) {
2925+
// Please check the method javadoc
2926+
guest.setMachineType("pc-i440fx-8.0");
2927+
} else {
2928+
guest.setMachineType(PC);
2929+
}
2930+
}
2931+
29062932
/**
29072933
* Creates a guest definition from a VM specification.
29082934
*/
@@ -2913,7 +2939,7 @@ protected GuestDef createGuestFromSpec(VirtualMachineTO vmTO, LibvirtVMDef vm, S
29132939
guest.setManufacturer(vmTO.getMetadataManufacturer());
29142940
guest.setProduct(vmTO.getMetadataProductName());
29152941
guest.setGuestArch(guestCpuArch != null ? guestCpuArch : vmTO.getArch());
2916-
guest.setMachineType(isGuestAarch64() ? VIRT : PC);
2942+
setGuestMachineType(guest);
29172943
guest.setBootType(GuestDef.BootType.BIOS);
29182944
if (MapUtils.isNotEmpty(customParams)) {
29192945
if (customParams.containsKey(GuestDef.BootType.UEFI.toString())) {

0 commit comments

Comments
 (0)