Repository navigation
In review
Description
problem
libvirt refuses the hot-plug ("PCI controller with index='0' doesn't support hotplug"), and the API caller only gets "null job execution result".
2026-12-01 11:19:19,553 ERROR [c.c.a.ApiAsyncJobDispatcher] (API-Job-Executor-73:[ctx-fc8f8c9c, job-692]) (logid:62efae87) Unexpected exception while executing org.apache.cloudstack.api.command.admin.vm.AddNicToVMCmdByAdmin java.lang.RuntimeException: null job execution result
at com.cloud.vm.VirtualMachineManagerImpl.addVmToNetwork(VirtualMachineManagerImpl.java:4577)
at com.cloud.vm.UserVmManagerImpl.addNicToVirtualMachine(UserVmManagerImpl.java:1552)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:569)
at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:344)
Cause - seems to be regression from #12826 "KVM: assign the hot-plugged NIC the next PCI slot above existing NICs (monotonic interface naming)"
- The wrapper now pins bus='0x00' plus a computed slot (LibvirtVMDef.java:1703, LibvirtPlugNicCommandWrapper.java:87).
- On q35, bus 0 is pcie-root, which doesn’t support hot-plug.
- Before this change, libvirt picked a free pcie-root-port.
Scope - any running UEFI VM (Windows 11 and Secure Boot guests included). BIOS/i440fx VMs are fine: concurrent adds got distinct device ids and slots (0x07, 0x08), and a re-added NIC got 0x09, above the existing ones.
versions
4.22.2 RC2
The steps to reproduce the bug
- Deploy with boottype=UEFI bootmode=LEGACY (or SECURE) then addNicToVirtualMachine.
- The API caller only gets null job execution result.
- The agent log shows:
LibvirtPlugNicCommandWrapper Assigning PCI slot 0x03 to hot-plugged NIC
Plug Nic failed due to org.libvirt.LibvirtException: XML error: The device at PCI address 0000:00:03.0 requires
hotplug capability, but the PCI controller with index='0' doesn't support hotplug
What to do about it?
No response
Activity
Alpha162 commentedon Dec 2, 2026
I reproduced this on a two-host lab running a build of
mainat 58fda71 (Ubuntu 24.04, libvirt 10.0.0, QEMU 8.2.2, OVMF 2024.02). A UEFI VM failsaddNicToVirtualMachinewith "null job execution result", and the agent logs the samePCI controller with index='0' doesn't support hotplugerror. A BIOS VM on the same build works.The pinned slot is always on bus 0x00. On i440fx that's
pci-root, which takes hot-plugged devices. On q35, bus 0 ispcie-root, which doesn't, so any slot we pick there fails. #12826 is on 4.20 as well, so 4.20.4 would ship this too.A small fix that worked for me: in
findNextAvailablePciSlot, return null (let libvirt choose) when the domain's PCI controller index 0 ispcie-root. libvirt then puts the NIC on a freepcie-root-port, as it did before #12826. i440fx keeps the monotonic slot logic unchanged.What I tested with that change on the lab:
LibvirtPlugNicCommandWrapperTestTwo things worth knowing:
pcie-root-portper hot-plugged NIC, which seems a bigger change than a fix for a release blocker should be.@sureshanaparti I see you've picked this up. I'm happy to open a PR against 4.20 with the change and tests if that helps, or to test yours on the same lab.
sureshanaparti commentedon Dec 2, 2026
thanks @Alpha162 , I created the fix here: #14948, can you review / verify it.