Document navigation

Device Virtualization

There are three main approaches to device virtualization: device emulation, paravirtualized devices, and device passthrough.

Device Emulation

Device emulation uses QEMU device models to emulate interfaces presented by physical devices. The guest operating system can therefore use its native drivers. Emulated devices provide broad compatibility but support only the functions implemented by their software models and generally have lower performance than paravirtualized or passthrough devices.

See Figure 1 for an illustration.
Figure 1. Device Emulation


Paravirtualized Devices

Paravirtualized devices implement frontend and backend drivers. Utilizing a frontend driver in the virtual machine, requests are directly sent to a backend driver on the host through a transaction-based communication mechanism, significantly reducing context switching overhead and improving performance over full device emulation. However, since the Virtio backend driver is still implemented in QEMU, the I/O processing path involves multiple switches between user space and kernel space. To further enhance performance, the functionality of the Virtio backend driver can be moved into the kernel space. This implementation is known as the Vhost-kernel backend. With this change, data transmission requires only a single switch from user space to kernel space, thereby improving performance.

As technology evolves, moving data processing to user space provides greater flexibility. Consequently, modifications to the original Vhost architecture led to the Vhost-user backend, which works with relevant user-space libraries from DPDK and SPDK to further boost performance.

See Figure 2 for an illustration.
Figure 2. Paravirtualized Devices


Device Passthrough

Device passthrough uses hardware-assisted I/O virtualization to map a physical PCI or PCIe device directly into a VM address space. The VM operates the device through its native driver and can achieve near-native performance. A passed-through device is dedicated to one VM and cannot be shared with other VMs.

See Figure 3 for an illustration.
Figure 3. Device Passthrough


SR-IOV is an extension to the PCIe specification defined by the PCI-SIG. Its purpose is to provide a standardized specification for granting virtual machines independent memory spaces, interrupts, and DMA data streams. SR-IOV enables a single physical PCIe device (Physical Function, PF) to be virtualized into multiple virtual PCIe devices (Virtual Functions, VFs). These VFs can then be passed through directly to virtual machines using device passthrough technology. This allows a single physical PCIe device to support multiple virtual machines.

See Figure 4 for an illustration.
Figure 4. SR-IOV