Module handler

Source
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, and
  • DeviceRequestHandler struct, which makes a connection to a VMM and starts an event loop.

They are expected to be used as follows:

  1. Define a struct and implement VhostUserDevice for it.
  2. Create a DeviceRequestHandler with the backend struct.
  3. 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ยง

DeviceRequestHandler
An adapter that implements vmm_vhost::Backend for any type implementing VhostUserDevice.
DeviceRequestHandlerSnapshot
MappingInfo
Keeps a mapping from the vmmโ€™s virtual addresses to guest addresses. used to translate messages from the vmm to guest offsets.
VhostBackendReqConnection
Keeps track of Vhost user backend request connection.
VhostBackendReqConnectionShared ๐Ÿ”’
VhostShmemMapper ๐Ÿ”’
VhostUserRegularOps ๐Ÿ”’
Ops for running vhost-user over a stream (i.e. regular protocol).
Vring ๐Ÿ”’
A virtio ring entry.
WorkerState ๐Ÿ”’

Enumsยง

DeviceStateThread ๐Ÿ”’
Error
Errors for device operations

Traitsยง

VhostUserDevice
Trait for vhost-user devices. Analogous to the VirtioDevice trait.

Functionsยง

vmm_va_to_gpa