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: u16Queue index
size: u16Queue size
desc_table: Option<DescriptorTable<T>>Descriptor table
max_size: u16Maximum queue size
ready: boolQueue ready flag
desc_table_addr: GuestPhysAddrDescriptor table address (guest physical)
avail_ring_addr: GuestPhysAddrAvailable ring address (guest physical)
used_ring_addr: GuestPhysAddrUsed ring address (guest physical)
event_idx_enabled: boolEvent index enabled
Implementations§
Source§impl<T: GuestMemoryAccessor + Clone> VirtioQueue<T>
impl<T: GuestMemoryAccessor + Clone> VirtioQueue<T>
Sourcepub fn set_size(&mut self, size: u16) -> VirtioResult<()>
pub fn set_size(&mut self, size: u16) -> VirtioResult<()>
Set queue size
Sourcepub fn set_desc_table_addr(&mut self, addr: GuestPhysAddr) -> VirtioResult<()>
pub fn set_desc_table_addr(&mut self, addr: GuestPhysAddr) -> VirtioResult<()>
Set descriptor table address
Sourcepub fn set_avail_ring_addr(&mut self, addr: GuestPhysAddr) -> VirtioResult<()>
pub fn set_avail_ring_addr(&mut self, addr: GuestPhysAddr) -> VirtioResult<()>
Set available ring address
Sourcepub fn set_used_ring_addr(&mut self, addr: GuestPhysAddr) -> VirtioResult<()>
pub fn set_used_ring_addr(&mut self, addr: GuestPhysAddr) -> VirtioResult<()>
Set used ring address
Sourcepub fn read_avail_idx(&self) -> VirtioResult<u16>
pub fn read_avail_idx(&self) -> VirtioResult<u16>
Read available ring index
Sourcepub fn add_used(&mut self, desc_index: u16, len: u32) -> VirtioResult<()>
pub fn add_used(&mut self, desc_index: u16, len: u32) -> VirtioResult<()>
Add a used buffer to the used ring
Sourcepub fn pop_avail(&mut self) -> VirtioResult<Option<u16>>
pub fn pop_avail(&mut self) -> VirtioResult<Option<u16>>
Get next available descriptor
Sourcepub fn get_used_ring(&self) -> Option<&UsedRing<T>>
pub fn get_used_ring(&self) -> Option<&UsedRing<T>>
Get the used ring reference
Sourcepub fn get_used_ring_mut(&mut self) -> Option<&mut UsedRing<T>>
pub fn get_used_ring_mut(&mut self) -> Option<&mut UsedRing<T>>
Get the used ring mutable reference
Sourcepub fn get_avail_ring(&self) -> Option<&AvailableRing<T>>
pub fn get_avail_ring(&self) -> Option<&AvailableRing<T>>
Get the available ring reference
Sourcepub fn get_desc_table(&self) -> Option<&DescriptorTable<T>>
pub fn get_desc_table(&self) -> Option<&DescriptorTable<T>>
Get the descriptor table reference
Sourcepub fn read_avail_entry(&self, ring_index: u16) -> VirtioResult<u16>
pub fn read_avail_entry(&self, ring_index: u16) -> VirtioResult<u16>
Read available ring entry
Sourcepub fn update_last_avail_idx(&mut self, idx: u16)
pub fn update_last_avail_idx(&mut self, idx: u16)
Update last available index
Sourcepub fn get_last_avail_idx(&self) -> u16
pub fn get_last_avail_idx(&self) -> u16
Get last available index
Sourcepub fn validate_virtio_block_chain(
&self,
head_index: u16,
min_length: usize,
) -> VirtioResult<bool>
pub fn validate_virtio_block_chain( &self, head_index: u16, min_length: usize, ) -> VirtioResult<bool>
Validate VirtIO block chain
Sourcepub fn get_data_buffers(
&self,
head_index: u16,
device_type: VirtioDeviceID,
) -> VirtioResult<Vec<(GuestPhysAddr, usize, bool)>>
pub fn get_data_buffers( &self, head_index: u16, device_type: VirtioDeviceID, ) -> VirtioResult<Vec<(GuestPhysAddr, usize, bool)>>
Get data buffers from descriptor chain
Sourcepub fn get_status_addr(&self, head_index: u16) -> VirtioResult<GuestPhysAddr>
pub fn get_status_addr(&self, head_index: u16) -> VirtioResult<GuestPhysAddr>
Get status address from descriptor chain
Sourcepub fn should_notify(&self) -> VirtioResult<bool>
pub fn should_notify(&self) -> VirtioResult<bool>
Check if should notify
Sourcepub fn write_status_byte(&self, head_index: u16, status: u8) -> VirtioResult<()>
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>
impl<T: Clone + GuestMemoryAccessor + Clone> Clone for VirtioQueue<T>
Source§fn clone(&self) -> VirtioQueue<T>
fn clone(&self) -> VirtioQueue<T>
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more