Expand description
Infrastructure for drivers targeting virtio devices.
§Concepts
The virtio specification describes the interactions between a driver and a
device. The device is typically a virtualized hardware model implemented
by an emulator, such as QEMU or crosvm. The driver is a component of the
guest operating system running under the emulator. This module provides
VirtioPciDevice, a building block for drivers targeting virtio devices
using the PCI transport.
The behavior of a virtio device depends on a set of feature bits negotiated
between the driver and the device. VirtioFeatureBits covers the bits
common to all virtio device. Drivers are recommended to encode device
type-specific feature bits into types that follow the same pattern as
VirtioFeatureBits, and implement the From trait to provide
conversions between their types and VirtioFeatureBits.
Drivers primarily interact with devices by submitting buffers into queues.
One buffer can be modeled as a remote procedure call (RPC), in that it
conveys one unit of work that the device is expected to perform.
VirtioBufferRef describes one buffer, which is a list of memory ranges
modeled by VirtioMemoryRange. When the driver submits the buffer to
the device, it transfers ownership of the memory described by the buffer,
and asks the device to perform the work. The device returns the buffer
after it completes the work, transferring ownership of the memory back to
the driver.
§References
The documentation references the following documents.
- OASIS Virtual I/O Device (VIRTIO) specification - version
1.4, Committee Specification 01, dated 8 April 2026, referenced as
virtio. - PCI Local Bus Specification - Revision 3.0, dated
February 3 2004, referenced as
pci.
Structs§
- Device
Status - Modified by both the driver and the device during lifecycle transitions.
- Virtio
Buffer Ref - Describes a buffer that can be submitted to a virtio queue.
- Virtio
Feature Bits - Configures virtio device operation.
- Virtio
Memory Range - Describes a memory region accessible by a virtio device.
- Virtio
PciDevice - Manages a fully initialized virtio device using the PCI transport.
- Virtio
PciDevice Builder - Builder pattern instantiation for
VirtioPciDevice.
Enums§
- Virtio
Memory Range Access - Describes the way a device may access a
VirtioMemoryRange.