Skip to content

Instantly share code, notes, and snippets.

@stephenfin
Created March 23, 2021 18:20
Show Gist options
  • Save stephenfin/0ff343eec42c57b0482f63306e755d24 to your computer and use it in GitHub Desktop.
Save stephenfin/0ff343eec42c57b0482f63306e755d24 to your computer and use it in GitHub Desktop.
libvirt with advanced device types

mdev

$ virsh nodedev-list --tree
  ...
  +- pci_0000_00_02_0
  |   |
  |   +- pci_0000_04_00_0
  |       |
  |       +- mdev_69f7daf5_c114_4017_a53f_6367c04cb4f3
  ...
$ virsh nodedev-dumpxml pci_0000_04_00_0
<device>
  <name>pci_0000_04_00_0</name>
  <path>/sys/devices/pci0000:00/0000:00:02.0/0000:04:00.0</path>
  <parent>pci_0000_00_02_0</parent>
  <driver>
    <name>nvidia</name>
  </driver>
  <capability type='pci'>
    <class>0x030200</class>
    <domain>0</domain>
    <bus>4</bus>
    <slot>0</slot>
    <function>0</function>
    <product id='0x1eb8'>TU104GL [Tesla T4]</product>
    <vendor id='0x10de'>NVIDIA Corporation</vendor>
    <capability type='virt_functions' maxCount='16'/>
    <capability type='mdev_types'>
      <type id='nvidia-223'>
        <name>GRID T4-2B</name>
        <deviceAPI>vfio-pci</deviceAPI>
        <availableInstances>0</availableInstances>
      </type>
      <type id='nvidia-231'>
        <name>GRID T4-2Q</name>
        <deviceAPI>vfio-pci</deviceAPI>
        <availableInstances>0</availableInstances>
      </type>
      <type id='nvidia-228'>
        <name>GRID T4-8A</name>
        <deviceAPI>vfio-pci</deviceAPI>
        <availableInstances>0</availableInstances>
      </type>
      <type id='nvidia-320'>
        <name>GRID T4-8C</name>
        <deviceAPI>vfio-pci</deviceAPI>
        <availableInstances>0</availableInstances>
      </type>
      <type id='nvidia-226'>
        <name>GRID T4-2A</name>
        <deviceAPI>vfio-pci</deviceAPI>
        <availableInstances>0</availableInstances>
      </type>
      <type id='nvidia-234'>
        <name>GRID T4-16Q</name>
        <deviceAPI>vfio-pci</deviceAPI>
        <availableInstances>0</availableInstances>
      </type>
      <type id='nvidia-319'>
        <name>GRID T4-4C</name>
        <deviceAPI>vfio-pci</deviceAPI>
        <availableInstances>3</availableInstances>
      </type>
      <type id='nvidia-224'>
        <name>GRID T4-2B4</name>
        <deviceAPI>vfio-pci</deviceAPI>
        <availableInstances>0</availableInstances>
      </type>
      <type id='nvidia-252'>
        <name>GRID T4-1B4</name>
        <deviceAPI>vfio-pci</deviceAPI>
        <availableInstances>0</availableInstances>
      </type>
      <type id='nvidia-232'>
        <name>GRID T4-4Q</name>
        <deviceAPI>vfio-pci</deviceAPI>
        <availableInstances>0</availableInstances>
      </type>
      <type id='nvidia-222'>
        <name>GRID T4-1B</name>
        <deviceAPI>vfio-pci</deviceAPI>
        <availableInstances>0</availableInstances>
      </type>
      <type id='nvidia-230'>
        <name>GRID T4-1Q</name>
        <deviceAPI>vfio-pci</deviceAPI>
        <availableInstances>0</availableInstances>
      </type>
      <type id='nvidia-229'>
        <name>GRID T4-16A</name>
        <deviceAPI>vfio-pci</deviceAPI>
        <availableInstances>0</availableInstances>
      </type>
      <type id='nvidia-321'>
        <name>GRID T4-16C</name>
        <deviceAPI>vfio-pci</deviceAPI>
        <availableInstances>0</availableInstances>
      </type>
      <type id='nvidia-227'>
        <name>GRID T4-4A</name>
        <deviceAPI>vfio-pci</deviceAPI>
        <availableInstances>0</availableInstances>
      </type>
      <type id='nvidia-225'>
        <name>GRID T4-1A</name>
        <deviceAPI>vfio-pci</deviceAPI>
        <availableInstances>0</availableInstances>
      </type>
      <type id='nvidia-233'>
        <name>GRID T4-8Q</name>
        <deviceAPI>vfio-pci</deviceAPI>
        <availableInstances>0</availableInstances>
      </type>
    </capability>
    <iommuGroup number='17'>
      <address domain='0x0000' bus='0x04' slot='0x00' function='0x0'/>
    </iommuGroup>
    <numa node='0'/>
    <pci-express>
      <link validity='cap' port='0' speed='8' width='16'/>
      <link validity='sta' speed='2.5' width='8'/>
    </pci-express>
  </capability>
