Expand description
Library for implementing vhost-user device executables.
This crate provides
VhostUserDevice
trait, which is a collection of methods to handle vhost-user requests, andDeviceRequestHandler
struct, 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
VhostUserDevice
for it. - Create a
DeviceRequestHandler
with the backend struct. - Drive the
DeviceRequestHandler::run
async 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§
- An adapter that implements
vmm_vhost::Backend
for any type implementingVhostUserDevice
. - Keeps a mapping from the vmm’s virtual addresses to guest addresses. used to translate messages from the vmm to guest offsets.
- Keeps track of Vhost user backend request connection.
- Ops for running vhost-user over a stream (i.e. regular protocol).
- Vring 🔒A virtio ring entry.
Enums§
- Errors for device operations
- Indicates the state of backend request connection
Traits§
- Trait for vhost-user devices. Analogous to the
VirtioDevice
trait.