Expand description
Library for implementing vhost-user device executables.
This crate provides
VhostUserDevicetrait, which is a collection of methods to handle vhost-user requests, andDeviceRequestHandlerstruct, which makes a connection to a VMM and starts an event loop.
They are expected to be used as follows:
- Define a struct and implement
VhostUserDevicefor it. - Create a
DeviceRequestHandlerwith the backend struct. - Drive the
DeviceRequestHandler::runasync fn with an executor.
โ
struct MyBackend {
/* fields */
}
impl VhostUserDevice for MyBackend {
/* implement methods */
}
fn main() -> Result<(), Box<dyn Error>> {
let backend = MyBackend { /* initialize fields */ };
let handler = DeviceRequestHandler::new(backend);
let socket = std::path::Path("/path/to/socket");
let ex = cros_async::Executor::new()?;
if let Err(e) = ex.run_until(handler.run(socket, &ex)) {
eprintln!("error happened: {}", e);
}
Ok(())
}Modulesยง
- sys ๐
Structsยง
- Device
Request Handler - An adapter that implements
vmm_vhost::Backendfor any type implementingVhostUserDevice. - Device
Request Handler Snapshot - Mapping
Info - Keeps a mapping from the vmmโs virtual addresses to guest addresses. used to translate messages from the vmm to guest offsets.
- Vhost
Backend ReqConnection - Keeps track of Vhost user backend request connection.
- Vhost
Backend ๐ReqConnection Shared - Vhost
Shmem ๐Mapper - Vhost
User ๐Regular Ops - Ops for running vhost-user over a stream (i.e. regular protocol).
- Vring ๐
- A virtio ring entry.
- Worker
State ๐
Enumsยง
- Device
State ๐Thread - Error
- Errors for device operations
Traitsยง
- Vhost
User Device - Trait for vhost-user devices. Analogous to the
VirtioDevicetrait.