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§
Sourcefn traits(&self) -> DeviceTraits
fn traits(&self) -> DeviceTraits
Device identity and capabilities.
Sourcefn queue_size(&self, queue_index: u16) -> u16
fn queue_size(&self, queue_index: u16) -> u16
The queue size for the given queue index.
Sourcefn read_registers_u32(
&mut self,
offset: u16,
) -> Pin<Box<dyn Future<Output = u32> + Send + '_>>
fn read_registers_u32( &mut self, offset: u16, ) -> Pin<Box<dyn Future<Output = u32> + Send + '_>>
Read device-specific config registers.
Sourcefn write_registers_u32(
&mut self,
offset: u16,
val: u32,
) -> Pin<Box<dyn Future<Output = ()> + Send + '_>>
fn write_registers_u32( &mut self, offset: u16, val: u32, ) -> Pin<Box<dyn Future<Output = ()> + Send + '_>>
Write device-specific config registers.
Provide the shared memory region to the device.
Sourcefn 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 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.
Sourcefn stop_queue(
&mut self,
idx: u16,
) -> Pin<Box<dyn Future<Output = Option<QueueState>> + Send + '_>>
fn stop_queue( &mut self, idx: u16, ) -> Pin<Box<dyn Future<Output = Option<QueueState>> + Send + '_>>
Stop a single queue and return its state.
Sourcefn reset(&mut self) -> Pin<Box<dyn Future<Output = ()> + Send + '_>>
fn reset(&mut self) -> Pin<Box<dyn Future<Output = ()> + Send + '_>>
Reset device-internal state.
Sourcefn supports_save_restore(&self) -> bool
fn supports_save_restore(&self) -> bool
Whether the device supports save/restore.