pub trait QueueT: for<'a> QueueGuard<'a> {
Show 28 methods
// Required methods
fn new(max_size: u16) -> Result<Self, Error>
where Self: Sized;
fn is_valid<M: GuestMemory>(&self, mem: &M) -> bool;
fn reset(&mut self);
fn lock(&mut self) -> <Self as QueueGuard<'_>>::G;
fn max_size(&self) -> u16;
fn 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>(
&self,
mem: &M,
order: Ordering,
) -> Result<Wrapping<u16>, Error>
where M: GuestMemory + ?Sized;
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 desc_table(&self) -> u64;
fn avail_ring(&self) -> u64;
fn used_ring(&self) -> u64;
fn event_idx_enabled(&self) -> bool;
fn pop_descriptor_chain<M>(&mut self, mem: M) -> Option<DescriptorChain<M>>
where M: Clone + Deref,
M::Target: GuestMemory;
}
Expand description
Trait to access and manipulate a virtio queue.
To optimize for performance, different implementations of the QueueT
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 QueueT
trait with a lifetime as well.
Required Methods§
Sourcefn new(max_size: u16) -> Result<Self, Error>where
Self: Sized,
fn new(max_size: u16) -> Result<Self, Error>where
Self: Sized,
Construct an empty virtio queue state object with the given max_size
.
Returns an error if max_size
is invalid.
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 QueueGuard<'_>>::G
fn lock(&mut self) -> <Self as QueueGuard<'_>>::G
Get an exclusive reference to the underlying Queue
object.
Logically this method will acquire the underlying lock protecting the Queue
Object.
The lock will be released when the returned object gets dropped.
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.
The descriptor table address is 64-bit, the corresponding part will be updated if ‘low’
and/or high
is Some
and valid.
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.
The available ring address is 64-bit, the corresponding part will be updated if ‘low’
and/or high
is Some
and valid.
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.
The used ring address is 64-bit, the corresponding part will be updated if ‘low’
and/or high
is Some
and valid.
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,
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>
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.
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).
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.
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.
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 desc_table(&self) -> u64
fn desc_table(&self) -> u64
Return the address of the descriptor table.
Sourcefn avail_ring(&self) -> u64
fn avail_ring(&self) -> u64
Return the address of the available ring.
Sourcefn event_idx_enabled(&self) -> bool
fn event_idx_enabled(&self) -> bool
Checks whether VIRTIO_F_RING_EVENT_IDX
is negotiated.
This getter is only returning the correct value after the device passes the FEATURES_OK
status.
Sourcefn pop_descriptor_chain<M>(&mut self, mem: M) -> Option<DescriptorChain<M>>
fn pop_descriptor_chain<M>(&mut self, mem: M) -> Option<DescriptorChain<M>>
Pop and return the next available descriptor chain, or None
when there are no more
descriptor chains available.
This enables the consumption of available descriptor chains in a “one at a time” manner, without having to hold a borrow after the method returns.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.