pub trait VirtioDeviceBuilder: Sized {
    const NAME: &'static str;

    fn create_virtio_device(
        self,
        protection_type: ProtectionType
    ) -> Result<Box<dyn VirtioDevice>>; fn create_vhost_user_device(
        self,
        _keep_rds: &mut Vec<RawDescriptor>
    ) -> Result<Box<dyn VhostUserDevice>> { ... } fn create_jail(
        &self,
        jail_config: &Option<JailConfig>,
        virtio_transport: VirtioDeviceType
    ) -> Result<Option<Minijail>> { ... } fn create_virtio_device_and_jail(
        self,
        protection_type: ProtectionType,
        jail_config: &Option<JailConfig>
    ) -> Result<VirtioDeviceStub> { ... } }
Expand description

A trait for spawning virtio device instances and jails from their configuration structure.

Implementors become able to create virtio devices and jails following their own configuration. This trait also provides a few convenience methods for e.g. creating a virtio device and jail at once.

Required Associated Constants§

Base name of the device, as it will appear in logs.

Required Methods§

Create a regular virtio device from the configuration and protection_type setting.

Provided Methods§

Create a device suitable for being run as a vhost-user instance.

It is ok to leave this method unimplemented if the device is not intended to be used with vhost-user.

Create a jail that is suitable to run a device.

The default implementation creates a simple jail with a seccomp policy derived from the base name of the device.

Helper method to return a VirtioDeviceStub filled using create_virtio_device and create_jail.

This helper should cover the needs of most devices when run as regular virtio devices.

Implementations on Foreign Types§

For creating console virtio devices.

Implementors§