</device>
$ virsh nodedev-dumpxml mdev_69f7daf5_c114_4017_a53f_6367c04cb4f3
<device>
  <name>mdev_69f7daf5_c114_4017_a53f_6367c04cb4f3</name>
  <path>/sys/devices/pci0000:00/0000:00:02.0/0000:04:00.0/69f7daf5-c114-4017-a53f-6367c04cb4f3</path>
  <parent>pci_0000_04_00_0</parent>
  <driver>
    <name>vfio_mdev</name>
  </driver>
  <capability type='mdev'>
    <type id='nvidia-319'/>
    <iommuGroup number='62'/>
  </capability>
</device>

vDPA

$ virsh nodedev-list --tree
  +- pci_0000_00_02_2
  |   |
  |   +- pci_0000_06_00_2
  |   |   |
  |   |   +- net_enp6s0f0v0_52_54_00_8e_a4_14
  |   |   +- vdpa_vdpa0
$ virsh nodedev-dumpxml pci_0000_06_00_0
<device>
  <name>pci_0000_06_00_0</name>
  <path>/sys/devices/pci0000:00/0000:00:02.2/0000:06:00.0</path>
  <parent>pci_0000_00_02_2</parent>
  <driver>
    <name>mlx5_core</name>
  </driver>
  <capability type='pci'>
    <class>0x020000</class>
    <domain>0</domain>
    <bus>6</bus>
    <slot>0</slot>
    <function>0</function>
    <product id='0x101d'>MT2892 Family [ConnectX-6 Dx]</product>
    <vendor id='0x15b3'>Mellanox Technologies</vendor>
    <capability type='virt_functions' maxCount='8'>
      <address domain='0x0000' bus='0x06' slot='0x00' function='0x2'/>
      <address domain='0x0000' bus='0x06' slot='0x00' function='0x3'/>
      <address domain='0x0000' bus='0x06' slot='0x00' function='0x4'/>
      <address domain='0x0000' bus='0x06' slot='0x00' function='0x5'/>
    </capability>
    <iommuGroup number='22'>
      <address domain='0x0000' bus='0x06' slot='0x00' function='0x0'/>
    </iommuGroup>
    <numa node='0'/>
    <pci-express>
      <link validity='cap' port='0' speed='16' width='8'/>
      <link validity='sta' speed='8' width='8'/>
    </pci-express>
  </capability>
</device>
$ virsh nodedev-dumpxml pci_0000_06_00_2
<device>
  <name>pci_0000_06_00_2</name>
  <path>/sys/devices/pci0000:00/0000:00:02.2/0000:06:00.2</path>
  <parent>pci_0000_00_02_2</parent>
  <driver>
    <name>mlx5_core</name>
  </driver>
  <capability type='pci'>
    <class>0x020000</class>
    <domain>0</domain>
    <bus>6</bus>
    <slot>0</slot>
    <function>2</function>
    <product id='0x101e'>ConnectX Family mlx5Gen Virtual Function</product>
    <vendor id='0x15b3'>Mellanox Technologies</vendor>
    <capability type='phys_function'>
      <address domain='0x0000' bus='0x06' slot='0x00' function='0x0'/>
    </capability>
    <iommuGroup number='99'>
      <address domain='0x0000' bus='0x06' slot='0x00' function='0x2'/>
    </iommuGroup>
    <numa node='0'/>
    <pci-express>
      <link validity='cap' port='0' speed='16' width='8'/>
      <link validity='sta' width='0'/>
    </pci-express>
  </capability>
</device>
$ virsh nodedev-dumpxml vdpa_vdpa0
<device>
  <name>vdpa_vdpa0</name>
  <path>/sys/devices/pci0000:00/0000:00:02.2/0000:06:00.2/vdpa0</path>
  <parent>pci_0000_06_00_2</parent>
  <driver>
    <name>vhost_vdpa</name>
  </driver>
  <capability type='vdpa'>
    <chardev>/dev/vhost-vdpa-0</chardev>
  </capability>
</device>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment