VirtioQueue

Struct VirtioQueue 

Source
pub struct VirtioQueue<T: GuestMemoryAccessor + Clone> {
    pub index: u16,
    pub size: u16,
    pub desc_table: Option<DescriptorTable<T>>,
    pub max_size: u16,
    pub ready: bool,
    pub desc_table_addr: GuestPhysAddr,
    pub avail_ring_addr: GuestPhysAddr,
    pub used_ring_addr: GuestPhysAddr,
    pub event_idx_enabled: bool,
    /* private fields */
}
Expand description

VirtIO queue implementation

Fields§

§index: u16

Queue index

§size: u16

Queue size

§desc_table: Option<DescriptorTable<T>>

Descriptor table

§max_size: u16

Maximum queue size

§ready: bool

Queue ready flag

§desc_table_addr: GuestPhysAddr

Descriptor table address (guest physical)

§avail_ring_addr: GuestPhysAddr

Available ring address (guest physical)

§used_ring_addr: GuestPhysAddr

Used ring address (guest physical)

§event_idx_enabled: bool

Event index enabled

Implementations§

Source§

impl<T: GuestMemoryAccessor + Clone> VirtioQueue<T>

Source

pub fn new(index: u16, size: u16, accessor: Arc<T>) -> Self

Create a new VirtIO queue

Source

pub fn set_size(&mut self, size: u16) -> VirtioResult<()>

Set queue size

Source

pub fn set_desc_table_addr(&mut self, addr: GuestPhysAddr) -> VirtioResult<()>

Set descriptor table address

Source

pub fn set_avail_ring_addr(&mut self, addr: GuestPhysAddr) -> VirtioResult<()>

Set available ring address

Source

pub fn set_used_ring_addr(&mut self, addr: GuestPhysAddr) -> VirtioResult<()>

Set used ring address

Source

pub fn set_ready(&mut self, ready: bool)

Mark queue as ready

Source

pub fn is_valid(&self) -> bool

Check if queue is valid and ready

Source

pub fn reset(&mut self)

Reset the queue

Source

pub fn read_avail_idx(&self) -> VirtioResult<u16>

Read available ring index

Source

pub fn add_used(&mut self, desc_index: u16, len: u32) -> VirtioResult<()>

Add a used buffer to the used ring

Source

pub fn pop_avail(&mut self) -> VirtioResult<Option<u16>>

Get next available descriptor

Source

pub fn get_used_ring(&self) -> Option<&UsedRing<T>>

Get the used ring reference

Source

pub fn get_used_ring_mut(&mut self) -> Option<&mut UsedRing<T>>

Get the used ring mutable reference

Source

pub fn get_avail_ring(&self) -> Option<&AvailableRing<T>>

Get the available ring reference

Source

pub fn get_desc_table(&self) -> Option<&DescriptorTable<T>>

Get the descriptor table reference

Source

pub fn read_avail_entry(&self, ring_index: u16) -> VirtioResult<u16>

Read available ring entry

Source

pub fn update_last_avail_idx(&mut self, idx: u16)

Update last available index

Source

pub fn get_last_avail_idx(&self) -> u16

Get last available index

Source

pub fn validate_virtio_block_chain( &self, head_index: u16, min_length: usize, ) -> VirtioResult<bool>

Validate VirtIO block chain

Source

pub fn get_data_buffers( &self, head_index: u16, device_type: VirtioDeviceID, ) -> VirtioResult<Vec<(GuestPhysAddr, usize, bool)>>

Get data buffers from descriptor chain

Source

pub fn get_status_addr(&self, head_index: u16) -> VirtioResult<GuestPhysAddr>

Get status address from descriptor chain

Source

pub fn should_notify(&self) -> VirtioResult<bool>

Check if should notify

Source

pub fn write_status_byte(&self, head_index: u16, status: u8) -> VirtioResult<()>

Write status byte to the status buffer of a descriptor chain

This method writes the status byte to the last descriptor in the chain, which should be a write-only descriptor according to VirtIO specification.

Trait Implementations§

Source§

impl<T: Clone + GuestMemoryAccessor + Clone> Clone for VirtioQueue<T>

Source§

fn clone(&self) -> VirtioQueue<T>

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<T: Debug + GuestMemoryAccessor + Clone> Debug for VirtioQueue<T>

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<T> Freeze for VirtioQueue<T>

§

impl<T> RefUnwindSafe for VirtioQueue<T>
where T: RefUnwindSafe,

§

impl<T> Send for VirtioQueue<T>
where T: Sync + Send,

§

impl<T> Sync for VirtioQueue<T>
where T: Sync + Send,

§

impl<T> Unpin for VirtioQueue<T>

§

impl<T> UnwindSafe for VirtioQueue<T>
where T: RefUnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.