Repository navigation
kvm: add PCIe root ports to x86 q35 guests so volumes and NICs can be hot-plugged - #14867
Draft
andrijapanicsb wants to merge 1 commit into
Draft
andrijapanicsb wants to merge 1 commit into
andrijapanicsb wants to merge 1 commit into
Conversation
… hot-plugged x86 KVM guests with a q35 machine type (all UEFI guests, and guests with kvm.guest.os.machine.type=q35 or a versioned pc-q35-* type) now always get a pcie-root controller and 28 pcie-root-port controllers, appended after all devices without index or address, as aarch64/s390x guests already get 32 (apache#5193). The count is fixed; there is no setting. NIC hot-plug no longer pins the NIC to a bus 0 slot on q35, where libvirt refuses it because the PCIe root complex is not hot-pluggable. Fixes apache#11212
andrijapanicsb
requested review from
abh1sar,
kiwiflyer,
weizhouapache and
wido
November 25, 2026 19:50
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #14867 +/- ##
============================================
+ Coverage 20.83% 20.93% +0.10%
- Complexity 20973 21172 +199
============================================
Files 6053 6057 +4
Lines 548955 549598 +643
Branches 73359 73483 +124
============================================
+ Hits 114377 115076 +699
+ Misses 421186 421074 -112
- Partials 13392 13448 +56
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:
|
Contributor
Author
|
@ACSHomeBot package G |
|
Accepted: Planned: RPM + DEB, KVM SystemVM. Status: Completed. Packaging results. |
Packaging results:
Test packages are available at:
|
This branch has not been deployed
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Fixes #11212
In short
On KVM, a UEFI (q35) guest can hot-plug only one more disk or NIC, then the next attach fails with
No more available PCI slots. This gives every x86 q35 guest 28 empty PCIe root ports at start, as aarch64/s390x guests already get 32 (#5193), so disks and NICs can be hot-plugged.Change
LibvirtComputingResource: an x86 guest with a q35 machine type (q35,pc-q35-*) gets apcie-rootcontroller and 28pcie-root-portcontrollers. The count is fixed, with no setting.LibvirtVMDef: these controllers go after all devices, withoutindexor<address>, so libvirt places every existing device exactly where it did before. The extra ports are the empty ones after them.LibvirtPlugNicCommandWrapper: on q35, a hot-plugged NIC is no longer pinned to a bus 0 slot (since KVM: assign the hot-plugged NIC the next PCI slot above existing NICs (monotonic interface naming) #12826). libvirt refuses that on q35, because the PCIe root complex isn't hot-pluggable.i440fx (
pc), LXC, aarch64 and s390x guests get exactly the same XML as before. 28 is also the maximum OpenStack Nova allows fornum_pcie_ports.Firmware note: OVMF before May 2023
OVMF before edk2 commit 27727338b2c0 reserves I/O space for every empty hot-plug port, and only about 10 ports get resources. On such hosts, a Windows guest takes the first hot-plugged disk after a start. The following ones show Device Manager code 10 until the guest is rebooted, then they work. Linux guests and NICs aren't affected. Today the second hot-plug fails outright, so this is still an improvement.
Fixed firmware: EL 9.3 and later (
edk2-ovmf-20230524-3.el9backports the fix) and Ubuntu 24.04. Affected, by package version: EL8, EL9.0-9.2, Ubuntu 22.04, Debian 12.Tests
Unit tests (JDK 17):
mvn -pl plugins/hypervisors/kvm test, 1115 tests, 0 failures, 0 Checkstyle violations.Lab: AlmaLinux 9.1 KVM hosts, libvirt 8.5.0, QEMU 7.0. The agent was built from an October 24.0.0-SNAPSHOT commit (d3f0700) with the same change. That commit predates #12826, so change 3 wasn't needed there.
Not tested yet
main. Planned; results will follow here.Related: #14844 (explicit disk controllers). With it, more Windows UEFI guests use virtio-blk disks, one root port each.