pub trait VirtioDeviceBuilder: Sized {
const NAME: &'static str;
// Required method
fn create_virtio_device(
self,
protection_type: ProtectionType,
) -> Result<Box<dyn VirtioDevice>>;
// Provided methods
fn create_vhost_user_device(
self,
_keep_rds: &mut Vec<RawDescriptor>,
) -> Result<Box<dyn VhostUserDeviceBuilder>> { ... }
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§
Required Methods§
Sourcefn create_virtio_device(
self,
protection_type: ProtectionType,
) -> Result<Box<dyn VirtioDevice>>
fn create_virtio_device( self, protection_type: ProtectionType, ) -> Result<Box<dyn VirtioDevice>>
Create a regular virtio device from the configuration and protection_type setting.
Provided Methods§
Sourcefn create_vhost_user_device(
self,
_keep_rds: &mut Vec<RawDescriptor>,
) -> Result<Box<dyn VhostUserDeviceBuilder>>
fn create_vhost_user_device( self, _keep_rds: &mut Vec<RawDescriptor>, ) -> Result<Box<dyn VhostUserDeviceBuilder>>
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.
Sourcefn create_jail(
&self,
jail_config: Option<&JailConfig>,
virtio_transport: VirtioDeviceType,
) -> Result<Option<Minijail>>
fn create_jail( &self, jail_config: Option<&JailConfig>, virtio_transport: VirtioDeviceType, ) -> Result<Option<Minijail>>
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.
Sourcefn create_virtio_device_and_jail(
self,
protection_type: ProtectionType,
jail_config: Option<&JailConfig>,
) -> Result<VirtioDeviceStub>
fn create_virtio_device_and_jail( self, protection_type: ProtectionType, jail_config: Option<&JailConfig>, ) -> Result<VirtioDeviceStub>
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.
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.
Implementations on Foreign Types§
Source§impl VirtioDeviceBuilder for &SerialParameters
For creating console virtio devices.
impl VirtioDeviceBuilder for &SerialParameters
For creating console virtio devices.