Skip to main content

Crate virtio_driver

Crate virtio_driver 

Source
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.

Structs§

DeviceStatus
Modified by both the driver and the device during lifecycle transitions.
VirtioBufferRef
Describes a buffer that can be submitted to a virtio queue.
VirtioFeatureBits
Configures virtio device operation.
VirtioMemoryRange
Describes a memory region accessible by a virtio device.
VirtioPciDevice
Manages a fully initialized virtio device using the PCI transport.
VirtioPciDeviceBuilder
Builder pattern instantiation for VirtioPciDevice.

Enums§

VirtioMemoryRangeAccess
Describes the way a device may access a VirtioMemoryRange.