Skip to content

kvm: honour explicit root and data disk controllers for UEFI and Windows VMs - #14844

Open
andrijapanicsb wants to merge 3 commits into
apache:mainfrom
andrijapanicsb:kvm-honour-explicit-disk-controller
Open

andrijapanicsb wants to merge 3 commits into
apache:mainfrom
andrijapanicsb:kvm-honour-explicit-disk-controller

Conversation

@andrijapanicsb

@andrijapanicsb andrijapanicsb commented Nov 25, 2026 •

Copy link
Copy Markdown
Contributor

Description

In short: the KVM agent now uses the disk controller set for a VM (rootDiskController, dataDiskController) on every storage type, for VMs created or imported from this version on. Existing VMs keep exactly the disk buses they have today.

The problem. A Windows VM with UEFI Secure Boot on NFS, local or SharedMountPoint storage (and every Windows UEFI VM on PowerFlex) always gets SATA disks, even with rootDiskController=virtio. A typical case: a Windows Server VM moved from VMware with CloudStack's VMware to KVM import. The import stores virtio, the guest has the virtio drivers, and the disks still end up on SATA. The forcing comes from #3638, #4773 and #11554; skip.force.disk.controller (#11750) is the only way out today.

Why only new VMs. Windows keeps only the storage driver it booted from ready for boot, and marks the others as not needed at boot (registry value StartOverride). So a VM that has booted on SATA stops with INACCESSIBLE_BOOT_DEVICE (0x7B) when it is moved to virtio. We reproduced it: an imported Windows Server 2025 VM that had booted on SATA failed on virtio, and booted on virtio once that registry value was removed. Changing the bus of existing VMs at upgrade would break them.

How it works

  • The management server marks a new KVM VM with the hidden setting honour.disk.controller=true when it is created or imported with an explicit controller (virtio, scsi, sata or ide). A controller inherited from a template counts only if the template has the setting too: KVM templates registered from this version on get it, and so do templates captured from a VM that has it. VMs created from a backup, a volume or a snapshot follow the source VM.
  • The agent honours the controllers only on VMs with that setting. Without it, today's code runs unchanged.
  • Agents report host.honour.disk.controller=true. When a VM with the setting starts on a host whose agent does not report it (during a rolling upgrade), the management server removes the setting for good. The VM then stays on the bus that agent gives it; SATA always boots on UEFI, because the CD-ROMs keep the SATA driver in use.
  • skip.force.disk.controller is unchanged.
VM Before After
Existing Windows UEFI Secure Boot VM with rootDiskController=virtio, NFS SATA SATA (unchanged)
Same kind of VM imported after the upgrade SATA virtio
New VM without controller settings today's defaults today's defaults
New Windows UEFI VM with explicit controllers, PowerFlex SATA the controller set
New VM with dataDiskController, RBD or Gluster data disks on the root disk bus dataDiskController

Existing VMs can be moved by an operator: remove the registry value inside Windows, set honour.disk.controller=true, restart. The steps are in the documentation PR apache/cloudstack-documentation#704.

Types of changes

  • Breaking change (fix or feature that would cause existing functionality to change)
  • New feature (non-breaking change which adds functionality)
  • Bug fix (non-breaking change which fixes an issue)
  • Enhancement (improves an existing feature and functionality)
  • Cleanup (Code refactoring and cleanup, that may add test cases)
  • Build/CI
  • Test (unit or integration test code)

Feature/Enhancement Scale or Bug Severity

Bug Severity

  • BLOCKER
  • Critical
  • Major
  • Minor
  • Trivial

