Repository navigation
KVM: let libvirt place the hot-plugged NIC on q35 guests - #14948
sureshanaparti wants to merge 1 commit into
Conversation
There was a problem hiding this comment.
🟢 Approval recommended
No active review issues remain, and the change includes targeted tests for q35 detection and fallback slot selection.
No open issues 🎉
What changed in this PR
Fixes KVM NIC hot-plugging for q35/UEFI guests by letting libvirt select a hot-pluggable PCIe root port while preserving deterministic slot assignment for i440fx guests.
Changes:
- Detects
pcie-rootcontrollers and skips explicit slot assignment. - Adds unit coverage for q35 detection and fallback behavior.
| File | Description |
|---|---|
| plugins/hypervisors/kvm/src/test/java/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtPlugNicCommandWrapperTest.java | Adds tests for q35 PCIe root detection and slot-selection fallback. |
| plugins/hypervisors/kvm/src/main/java/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtPlugNicCommandWrapper.java | Detects PCIe root-complex guests and delegates NIC placement to libvirt while retaining i440fx slot assignment. |
Review effort: Lite
|
@blueorangutan package |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## 4.22 #14948 +/- ##
=========================================
Coverage 18.34% 18.34%
- Complexity 16670 16675 +5
=========================================
Files 5939 5939
Lines 537814 537831 +17
Branches 65937 65940 +3
=========================================
+ Hits 98637 98663 +26
+ Misses 427953 427944 -9
Partials 11224 11224
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:
|
|
one optional change we can make in "findNextAvailablePciSlot" method to parse the domxml once and pass it to both hasPcieRootComplex and getUsedPciSlots |
Alpha162
left a comment
There was a problem hiding this comment.
Thanks @sureshanaparti. I built this PR's diff and ran it on the same lab as #14930, swapping only the KVM plugin jar on one host. That lab's agent is a build of main at 58fda71 plus my NUMA change from #14921, which doesn't touch the NIC plug path.
| Case | Result |
|---|---|
| UEFI VM, add a NIC with the original jar (control) | Fails with the same PCI controller with index='0' doesn't support hotplug error |
| UEFI VM, add a NIC with this PR | Works. The NIC lands on a free root port (bus 0x08) |
| Same VM, add a second NIC with no spare root port left | Fails with libvirt's "No more available PCI slots", same as before #12826 |
| Same VM after a stop and start, add a NIC | Works (bus 0x09) |
| BIOS VM with hot-plugged NICs on slots 0x08 and 0x09, remove the first and add it again | Works, and it comes back on 0x0a, so the ordering from #12826 still holds |
LibvirtPlugNicCommandWrapperTest |
10 pass |
The code reads well to me, and it's the same approach as the patch I tested on #14930. LGTM.
One question: #12826 is on 4.20 as well. Should this go to 4.20 too, so a later 4.20 release doesn't pick up the same regression?
thanks @Alpha162 for testing. we can keep 4.22 for now, in case required in 4.20, we can back port as we cannot merge forward 4.20 to 4.22 in the current state as 4.22 is frozen for release. also, note that 4.20.x EOL on 1 Jan 2027 and not sure if any 4.20.x further release before that. |
|
@blueorangutan package |
|
@sudo87 a [SL] Jenkins job has been kicked to build packages. It will be bundled with KVM, XenServer and VMware SystemVM templates. I'll keep you posted as I make progress. |
Description
This PR, for KVM, lets libvirt place the hot-plugged NIC on q35 guests.
Since #12826 the hot-plugged NIC is pinned to a slot on bus 0 so the guest sees a monotonic interface order. On a UEFI guest the machine type is q35, where bus 0 is the PCIe root complex and does not accept hot-plugged devices, so libvirt refuses the attach and addNicToVirtualMachine fails for every running UEFI VM.
When the domain XML carries a pcie-root controller, return no slot and let libvirt pick a free root port, as it did before #12826. i440fx guests keep the monotonic slot selection.
Fixes #14930
Types of changes
Feature/Enhancement Scale or Bug Severity
Feature/Enhancement Scale
Bug Severity
Screenshots (if appropriate):
How Has This Been Tested?
How did you try to break this feature and the system with this change?