Configuration files that describe VMware virtual machines (files with the .vmx extension) include an encoding of the persistent PCI slot that PCI or PCIe virtual devices such as NICs, HBAs, etc will be plugged into by the hypervisor when the virtual machine is powered on.
This article describes the internal algorithm used to map those persistent PCI slot numbers to the PCI bus topology visible within the guest OS. This description may aid in mapping multi-instance virtual devices (for example, multiple VMXNET3 vNICs) in the guest OS to the virtual device instance in the virtual machine's configuration.
VMware vSphere ESXi
Func is always 0. Legacy PCI devices have multiple devices on the same bus, while PCIe (being point-to-point) has one PCIe device on a bus.
The mapping algorithm can be described using these steps:
# egrep "ethernet4.pciSlotNumber" /path/to/VM/VM.vmx
ethernet4.pciSlotNumber = "1216"
FFF.BBBBB.DDDDD
001.00110.00000 [1216 = 0x4C0]BBBBB is 00000, the device is on the Primary PCI bus, at Bus:Dev.Func 0:DDDDD.0:# egrep "pciBridge0.pciSlotNumber" /path/to/VM/VM.vmx
pciBridge0.pciSlotNumber = "17"
000.00000.10001 [17 = 0x11]Bus:Dev.Func = 00h:11h.00h
BBBBB is non-zero, the device is on a Secondary PCI bus. To look up the PCI Bridge device, use BBBBB - 1. ethernet4 at 1216, BBBBB = 00110.PCI Bridge Device = BBBBB - 1 = 5 (Virtual device name "pciBridge5")# egrep "pciBridge5.pciSlotNumber" /path/to/VM/VM.vmx
pciBridge5.pciSlotNumber = "22"
FFF.BBBBB.DDDDD
000.00000.10110 [22 = 0x16]FFF from step 2 and DDDDD from step 6 yields the Dev.Func of the PCI Bridge:Bus:Dev.Func of PCI Bridge = 00h:16h:01h
(Dev = 0x16 from step 6, Func = 0x1 from step 2])BBBBB for the bridge is non-zero, repeat the process from step 4 to locate the parent bridge. Dev.Func DDDDD.0 from step 2:ethernet4 on secondary bus behind 00h:16h:01h at Dev.Func 00h:0h
Notes:
DDDDD encoding will usually be 0.DDDDD encoding will specify which device on the secondary PCI bus they are on.