HowTo Map VF Number and the VM in SR-IOV Mode

Version 6

    This post shows how to correlate the VM and it's VF number when working in SR-IOV mode.

     

    References

     

    There are two options for the VF mode:

    • probed VF: The hypervisor will see the interface
    • non probed VF: The VM will see a PCI device


    There are several options to find the PCI device attached to the VM in non probed VF mode, here is one option:

     

    1. Use the following command "virsh dumpxml <VM ID>"

    For example:

    #virsh dumpxml vm42

    ...

    <hostdev mode='subsystem' type='pci' managed='yes'>

    <source>

    <address domain='0x0000' bus='0x86' slot='0x01' function='0x0'/> // this is the PCI ID: 86:01.0

    </source>

    <alias name='hostdev0'/>

    <address type='pci' domain='0x0000' bus='0x00' slot='0x07' function='0x0'/>

    </hostdev>


    2. Use lspci command to find Mellanox PCI ID (for example 86:01:0)

    #lspci | grep Mellanox

    86:00.0 Network controller: Mellanox Technologies MT27520 Family [ConnectX-3 Pro]

    86:00.1 Network controller: Mellanox Technologies MT27500 Family [ConnectX-3 Virtual Function]

    86:00.2 Network controller: Mellanox Technologies MT27500 Family [ConnectX-3 Virtual Function]

    86:00.3 Network controller: Mellanox Technologies MT27500 Family [ConnectX-3 Virtual Function]

    86:00.4 Network controller: Mellanox Technologies MT27500 Family [ConnectX-3 Virtual Function]

    86:00.5 Network controller: Mellanox Technologies MT27500 Family [ConnectX-3 Virtual Function]

    86:00.6 Network controller: Mellanox Technologies MT27500 Family [ConnectX-3 Virtual Function]

    86:00.7 Network controller: Mellanox Technologies MT27500 Family [ConnectX-3 Virtual Function]

    86:01.0 Network controller: Mellanox Technologies MT27500 Family [ConnectX-3 Virtual Function]

     

    3. Find the mapping of the VF to the PCI device (for example, which VF is mapped to PCI 86:01.0)

    #ls -l /sys/class/net/eth4/device/virtfn*   // eth4 is the device name).

     

    lrwxrwxrwx  1 root root       0 Aug 12 16:28 virtfn0 -> ../0000:86:00.1

    lrwxrwxrwx  1 root root       0 Aug 12 16:28 virtfn1 -> ../0000:86:00.2

    lrwxrwxrwx  1 root root       0 Aug 12 16:28 virtfn2 -> ../0000:86:00.3

    lrwxrwxrwx  1 root root       0 Aug 12 16:28 virtfn3 -> ../0000:86:00.4

    lrwxrwxrwx  1 root root       0 Aug 12 16:28 virtfn4 -> ../0000:86:00.5

    lrwxrwxrwx  1 root root       0 Aug 12 16:28 virtfn5 -> ../0000:86:00.6

    lrwxrwxrwx  1 root root       0 Aug 12 16:28 virtfn6 -> ../0000:86:00.7

    lrwxrwxrwx  1 root root       0 Aug 12 16:28 virtfn7 -> ../0000:86:01.0

     

    In this example, it is VF7.

     

    In case you use probed VFs, you can simply find it using ethtool command:

    # ethtool -i eth6

    driver: mlx4_en

    version: 2.3-0.1.0 (Aug  3 2014)

    firmware-version: 2.32.1078

    bus-info: 0000:86:00.1   

    supports-statistics: yes

    supports-test: yes

    supports-eeprom-access: no

    supports-register-dump: no 

    supports-priv-flags: yes