How Has This Been Tested?

  • Unit tests, new: VMs with and without honour.disk.controller on file-based, PowerFlex and RBD pools (without it the buses are the same as before, for example SATA for an older Windows UEFI Secure Boot VM with virtio); which new VMs and templates get the setting (deploy, import, template, volume, snapshot, backup); the start guard; the host capability.
  • Results (Linux, JDK 21): KVM plugin 1124 tests, server 4373, engine orchestration 260; 0 failures. Checkstyle clean.
  • Lab, first commit only (agent jar on one host, 24.0.0-SNAPSHOT, EL9, NFS): fresh imports of Windows Server 2019 and 2022 with UEFI Secure Boot booted from virtio on their first start, Secure Boot on. An existing imported Windows Server 2025 VM that had booted on SATA stopped with 0x7B on virtio, which led to this rework. Hot-plug of data disks was the same with and without the change (one disk, then "No more available PCI slots", see Unable to add more than 2 volumes or networks to a vm deployed from a UEFI image #11212); live migration between a patched and an unpatched host worked both ways.

Lab with this rework. A new test cloud built from stock main 04fa924 (1 management server, 2 AlmaLinux 9 KVM hosts, NFS primary storage), then the management server and one host upgraded to packages of this head (first a local build, then the ACSHomeBot packages, merged onto main 85ca17a); the other host stayed on stock packages. Guest: Windows Server 2025 with UEFI Secure Boot, imported from vSphere with rootDiskController=virtio and dataDiskController=virtio.

Case What happened Result
Existing VM, imported and booted on stock code (SATA), started on the upgraded host Stays on SATA, boots once, Secure Boot on Pass
VM imported after the upgrade, first start on the upgraded host Root and data disk on virtio, boots, Secure Boot on; the hidden setting is written Pass
VM imported after the upgrade, first start on the stock host Boots on SATA; the management server logs a WARN and removes the setting Pass
The same VM, next start on the upgraded host Stays on SATA, boots once, Secure Boot on Pass
Host capability Upgraded host reports host.honour.disk.controller=true, the stock host nothing Pass
On the ACSHomeBot packages: a new import, first start on the upgraded host; then live migration to the stock host Root and data disk on virtio, boots, Secure Boot on, the setting is written; after the live migration still virtio and the setting kept (the guard acts only at start) Pass
Documented switch of the existing SATA VM (steps in apache/cloudstack-documentation#704): registry value removed inside Windows, VM stopped, setting added with addResourceDetail, started on the upgraded host Root and data disk on virtio, boots once with no restart, Secure Boot on, disks and drive letters unchanged; the same after one more stop and start Pass

Not tested yet with this rework: Windows Server 2019/2022 and Linux guests, ISO installs, three or more disks, skip.force.disk.controller, storage other than NFS, templates registered after the upgrade, and a management server rollback.

Details

Bus per storage type, VMs with honour.disk.controller=true (without it: unchanged)

Pool type Root disk Data disks
File-based QCOW2 (NFS, local, SharedMountPoint) rootDiskController dataDiskController; Windows UEFI without it: the root disk bus
PowerFlex rootDiskController (before: the data disk bus) dataDiskController
RBD, Gluster rootDiskController dataDiskController (before: the root disk bus)
CLVM, RAW (Linstor, StorPool, ...) rootDiskController dataDiskController

ide on a UEFI VM gives sata (q35 has no IDE bus). osdefault and virtio-blk are not explicit. CD-ROMs are not changed (SATA on UEFI, IDE on BIOS).

Files: VmDetailConstants, Host (new names); LibvirtComputingResource (honour only with the setting), LibvirtReadyCommandWrapper (report the capability); AgentManagerImpl (store it); UserVmManagerImpl (set the setting at creation, follow backups, remove it on a host without the capability); TemplateAdapterBase (new KVM templates), TemplateManagerImpl (templates from a VM follow the VM).

Not covered: an operator who changes the controller of a VM that has the setting, after it booted on another bus, needs the registry fix first (documented). A full rollback of the management server and a new upgrade is not handled.

…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.
@andrijapanicsb

Copy link
Copy Markdown
Contributor Author

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
opposite. Secure Boot checks signatures, not the disk bus. As far as I can find, no log, error code or reproduction
was ever posted for the original observation (#3638, #4773, #10213).

What I tested

  • Windows Server 2025 on CloudStack with Secure Boot (q35, OVMF_CODE.secboot.fd with SMM, bootmode=secure), both
    disks on bus='virtio', CD-ROMs on SATA. Two runs; both booted, finished their first boot and ran the guest agent.
  • The same guest on KVM with the Microsoft keys enrolled, boot disk on virtio-blk: Confirm-SecureBootUEFI returned
    True inside Windows, on the first boot and after a reboot.
  • Windows Server 2019 on CloudStack UEFI with virtio disks (Secure Boot off): several runs, all fine.
  • virtio-win ships the same viostor build for Server 2016, 2019, 2022 and 2025. Only 2025 was run with Secure Boot on
    virtio.

When Windows really fails

None of these cases is caused by the disk bus:

  1. No virtio storage driver in the guest, for example Windows installed from Microsoft media onto SATA or IDE.
    Booting from virtio then stops with INACCESSIBLE_BOOT_DEVICE, with or without Secure Boot. That is a fair reason
    for a SATA default when no controller is set, not for overriding an explicit setting.

  2. Test-signed or self-built drivers. Secure Boot policy prevents enabling TESTSIGNING
    (Microsoft docs),
    so a setup that relied on test signing works only with Secure Boot off. The cause is the signature, not the bus.

  3. Drivers signed in a way the Windows edition does not accept. Microsoft describes attestation signing as "for
    testing on Windows 10 client only systems"
    (Microsoft docs).
    The same applies to certificate chains the guest does not trust, such as smbus.inf from virtio-win 0.1.285 on
    Server 2025 ("terminated in a root certificate which is not trusted"), and to older Windows releases that cannot
    validate SHA-2 signatures.

  4. Firmware keys that do not match the boot manager: the CA that signed it is missing from db, or the boot
    manager is revoked through dbx. This fails in the firmware, before any disk driver loads.

  5. The first boot after moving an existing guest from SATA to virtio.

    It is a first-boot sequencing issue, not a Secure Boot one.

For this PR: forcing SATA only covers case 1, and it overrides every operator who sets virtio on purpose. This
change keeps the SATA default when no controller is set, and honours rootDiskController and dataDiskController
when they are set, as is already the case for RBD and CLVM pools.

If there is a specific Windows version or scenario to check, I can run it and post the results.

@codecov

codecov Bot commented Nov 25, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 83.20611% with 22 lines in your changes missing coverage. Please review.
✅ Project coverage is 20.86%. Comparing base (04fa924) to head (99ac4dd).
⚠️ Report is 2 commits behind head on main.

Files with missing lines Patch % Lines
.../src/main/java/com/cloud/vm/UserVmManagerImpl.java 81.15% 2 Missing and 11 partials ⚠️
...ervisor/kvm/resource/LibvirtComputingResource.java 85.18% 2 Missing and 2 partials ⚠️
...n/java/com/cloud/template/TemplateManagerImpl.java 72.72% 0 Missing and 3 partials ⚠️
...java/com/cloud/agent/manager/AgentManagerImpl.java 86.66% 0 Missing and 2 partials ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##               main   #14844      +/-   ##
============================================
+ Coverage     20.83%   20.86%   +0.02%     
- Complexity    20973    21055      +82     
============================================
  Files          6053     6053              
  Lines        548955   549082     +127     
  Branches      73359    73392      +33     
============================================
+ Hits         114377   114567     +190     
+ Misses       421186   421116      -70     
- Partials      13392    13399       +7     
Flag Coverage Δ
uitests 3.86% <ø> (ø)
unittests 22.30% <83.20%> (+0.03%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@andrijapanicsb
andrijapanicsb marked this pull request as ready for review November 25, 2026 01:22
@andrijapanicsb

Copy link
Copy Markdown
Contributor Author

@ACSHomeBot package G

@andrijapanicsb andrijapanicsb added this to the 24.0 milestone Nov 25, 2026
@andrijapanicsb andrijapanicsb self-assigned this Nov 25, 2026
@ACSHomeBot

ACSHomeBot commented Nov 25, 2026 •

Copy link
Copy Markdown

Accepted: package kvm G for 7576ac9e81cf.

Planned: RPM + DEB, KVM SystemVM.

Status: Completed. Packaging results.

@ACSHomeBot

Copy link
Copy Markdown

Windows keeps only the storage driver it booted from ready for boot: it
demotes the others with StartOverride. A Windows VM that has booted on
SATA stops with INACCESSIBLE_BOOT_DEVICE when it is moved to virtio. So
honouring rootDiskController and dataDiskController on every existing VM
would break Windows UEFI VMs that carry rootDiskController=virtio (for
example from the VMware to KVM import) but have always run on SATA.

The KVM agent now honours the controller details only on VMs with the
honour.disk.controller=true detail. Without it, the buses stay as before
on every storage pool type.

The management server sets this detail, hidden, on a new KVM VM:
- when the deploy or import details name a controller (virtio, scsi,
  sata or ide); imports pass the bus the source disk used;
- when the controller comes from a template that has the detail: KVM
  templates registered or uploaded from this version on, and templates
  captured from a VM that has it;
- for a VM created from a backup, a volume or a snapshot, only when the
  source VM has it.

KVM agents report host.honour.disk.controller=true when they connect;
agents that do not report it get false. When a VM with the detail starts
on a host whose agent does not honour it (during a rolling upgrade), the
management server removes the detail for good, so the VM keeps the bus
that agent boots it from. SATA always boots on UEFI, because the CD-ROMs
keep the SATA driver in use.

skip.force.disk.controller is unchanged.
TemplateAdapterBase.addHonourDiskControllerDetail() added the detail to
the details map of the caller, which can be read-only (it failed with
UnsupportedOperationException in ExternalTemplateAdapterTest). It now
returns a copy with the detail. The host capability sync and the start
guard also write to copies of the host and VM details now.
@andrijapanicsb

Copy link
Copy Markdown
Contributor Author

@ACSHomeBot package G

@ACSHomeBot

ACSHomeBot commented Nov 25, 2026 •

Copy link
Copy Markdown

Accepted: package kvm G for 99ac4ddd3bd4.

Planned: RPM + DEB, KVM SystemVM.

Status: Failed.

Packaging results:

Result Artifact Platform Build Time
PASS RPM EL (EL8/9/10) 27 min
NOT RUN DEB Ubuntu, Debian n/a

Built package artifacts were retained locally, but no public repository was promoted.

Status: Package building failed.

@andrijapanicsb

Copy link
Copy Markdown
Contributor Author

@ACSHomeBot package G

@ACSHomeBot

ACSHomeBot commented Nov 25, 2026 •

Copy link
Copy Markdown

Accepted: package kvm G for 99ac4ddd3bd4.

Planned: RPM + DEB, KVM SystemVM.

Status: Completed. Packaging results.

@ACSHomeBot

Copy link
Copy Markdown

@andrijapanicsb
andrijapanicsb marked this pull request as ready for review November 26, 2026 04:25

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants