Expand description
Virtio Vhost Backend Drivers
Virtio devices use virtqueues to transport data efficiently. The first generation of virtqueue is a set of three different single-producer, single-consumer ring structures designed to store generic scatter-gather I/O. The virtio specification 1.1 introduces an alternative compact virtqueue layout named “Packed Virtqueue”, which is more friendly to memory cache system and hardware implemented virtio devices. The packed virtqueue uses read-write memory, that means the memory will be both read and written by both host and guest. The new Packed Virtqueue is preferred for performance.
Vhost is a mechanism to improve performance of Virtio devices by delegate data plane operations to dedicated IO service processes. Only the configuration, I/O submission notification, and I/O completion interruption are piped through the hypervisor. It uses the same virtqueue layout as Virtio to allow Vhost devices to be mapped directly to Virtio devices. This allows a Vhost device to be accessed directly by a guest OS inside a hypervisor process with an existing Virtio (PCI) driver.
The initial vhost implementation is a part of the Linux kernel and uses ioctl interface to communicate with userspace applications. Dedicated kernel worker threads are created to handle IO requests from the guest.
Later Vhost-user protocol is introduced to complement the ioctl interface used to control the vhost implementation in the Linux kernel. It implements the control plane needed to establish virtqueues sharing with a user space process on the same host. It uses communication over a Unix domain socket to share file descriptors in the ancillary data of the message. The protocol defines 2 sides of the communication, frontend and backend. Frontend is the application that shares its virtqueues. Backend is the consumer of the virtqueues. Frontend and backend can be either a client (i.e. connecting) or server (listening) in the socket communication.
Re-exports§
pub use message::VHOST_USER_F_PROTOCOL_FEATURES;
pub use connection::Connection;
pub use message::BackendReq;
pub use message::FrontendReq;
Modules§
- backend 🔒Common traits and structs for vhost-user backend drivers.
- Common data structures for listener and connection.
- Define communication messages for the vhost-user protocol.
- sys 🔒A wrapper module for platform dependent code.
- Unix specific code that keeps rest of the code in the crate platform independent.
Structs§
- Client for a vhost-user device. The API is a thin abstraction over the vhost-user protocol.
- Handles requests from a vhost-user connection by dispatching them to [Backend] methods.
- Client for a vhost-user frontend. Allows a backend to send requests to the frontend.
- Handles requests from a vhost-user backend connection by dispatching them to [Frontend] methods.
- Memory region configuration data.
- Vring configuration data.
Enums§
- Errors for vhost-user operations
Constants§
- Maximum number of memory regions supported.
Traits§
- Trait for vhost-user backends.
- Trait for vhost-user frontends to respond to requests from the backend.
Functions§
- Utility function to convert a vector of files into a single file. Returns
None
if the vector contains no files or more than one file.
Type Aliases§
- Result of request handler.
- Result of vhost-user operations