On 11/3/22 6:35 AM, longguang.yue wrote:
Hi, all
I have add two pcie-to-pci-bridge controllers, how hotplug devices
onto this two controllers? and libvirt knows to plug onto pci-bridge
when there are no pcie-ports.
defaultly libvirt plugs devices onto pcie-port.
Do you mean you want hotplugged devices to be placed on the
pcie-to-pci-bridge even though there are unused pci-root-ports?
You can force a new device to be hotplugged to a particular slot of a
particular controller by including the <address> element in the XML of
the device you attach - whatever controller/slot/function you specify
there is what libvirt will use (practically speaking the function must
be 0).
My recollection is that, *if the device is a conventional PCI device
(and not a PCIe device) then libvirt will anyway attempt to find a an
open conventional PCI slot, which would be found only on the
pcie-to-pci-bridge. However, very few devices are actually conventional
PCI, so this will very rarely happen automatically (I haven't looked at
that code in a long time, and retain no specific memory, but I think the
only emulated device that is conventional PCI is a watchdog device or
something)
So, if libvirt is selecting a pcie-root-port to plug in a device, that's
because the device is a PCIe device. If you want to force it to do
otherwise, you'll need to manually specify the address (just set "bus"
of the address to the "index" of the controller, set "slot" to an
unoccupied slot (1-31), and set domain and function to 0).