VirtioDevice

Trait VirtioDevice 

Source
pub trait VirtioDevice: AsAny + Send {
Show 22 methods // Required methods fn avail_features(&self) -> u64; fn acked_features(&self) -> u64; fn set_acked_features(&mut self, acked_features: u64); fn const_device_type() -> u32 where Self: Sized; fn device_type(&self) -> u32; fn queues(&self) -> &[Queue]; fn queues_mut(&mut self) -> &mut [Queue]; fn queue_events(&self) -> &[EventFd]; fn interrupt_trigger(&self) -> &dyn VirtioInterrupt; fn read_config(&self, offset: u64, data: &mut [u8]); fn write_config(&mut self, offset: u64, data: &[u8]); fn activate( &mut self, mem: GuestMemoryMmap, interrupt: Arc<dyn VirtioInterrupt>, ) -> Result<(), ActivateError>; fn is_activated(&self) -> bool; // Provided methods fn has_feature(&self, feature: u64) -> bool { ... } fn interrupt_status(&self) -> Arc<AtomicU32> { ... } fn avail_features_by_page(&self, page: u32) -> u32 { ... } fn ack_features_by_page(&mut self, page: u32, value: u32) { ... } fn reset(&mut self) -> Option<(Arc<dyn VirtioInterrupt>, Vec<EventFd>)> { ... } fn mark_queue_memory_dirty( &mut self, mem: &GuestMemoryMmap, ) -> Result<(), QueueError> { ... } fn kick(&mut self) { ... } fn as_cow_file_engine(&self) -> Option<&CowFileEngine> { ... } fn nyx_handle_queue_event(&mut self, _queue_index: u16) { ... }
}
Expand description

Trait for virtio devices to be driven by a virtio transport.

The lifecycle of a virtio device is to be moved to a virtio transport, which will then query the device. The virtio devices needs to create queues, events and event fds for interrupts and expose them to the transport via get_queues/get_queue_events/get_interrupt/get_interrupt_status fns.

Required Methods§

Source

fn avail_features(&self) -> u64

Get the available features offered by device.

Source

fn acked_features(&self) -> u64

Get acknowledged features of the driver.

Source

fn set_acked_features(&mut self, acked_features: u64)

Set acknowledged features of the driver. This function must maintain the following invariant:

  • self.avail_features() & self.acked_features() = self.get_acked_features()
Source

fn const_device_type() -> u32
where Self: Sized,

The virtio device type (as a constant of the struct).

Source

fn device_type(&self) -> u32

The virtio device type.

It should be the same as returned by Self::const_device_type().

Source

fn queues(&self) -> &[Queue]

Returns the device queues.

Source

fn queues_mut(&mut self) -> &mut [Queue]

Returns a mutable reference to the device queues.

Source

fn queue_events(&self) -> &[EventFd]

Returns the device queues event fds.

Source

fn interrupt_trigger(&self) -> &dyn VirtioInterrupt

Source

fn read_config(&self, offset: u64, data: &mut [u8])

Reads this device configuration space at offset.

Source

fn write_config(&mut self, offset: u64, data: &[u8])

Writes to this device configuration space at offset.

Source

fn activate( &mut self, mem: GuestMemoryMmap, interrupt: Arc<dyn VirtioInterrupt>, ) -> Result<(), ActivateError>

Performs the formal activation for a device, which can be verified also with is_activated.

Source

fn is_activated(&self) -> bool

Checks if the resources of this device are activated.

Provided Methods§

Source

fn has_feature(&self, feature: u64) -> bool

Check if virtio device has negotiated given feature.

Source

fn interrupt_status(&self) -> Arc<AtomicU32>

Returns the current device interrupt status.

Source

fn avail_features_by_page(&self, page: u32) -> u32

The set of feature bits shifted by page * 32.

Source

fn ack_features_by_page(&mut self, page: u32, value: u32)

Acknowledges that this set of features should be enabled.

Source

fn reset(&mut self) -> Option<(Arc<dyn VirtioInterrupt>, Vec<EventFd>)>

Optionally deactivates this device and returns ownership of the guest memory map, interrupt event, and queue events.

Source

fn mark_queue_memory_dirty( &mut self, mem: &GuestMemoryMmap, ) -> Result<(), QueueError>

Mark pages used by queues as dirty.

Source

fn kick(&mut self)

Kick the device, as if it had received external events.

Source

fn as_cow_file_engine(&self) -> Option<&CowFileEngine>

Returns a COW file engine if the device exposes one (NYX extension).

Source

fn nyx_handle_queue_event(&mut self, _queue_index: u16)

Handle a queue notification from an MMIO write (NYX extension).

Trait Implementations§

Source§

impl Debug for dyn VirtioDevice

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Implementors§