Trait VirtioDeviceModule

Source
pub trait VirtioDeviceModule: Serialize + DeserializeOwned {
    // Required methods
    fn sort_name(&self) -> &'static str;
    fn create(
        &self,
        cx: &mut VirtioDeviceArgs<'_>,
    ) -> Result<Box<dyn VirtioDevice>>;
    fn create_jail(&self, jail_config: &JailConfig) -> Result<Option<Minijail>>;
}
Expand description

A module that creates a single virtio device and provides hooks to integrate it into the VMM.

The goal of this API is to allow nearly all of a device’s code to live together, including logic that was historically spread across the code base, like wiring up control tubes. To add a new device, you should just need to write one of these modules, add cmdline params, and insert the module into crosvm::config::Config.

Generally, types implementing this trait should only contain data derived from the cmdline arguments. If a device needs, say, some information from the hypervisor, then pass that data through VirtioDeviceArgs.

Requires serde because Config requires serde (for Windows).

Required Methods§

Source

fn sort_name(&self) -> &'static str

Name of the device used to determine init processing order.

Source

fn create(&self, cx: &mut VirtioDeviceArgs<'_>) -> Result<Box<dyn VirtioDevice>>

Create an instance of this device.

Source

fn create_jail(&self, jail_config: &JailConfig) -> Result<Option<Minijail>>

Optionally create a jail for this device.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§