]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
conf: auto-add a pcie-root-port when needed while plugging in pcie-to-pci-bridge
authorLaine Stump <laine@redhat.com>
Mon, 25 Aug 2025 03:32:39 +0000 (23:32 -0400)
committerLaine Stump <laine@redhat.com>
Wed, 10 Sep 2025 17:12:41 +0000 (13:12 -0400)
This will almost surely never come up during any normal operation[*],
which is likely why this wasn't done when pcie-to-pci-bridge support
was added back in the before-fore times. It's pretty simple to support
though - a pcie-to-pci-bridge plugs into a pcie-root-port just like
any other pcie device, and if there isn't an open slot on an existing
pcie-root-port, we can just add one.

([*] in real life, a pcie-to-pci-bridge is only auto-added by libvirt
itself, while this function is dealing with the followup to *user
added* devices. Also each pcie-to-pci-bridge has 32 slots, and it's
unlikely a domain with pcie support would be wanting more than 32
conventional PCI (i.e. not PCIe) devices)

Signed-off-by: Laine Stump <laine@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
src/conf/domain_addr.c

index ef1b2bd69aa37e4791e3c92350fd5552475b3704..6aa5ac1b9facb3b9daaac66c4e57f58d02db5c6a 100644 (file)
@@ -691,7 +691,8 @@ virDomainPCIAddressSetGrow(virDomainPCIAddressSet *addrs,
             }
         }
     } else if (flags & (VIR_PCI_CONNECT_TYPE_PCIE_DEVICE |
-                        VIR_PCI_CONNECT_TYPE_PCIE_SWITCH_UPSTREAM_PORT)) {
+                        VIR_PCI_CONNECT_TYPE_PCIE_SWITCH_UPSTREAM_PORT |
+                        VIR_PCI_CONNECT_TYPE_PCIE_TO_PCI_BRIDGE)) {
         model = VIR_DOMAIN_CONTROLLER_MODEL_PCIE_ROOT_PORT;
     } else {
         /* The types of devices that we can't auto-add a controller for: