Repository navigation
kvm: honour explicit root and data disk controllers for UEFI and Windows VMs - #14844
andrijapanicsb wants to merge 1 commit into
Conversation
…ows VMs When the rootDiskController or dataDiskController detail of a VM is set to virtio, scsi, sata or ide, the KVM agent now uses that bus for the disk on every primary storage type, whatever the guest OS and the boot mode. Until now a Windows VM with UEFI Secure Boot on a file-based pool (and every Windows UEFI VM on PowerFlex) always got SATA disks, whatever was set. Without these details the existing defaults stay, including SATA for Windows UEFI VMs. CD-ROMs are not changed (SATA on UEFI, IDE on BIOS). ide on a UEFI VM gives sata, as the q35 machine type has no IDE bus. skip.force.disk.controller keeps working as before.
|
On the concern raised in #10213 that virtio disks break Windows guests with UEFI Secure Boot (#10213 (comment)): I looked into this claim and tested it. Short version: I found no evidence that virtio disks break Windows under UEFI Secure Boot, and my tests show the What I tested
When Windows really fails None of these cases is caused by the disk bus:
For this PR: forcing SATA only covers case 1, and it overrides every operator who sets virtio on purpose. This If there is a specific Windows version or scenario to check, I can run it and post the results. |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #14844 +/- ##
============================================
+ Coverage 20.83% 20.85% +0.01%
- Complexity 20973 21015 +42
============================================
Files 6053 6053
Lines 548955 548976 +21
Branches 73359 73364 +5
============================================
+ Hits 114377 114481 +104
+ Misses 421186 421115 -71
+ Partials 13392 13380 -12
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
|
@ACSHomeBot package G |
|
Accepted: Planned: RPM + DEB, KVM SystemVM. Status: Completed. Packaging results. |
Packaging results:
Test packages are available at:
|
Description
This PR makes the KVM agent use the disk bus that is set for a VM with the
rootDiskControlleranddataDiskControllerdetails (VM details, or template details copied to the VM), whatever the guest OS, the bootmode (BIOS, UEFI legacy, UEFI secure) and the primary storage type. When no controller is set, nothing changes.
Problem. A Windows VM with UEFI Secure Boot on a file-based primary storage (NFS, local, SharedMountPoint) always
gets its disks on SATA, even when its details say
rootDiskController=virtioanddataDiskController=virtioand theguest has the virtio storage drivers. Example: a Windows Server 2025 VM (q35, UEFI Secure Boot, NFS primary storage)
imported with
UEFI=SECURE,rootDiskController=virtio,dataDiskController=virtio,nicAdapter=virtio: libvirtgets both disks with
bus='sata'. The same happens for Windows Server 2019 and 2022: there is no Windows versionspecific code, the KVM agent only checks whether the OS name contains "window".
Expected. If the VM settings say the disk controller is virtio, the disks are virtio. A VM without these settings
keeps today's defaults (SATA for Windows UEFI VMs), and the CD-ROMs of UEFI VMs stay on SATA.
Root cause
The bus is forced in
LibvirtComputingResource.createVbd()after the controller details have been read:DiskDef.defFileBasedDisk(path, devId, format, isWindowsOS), which puts the diskof a Secure Boot VM on SATA (Windows) or virtio (other OSes), ignoring the controller details. Its author later
explained it as an issue with Windows Secure Boot guests and virtio disks, and noted that this "always over-rides
the os configuration setting, no matter what controller configured"
(kvm: fix disk controller for secure boot vm #10213 (comment)).
they are forced too), and put the CD-ROMs of UEFI VMs on SATA (the q35 machine type has no IDE bus).
skip.force.disk.controllerVM/template detail as an opt-out, on file-based pools only (issue RootDiskController setting not Honored throughout Instance lifecycle #9460).
As a result, whether an explicit controller is honoured depends on the storage type:
createVbd)rootDiskControllerhonoured (no forcing)dataDiskControllerignoredrootDiskControllerhonoureddataDiskControllerignoredSo Windows UEFI Secure Boot VMs with
rootDiskController=virtioalready get virtio disks on RBD and CLVM pools today;only file-based pools and PowerFlex force SATA.
The change (KVM agent only)
plugins/hypervisors/kvm/.../LibvirtComputingResource.java:getExplicitDiskBus(): returns the bus set for a disk byrootDiskController(root volume) ordataDiskController(data volume), ornullwhen the detail is not set or is notvirtio,scsi,sataoride(for example
osdefault, which the UI puts in KVM templates by default). Two rules keep it compatible:dataDiskControllerfollow the root disk, as they do today.ideon a UEFI VM givessata: UEFI VMs use q35, which has no IDE bus (libvirt refuses it), and SATA is what theCD-ROMs of UEFI VMs already use.
createVbd(): when that bus is set, it is used for the disk on every pool type (file-based, PowerFlex, RBD, Gluster,CLVM, RAW). When it is not set, the existing code runs unchanged, including the SATA defaults of Windows UEFI VMs and
the PowerFlex SATA forcing.
defineDiskForDefaultPoolType(): newexplicitDiskBusparameter.skip.force.disk.controlleris still checkedfirst and behaves exactly as before.
Not changed: CD-ROMs (still SATA on UEFI, IDE on BIOS), device names (
vdXfor virtio,sdXfor SATA/SCSI, letter fromthe device id), the hot-plug path (
KVMStorageProcessor, which already honours the controller details since #12452),the management server, the API, the UI and the database.
Behaviour
Only VMs with
rootDiskControllerand/ordataDiskControllerset tovirtio,scsi,sataoridecan change, andonly at their next start.
osdefaultosdefaultCompatibility and upgrade notes
The agent cannot tell who set a controller detail, but on KVM the management server never writes a default one:
the details come from the user (deploy or update details, UI settings), from the template details, or from the
import of an unmanaged or converted VM, which copies the bus the source disk used
(
UnmanagedVMsManagerImpl). Theosdefaultvalue is not a bus and is treated as not set, as before.VMs whose explicit controller was overridden get it at their next start (bold cells above). A Windows guest moved
from SATA to virtio needs the virtio storage driver installed and enabled for boot, otherwise it stops with
INACCESSIBLE_BOOT_DEVICE. Note that the VMware to KVM conversion stores
virtiofor a disk when the converted domainXML cannot be parsed (
LibvirtBaseConvertCommandWrapper). Operators can list these VMs before upgrading the agentsand set
rootDiskController=sata/dataDiskController=satato keep SATA:(4.20 uses the table
user_vm_details. Add the PowerFlex, RBD and Gluster VMs listed in the table above if thosepools are used.)
Running VMs are not touched. Live migration keeps the running domain definition.
During a rolling upgrade, a VM gets SATA or virtio depending on the agent version of the host it starts on.
skip.force.disk.controllerkeeps working. It is no longer needed to get explicit controllers honoured; it onlychanges the defaults used when no controller is set.
On q35, each virtio disk takes a PCIe root port and SATA disks do not. See Unable to add more than 2 volumes or networks to a vm deployed from a UEFI image #11212 about the PCIe slots left for
hot-plugging volumes and NICs into UEFI VMs.
Types of changes
Feature/Enhancement Scale or Bug Severity
Bug Severity
How Has This Been Tested?
Unit tests in
LibvirtComputingResourceTest(20 new, 5 updated for the new parameter). ThecreateVbdtests build thelibvirt disk definitions of a User VM the way it is done at start, and check bus, target name and the
<target>XMLof every disk and CD-ROM:
vda/vdbvirtio, CD-ROMssdd/sdeSATA.osdefault: SATA, as before.dataDiskControlleris not set.scsi: honoured.ideon UEFI gives SATA;ideon BIOS stays IDE;virtio-blkkeeps the current behaviour.skip.force.disk.controller=truegives the same buses as before.UEFI legacy and UEFI secure, and 7 controller combinations.
Results (JDK 17, Maven 3.8.7):
mvn -pl plugins/hypervisors/kvm test -Dtest=LibvirtComputingResourceTest: 350 tests, 0 failures.mvn -pl plugins/hypervisors/kvm test(whole KVM plugin, checkstyle included): 1119 tests, 0 failures, 0 errors,1 skipped (
QemuImgTest, needs a local qemu-img).createVbdtests run againstmainwithout the fix: the 8 that check explicit controllers fail(for example "expected virtio but was sata" for the Windows Secure Boot case) and the 7 that check unchanged
behaviour pass.
Lab tests
These were run before this change, using
skip.force.disk.controller=true. For a VM with explicit virtio controllersthat gives the same libvirt disk definitions as this change. A run with the patched agent jar itself is still to be
done; only the
cloud-plugin-hypervisor-kvmjar needs to be replaced on a host for it.Setup
pc-q35-rhel9.0.0,OVMF_CODE.secboot.fdwith SMM.(virtio-win 1.9.61, viostor 100.103.104.30200).
UEFI=SECURE,rootDiskController=virtio,dataDiskController=virtio,nicAdapter=virtio.Results
skip.force.disk.controllersdb,sdc,bus='sata'sdd,sde, SATAtruevdb,vdc,bus='virtio'sdd,sde, SATAtrue(a fresh VM)vdb,vdc,bus='virtio'sdd,sde, SATAits own ("Operating System: Upgrade (Planned)"); after that it settled.
Microsoft keys and a virtio-blk boot disk:
Confirm-SecureBootUEFIreturnedTrueon the first boot and after areboot.
How did you try to break this feature and the system with this change?
osdefault, withvirtio-blk, withskip.force.disk.controller: same buses asbefore (unit tests above).
vdXnames, which cannot collide with the CD-ROMs; SATA and SCSI disks keep the
sdXname of their device id, and thedevice ids of the CD-ROMs are still kept free for the volumes (server,kvm: Avoid device id conflicts between data volumes, CD-ROMs and the config drive ISO #14407).
ideon UEFI VMs, which libvirt refuses on q35: given SATA.Backport
4.22 and 4.20 have the same forcing code (#11554, #11750 and #12452 are on both branches), so they need the fix too.
The patch does not apply cleanly to them: one trivial conflict in
createVbd(CLVM_NGdoes not exist on thesebranches) and context differences in the test class. The
createVbdtests also need the CD-ROMs passed as ISO volumes,because the KVM agent of these branches does not define the empty CD-ROM slots itself (#13101 is not on them).
#14407 is not on these branches (#14073 is open for 4.22), so the SATA name collisions of #13484 can still happen there
for VMs whose disks are on SATA; this PR does not change that, and VMs whose disks are on virtio do not have it.
Checked locally with the conflicts resolved (JDK 17):
LibvirtComputingResourceTestpasses on 4.22 at759bb81886(289 tests) and on 4.20 at
e6f193db80(262 tests), the 20 new tests included. The resolved 4.22 change appliescleanly to the tags 4.22.1.0 and 4.22.1.1, the 4.20 one to 4.20.3.1. On the tag 4.23.0.0 the
mainpatch applieswith a 3-way merge and no conflict, and the test class passes (335 tests).
Documentation
The admin guide notes added by apache/cloudstack-documentation#616 and #655 should say that the
rootDiskControllerand
dataDiskControllersettings are honoured for UEFI and Windows VMs, and thatskip.force.disk.controlleronlymatters when no controller is set.