Trait crosvm_direct::crosvm::sys::unix::device_helpers::VirtioDeviceBuilder
source · [−]pub trait VirtioDeviceBuilder {
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>,
jail_type: 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
fn 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
fn create_vhost_user_device(
&self,
_keep_rds: &mut Vec<RawDescriptor>
) -> Result<Box<dyn VhostUserDevice>>
fn create_vhost_user_device(
&self,
_keep_rds: &mut Vec<RawDescriptor>
) -> Result<Box<dyn VhostUserDevice>>
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.
fn create_jail(
&self,
jail_config: &Option<JailConfig>,
jail_type: VirtioDeviceType
) -> Result<Option<Minijail>>
fn create_jail(
&self,
jail_config: &Option<JailConfig>,
jail_type: 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.
fn 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.
Implementations on Foreign Types
sourceimpl VirtioDeviceBuilder for SerialParameters
impl VirtioDeviceBuilder for SerialParameters
For creating console virtio devices.