Host device management

Libvirt provides management of both physical and virtual host devices (historically also referred to as node devices) like USB, PCI, SCSI, and network devices. This also includes various virtualization capabilities which the aforementioned devices provide for utilization, for example SR-IOV, NPIV, MDEV, DRM, etc.

The node device driver provides means to list and show details about host devices (virsh nodedev-list, virsh nodedev-info, and virsh nodedev-dumpxml), which are generic and can be used with all devices. It also provides the means to manage virtual devices. Persistently-defined virtual devices are only supported for mediated devices, while transient devices are supported by both mediated devices and NPIV (more info about NPIV)).

Persistent virtual devices are managed with virsh nodedev-define and virsh nodedev-undefine. Persistent devices can be configured to start manually or automatically using virsh nodedev-autostart. Inactive devices can be made active with virsh nodedev-start.

Transient virtual devices are started and stopped with the commands virsh nodedev-create and virsh nodedev-destroy.

Devices on the host system are arranged in a tree-like hierarchy, with the root node being called computer. The node device driver supports udev backend (HAL backend was removed in 6.8.0).

Details of the XML format of a host device can be found here. Of particular interest is the capability element, which describes features supported by the device. Some specific device types are addressed in more detail below.

Basic structure of a node device

<device>
  <name>pci_0000_00_17_0</name>
  <path>/sys/devices/pci0000:00/0000:00:17.0</path>
  <parent>computer</parent>
  <driver>
    <name>ahci</name>
  </driver>
  <capability type='pci'>
...
  </capability>
</device>