Struct virtio_queue::QueueState
source · [−]pub struct QueueState {
pub max_size: u16,
pub next_avail: Wrapping<u16>,
pub next_used: Wrapping<u16>,
pub event_idx_enabled: bool,
pub num_added: Wrapping<u16>,
pub size: u16,
pub ready: bool,
pub desc_table: GuestAddress,
pub avail_ring: GuestAddress,
pub used_ring: GuestAddress,
}
Expand description
Struct to maintain information and manipulate state of a virtio queue.
WARNING: The way the QueueState
is defined now, it can be used as the queue object, therefore
it is allowed to set up and use an invalid queue (initialized with random data since the
QueueState
’s fields are public). When fixing https://github.com/rust-vmm/vm-virtio/issues/143,
we plan to rename QueueState
to Queue
, and define a new QueueState
that would be the
actual state of the queue (no Wrapping
s in it, for example). This way, we will also be able to
do the checks that we normally do in the queue’s field setters when starting from scratch, when
trying to create a Queue
from a QueueState
.
Fields
max_size: u16
The maximum size in elements offered by the device.
next_avail: Wrapping<u16>
Tail position of the available ring.
next_used: Wrapping<u16>
Head position of the used ring.
event_idx_enabled: bool
VIRTIO_F_RING_EVENT_IDX negotiated.
num_added: Wrapping<u16>
The number of descriptor chains placed in the used ring via add_used
since the last time needs_notification
was called on the associated queue.
size: u16
The queue size in elements the driver selected.
ready: bool
Indicates if the queue is finished with configuration.
desc_table: GuestAddress
Guest physical address of the descriptor table.
avail_ring: GuestAddress
Guest physical address of the available ring.
used_ring: GuestAddress
Guest physical address of the used ring.
Trait Implementations
sourceimpl Debug for QueueState
impl Debug for QueueState
sourceimpl Default for QueueState
impl Default for QueueState
sourcefn default() -> QueueState
fn default() -> QueueState
Returns the “default value” for a type. Read more
sourceimpl PartialEq<QueueState> for QueueState
impl PartialEq<QueueState> for QueueState
sourcefn eq(&self, other: &QueueState) -> bool
fn eq(&self, other: &QueueState) -> bool
This method tests for self
and other
values to be equal, and is used
by ==
. Read more
sourcefn ne(&self, other: &QueueState) -> bool
fn ne(&self, other: &QueueState) -> bool
This method tests for !=
.
sourceimpl<'a> QueueStateGuard<'a> for QueueState
impl<'a> QueueStateGuard<'a> for QueueState
type G = &'a mut QueueState
type G = &'a mut QueueState
Type for guard returned by Self::lock()
.
sourceimpl QueueStateOwnedT for QueueState
impl QueueStateOwnedT for QueueState
sourcefn iter<M>(&mut self, mem: M) -> Result<AvailIter<'_, M>, Error> where
M: Deref,
M::Target: GuestMemory,
fn iter<M>(&mut self, mem: M) -> Result<AvailIter<'_, M>, Error> where
M: Deref,
M::Target: GuestMemory,
Get a consuming iterator over all available descriptor chain heads offered by the driver. Read more
sourcefn go_to_previous_position(&mut self)
fn go_to_previous_position(&mut self)
Undo the last advancement of the next available index field by decrementing its value by one. Read more
sourceimpl QueueStateT for QueueState
impl QueueStateT for QueueState
sourcefn new(max_size: u16) -> Self
fn new(max_size: u16) -> Self
Construct an empty virtio queue state object with the given max_size
.
sourcefn is_valid<M: GuestMemory>(&self, mem: &M) -> bool
fn is_valid<M: GuestMemory>(&self, mem: &M) -> bool
Check whether the queue configuration is valid.
sourcefn lock(&mut self) -> <Self as QueueStateGuard<'_>>::G
fn lock(&mut self) -> <Self as QueueStateGuard<'_>>::G
Get an exclusive reference to the underlying QueueState
object. Read more
sourcefn set_desc_table_address(&mut self, low: Option<u32>, high: Option<u32>)
fn set_desc_table_address(&mut self, low: Option<u32>, high: Option<u32>)
Set the descriptor table address for the queue. Read more
sourcefn set_avail_ring_address(&mut self, low: Option<u32>, high: Option<u32>)
fn set_avail_ring_address(&mut self, low: Option<u32>, high: Option<u32>)
Set the available ring address for the queue. Read more
sourcefn set_used_ring_address(&mut self, low: Option<u32>, high: Option<u32>)
fn set_used_ring_address(&mut self, low: Option<u32>, high: Option<u32>)
Set the used ring address for the queue. Read more
sourcefn set_event_idx(&mut self, enabled: bool)
fn set_event_idx(&mut self, enabled: bool)
Enable/disable the VIRTIO_F_RING_EVENT_IDX feature for interrupt coalescing.
sourcefn avail_idx<M>(&self, mem: &M, order: Ordering) -> Result<Wrapping<u16>, Error> where
M: GuestMemory + ?Sized,
fn avail_idx<M>(&self, mem: &M, order: Ordering) -> Result<Wrapping<u16>, Error> where
M: GuestMemory + ?Sized,
Read the idx
field from the available ring.
sourcefn used_idx<M: GuestMemory>(
&self,
mem: &M,
order: Ordering
) -> Result<Wrapping<u16>, Error>
fn used_idx<M: GuestMemory>(
&self,
mem: &M,
order: Ordering
) -> Result<Wrapping<u16>, Error>
Read the idx
field from the used ring.
sourcefn add_used<M: GuestMemory>(
&mut self,
mem: &M,
head_index: u16,
len: u32
) -> Result<(), Error>
fn add_used<M: GuestMemory>(
&mut self,
mem: &M,
head_index: u16,
len: u32
) -> Result<(), Error>
Put a used descriptor head into the used ring.
sourcefn enable_notification<M: GuestMemory>(
&mut self,
mem: &M
) -> Result<bool, Error>
fn enable_notification<M: GuestMemory>(
&mut self,
mem: &M
) -> Result<bool, Error>
Enable notification events from the guest driver. Read more
sourcefn disable_notification<M: GuestMemory>(&mut self, mem: &M) -> Result<(), Error>
fn disable_notification<M: GuestMemory>(&mut self, mem: &M) -> Result<(), Error>
Disable notification events from the guest driver.
sourcefn needs_notification<M: GuestMemory>(&mut self, mem: &M) -> Result<bool, Error>
fn needs_notification<M: GuestMemory>(&mut self, mem: &M) -> Result<bool, Error>
Check whether a notification to the guest is needed. Read more
sourcefn next_avail(&self) -> u16
fn next_avail(&self) -> u16
Return the index of the next entry in the available ring.
sourcefn set_next_avail(&mut self, next_avail: u16)
fn set_next_avail(&mut self, next_avail: u16)
Set the index of the next entry in the available ring.
sourcefn set_next_used(&mut self, next_used: u16)
fn set_next_used(&mut self, next_used: u16)
Set the index for the next descriptor in the used ring.
sourcefn pop_descriptor_chain<M>(&mut self, mem: M) -> Option<DescriptorChain<M>> where
M: Clone + Deref,
M::Target: GuestMemory,
fn pop_descriptor_chain<M>(&mut self, mem: M) -> Option<DescriptorChain<M>> where
M: Clone + Deref,
M::Target: GuestMemory,
Pop and return the next available descriptor chain, or None
when there are no more
descriptor chains available. Read more
sourcefn lock_with_memory<M>(
&mut self,
mem: M
) -> QueueGuard<M, <Self as QueueStateGuard<'_>>::G> where
M: Deref + Clone,
M::Target: GuestMemory + Sized,
fn lock_with_memory<M>(
&mut self,
mem: M
) -> QueueGuard<M, <Self as QueueStateGuard<'_>>::G> where
M: Deref + Clone,
M::Target: GuestMemory + Sized,
Get an exclusive reference to the underlying QueueState
object with an associated
GuestMemory
object. Read more
impl StructuralPartialEq for QueueState
Auto Trait Implementations
impl RefUnwindSafe for QueueState
impl Send for QueueState
impl Sync for QueueState
impl Unpin for QueueState
impl UnwindSafe for QueueState
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more