VirtIO

VirtIO vdevs can reduce virtualisation overhead.

QNX hypervisors currently support the VirtIO 1.0 specification. The benefits of VirtIO include:

For more information about VirtIO, including updates to VirtIO 1.1 and more recent, see Virtual I/O Device (VIRTIO) Version 1.0 on the Organization for the Advancement of Structured Information Standards (OASIS) web site; and Edouard Bugnion, Jason Nieh and Dan Tsafrir, Hardware and Software Support for Virtualization (Morgan & Claypool, 2017), pp. 96-100.

Implementing a VirtIO vdev

For this discussion, we will examine an implementation of VirtIO using virtio-blk (block device support for filesystems). Note that:

The hypervisor uses two mechanisms specific to its implementation of the virtio-blk device:

For more information about what to do in a guest when implementing VirtIO, see Discovering and connecting VirtIO devices in the Using a QNX Hypervisor System chapter.

Guest to hardware with virtqueues

Assuming a Linux guest, the VirtIO virtio-blk implementation in a QNX hypervisor system works as follows:

  1. A VM is configured with a virtio-blk device; the qvm process instance will load the vdev-virtio-blk.so shared object.

    This vdev includes a delayed option that can be used to reduce boot times from a cold boot. It lets the VM launch and the guest start without confirming the presence of the hardware device. For example, the guest can start without the underlying block device specified by the virtio-blk hostdev being available (see vdev virtio-blk in the Virtual Device Reference chapter).

  2. The qvm process instance that will host the guest reads its configuration file and loads the vdev-virtio-blk.so.

    This vdev's hostdev (host device) option specifies the mountpoint/file path that will be opened and passed to the guest as /dev/vda. For example, the hostdev option can pass the path /dev/hd1t131 to the guest as /dev/vda. You can specify multiple hostdev options for a guest.

  3. The qvm process hosting the guest launches, and the guest starts.
  4. After the guest opens the locations specified by the vdev's hostdevoptions, file descriptors refer to each of these locations. The hosting qvm process instance owns these file descriptors, but the QNX hypervisor microkernel manages them.
Figure 1. Data is passed from virtqueues in the guest to the hardware. Note that the guest and the qvm process share the same address space.

The guest can now read and write to hardware. For example, on a Linux application read:

Similarly, on a Linux application write:

For both reading and writing, the Linux filesystem cache may be used.