On Mon, Aug 23, 2021 at 05:07:03PM -0400, Eduardo Habkost wrote: > To give just one example: > > $ (echo 'info pci';echo quit;) | qemu-system-x86_64 -device virtio-net-pci > -device e1000e -monitor stdio | tail -n 20 > Bus 0, device 4, function 0: > Ethernet controller: PCI device 1af4:1000 > PCI subsystem 1af4:0001 > IRQ 0, pin A > BAR0: I/O at 0xffffffffffffffff [0x001e]. > BAR1: 32 bit memory at 0xffffffffffffffff [0x00000ffe]. > BAR4: 64 bit prefetchable memory at 0xffffffffffffffff [0x00003ffe]. > BAR6: 32 bit memory at 0xffffffffffffffff [0x0003fffe]. > id "" > Bus 0, device 5, function 0: > Ethernet controller: PCI device 8086:10d3 > PCI subsystem 8086:0000 > IRQ 0, pin A > BAR0: 32 bit memory at 0xffffffffffffffff [0x0001fffe]. > BAR1: 32 bit memory at 0xffffffffffffffff [0x0001fffe]. > BAR2: I/O at 0xffffffffffffffff [0x001e]. > BAR3: 32 bit memory at 0xffffffffffffffff [0x00003ffe]. > BAR6: 32 bit memory at 0xffffffffffffffff [0x0003fffe]. > id "" > (qemu) quit > $ (echo 'info pci';echo quit;) | qemu-system-x86_64 -device e1000e -device > virtio-net-pci -monitor stdio | tail -n 20 > Bus 0, device 4, function 0: > Ethernet controller: PCI device 8086:10d3 > PCI subsystem 8086:0000 > IRQ 0, pin A > BAR0: 32 bit memory at 0xffffffffffffffff [0x0001fffe]. > BAR1: 32 bit memory at 0xffffffffffffffff [0x0001fffe]. > BAR2: I/O at 0xffffffffffffffff [0x001e]. > BAR3: 32 bit memory at 0xffffffffffffffff [0x00003ffe]. > BAR6: 32 bit memory at 0xffffffffffffffff [0x0003fffe]. > id "" > Bus 0, device 5, function 0: > Ethernet controller: PCI device 1af4:1000 > PCI subsystem 1af4:0001 > IRQ 0, pin A > BAR0: I/O at 0xffffffffffffffff [0x001e]. > BAR1: 32 bit memory at 0xffffffffffffffff [0x00000ffe]. > BAR4: 64 bit prefetchable memory at 0xffffffffffffffff [0x00003ffe]. > BAR6: 32 bit memory at 0xffffffffffffffff [0x0003fffe]. > id "" > (qemu) quit > > > If the order of the -device arguments changes, the devices are assigned to > different PCI slots.
Thanks for the example. Initially I thought about this and didn't think it an issue (because serious users will always specify addr=XXX for -device; I thought libvirt always does that), but I do remember that guest OS could identify its hardware config with devfn number, so nmcli may mess up its config with before/after this change indeed.. I can use a custom sort to replace qsort() to guarantee that. Do you have other examples in mind that I may have overlooked, especially I may not be able to fix by a custom sort with only moving priority>=1 devices? Thanks, -- Peter Xu