Skip to main content

DynVirtioDevice

Trait DynVirtioDevice 

Source
pub trait DynVirtioDevice: InspectMut + Send {
    // Required methods
    fn traits(&self) -> DeviceTraits;
    fn queue_size(&self, queue_index: u16) -> u16;
    fn read_registers_u32(
        &mut self,
        offset: u16,
    ) -> Pin<Box<dyn Future<Output = u32> + Send + '_>>;
    fn write_registers_u32(
        &mut self,
        offset: u16,
        val: u32,
    ) -> Pin<Box<dyn Future<Output = ()> + Send + '_>>;
    fn set_shared_memory_region(
        &mut self,
        region: &Arc<dyn MappedMemoryRegion>,
    ) -> Result<()>;
    fn start_queue<'a>(
        &'a mut self,
        idx: u16,
        resources: QueueResources,
        features: &'a VirtioDeviceFeatures,
        initial_state: Option<QueueState>,
    ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'a>>;
    fn stop_queue(
        &mut self,
        idx: u16,
    ) -> Pin<Box<dyn Future<Output = Option<QueueState>> + Send + '_>>;
    fn reset(&mut self) -> Pin<Box<dyn Future<Output = ()> + Send + '_>>;
    fn supports_save_restore(&self) -> bool;
}
Expand description

Object-safe wrapper for VirtioDevice.

Uses boxed futures instead of async fn for object safety. The blanket impl converts any T: VirtioDevice into a DynVirtioDevice.

The device task, backend server, and resolver hold Box<dyn DynVirtioDevice>.

Required Methods§

Source

fn traits(&self) -> DeviceTraits

Device identity and capabilities.

Source

fn queue_size(&self, queue_index: u16) -> u16

The queue size for the given queue index.

Source

fn read_registers_u32( &mut self, offset: u16, ) -> Pin<Box<dyn Future<Output = u32> + Send + '_>>

Read device-specific config registers.

Source

fn write_registers_u32( &mut self, offset: u16, val: u32, ) -> Pin<Box<dyn Future<Output = ()> + Send + '_>>

Write device-specific config registers.

Source

fn set_shared_memory_region( &mut self, region: &Arc<dyn MappedMemoryRegion>, ) -> Result<()>

Provide the shared memory region to the device.

Source

fn start_queue<'a>( &'a mut self, idx: u16, resources: QueueResources, features: &'a VirtioDeviceFeatures, initial_state: Option<QueueState>, ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'a>>

Start a single queue.

Source

fn stop_queue( &mut self, idx: u16, ) -> Pin<Box<dyn Future<Output = Option<QueueState>> + Send + '_>>

Stop a single queue and return its state.

Source

fn reset(&mut self) -> Pin<Box<dyn Future<Output = ()> + Send + '_>>

Reset device-internal state.

Source

fn supports_save_restore(&self) -> bool

Whether the device supports save/restore.

Implementors§