Trait virtio_queue::QueueStateT
source · [−]pub trait QueueStateT: for<'a> QueueStateGuard<'a> {
Show 23 methods
fn new(max_size: u16) -> Self;
fn is_valid<M: GuestMemory>(&self, mem: &M) -> bool;
fn reset(&mut self);
fn lock(&mut self) -> <Self as QueueStateGuard<'_>>::G;
fn max_size(&self) -> u16;
fn set_size(&mut self, size: u16);
fn ready(&self) -> bool;
fn set_ready(&mut self, ready: bool);
fn set_desc_table_address(&mut self, low: Option<u32>, high: Option<u32>);
fn set_avail_ring_address(&mut self, low: Option<u32>, high: Option<u32>);
fn set_used_ring_address(&mut self, low: Option<u32>, high: Option<u32>);
fn set_event_idx(&mut self, enabled: bool);
fn avail_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>;
fn add_used<M: GuestMemory>(
&mut self,
mem: &M,
head_index: u16,
len: u32
) -> Result<(), Error>;
fn enable_notification<M: GuestMemory>(
&mut self,
mem: &M
) -> Result<bool, Error>;
fn disable_notification<M: GuestMemory>(
&mut self,
mem: &M
) -> Result<(), Error>;
fn needs_notification<M: GuestMemory>(
&mut self,
mem: &M
) -> Result<bool, Error>;
fn next_avail(&self) -> u16;
fn set_next_avail(&mut self, next_avail: u16);
fn next_used(&self) -> u16;
fn set_next_used(&mut self, next_used: u16);
fn lock_with_memory<M>(
&mut self,
mem: M
) -> QueueGuard<M, <Self as QueueStateGuard<'_>>::G>
where
M: Deref + Clone,
M::Target: GuestMemory + Sized,
{ ... }
}
Expand description
Trait to access and manipulate a virtio queue.
To optimize for performance, different implementations of the QueueStateT
trait may be
provided for single-threaded context and multi-threaded context.
Using Higher-Rank Trait Bounds (HRTBs) to effectively define an associated type that has a
lifetime parameter, without tagging the QueueStateT
trait with a lifetime as well.
Required methods
Construct an empty virtio queue state object with the given max_size
.
fn is_valid<M: GuestMemory>(&self, mem: &M) -> bool
fn is_valid<M: GuestMemory>(&self, mem: &M) -> bool
Check whether the queue configuration is valid.
fn lock(&mut self) -> <Self as QueueStateGuard<'_>>::G
fn lock(&mut self) -> <Self as QueueStateGuard<'_>>::G
Get an exclusive reference to the underlying QueueState
object.
Logically this method will acquire the underlying lock protecting the QueueState
Object.
The lock will be released when the returned object gets dropped.
Set the descriptor table address for the queue.
The descriptor table address is 64-bit, the corresponding part will be updated if ‘low’
and/or high
is Some
and valid.
Set the available ring address for the queue.
The available ring address is 64-bit, the corresponding part will be updated if ‘low’
and/or high
is Some
and valid.
Set the used ring address for the queue.
The used ring address is 64-bit, the corresponding part will be updated if ‘low’
and/or high
is Some
and valid.
fn 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.
Read the idx
field from the available ring.
Read the idx
field from the used ring.
Put a used descriptor head into the used ring.
fn 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.
Return true if one or more descriptors can be consumed from the available ring after notifications were enabled (and thus it’s possible there will be no corresponding notification).
fn 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.
fn 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.
Please note this method has side effects: once it returns true
, it considers the
driver will actually be notified, remember the associated index in the used ring, and
won’t return true
again until the driver updates used_event
and/or the notification
conditions hold once more.
fn next_avail(&self) -> u16
fn next_avail(&self) -> u16
Return the index of the next entry in the available ring.
fn 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.
fn 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.
Provided methods
fn 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.
Logically this method will acquire the underlying lock protecting the QueueState
Object.
The lock will be released when the returned object gets dropped.