Module devices::virtio::vhost_user_backend::handler   
source ยท 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ยง
- An adapter that implements
vmm_vhost::Backendfor 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.
 - VhostShmemMapper ๐
 - VhostUserRegularOps ๐Ops for running vhost-user over a stream (i.e. regular protocol).
 - Vring ๐A virtio ring entry.
 - WorkerState ๐
 
Enumsยง
- DeviceStateThread ๐
 - Errors for device operations
 
Traitsยง
- Trait for vhost-user devices. Analogous to the
VirtioDevicetrait.