pub trait VirtioDevice: InspectMut + Send {
// Required methods
fn traits(&self) -> DeviceTraits;
fn read_registers_u32(&self, offset: u16) -> u32;
fn write_registers_u32(&mut self, offset: u16, val: u32);
fn enable(&mut self, resources: Resources) -> Result<()>;
fn poll_disable(&mut self, cx: &mut Context<'_>) -> Poll<()>;
}Required Methods§
fn traits(&self) -> DeviceTraits
fn read_registers_u32(&self, offset: u16) -> u32
fn write_registers_u32(&mut self, offset: u16, val: u32)
Sourcefn enable(&mut self, resources: Resources) -> Result<()>
fn enable(&mut self, resources: Resources) -> Result<()>
Enable the device with the given resources.
Called when the guest sets DRIVER_OK. On success, the device should
start processing queues and the transport will reflect DRIVER_OK in
the device status. On failure, the transport will log the error and
leave DRIVER_OK unset, so the device remains inert and the guest
will observe failures through IO timeouts.
Sourcefn poll_disable(&mut self, cx: &mut Context<'_>) -> Poll<()>
fn poll_disable(&mut self, cx: &mut Context<'_>) -> Poll<()>
Poll the device to complete a disable/reset operation.
This is called when the guest writes status=0 (device reset). The device
should stop workers and drain any in-flight IO. Returns Poll::Ready(())
when the disable is complete, or Poll::Pending if more work is needed.
Devices that don’t need async cleanup can return Poll::Ready(())
immediately.