pub enum Queue {
SplitVirtQueue(SplitQueue),
PackedVirtQueue(PackedQueue),
}
Expand description
Virtqueue interface representing different types of virtqueues The struct of each queue type is wrapped in the enum variants
Variants§
SplitVirtQueue(SplitQueue)
Split virtqueue type in virtio v1.2 spec: https://docs.oasis-open.org/virtio/virtio/v1.2/csd01/virtio-v1.2-csd01.html#x1-350007
PackedVirtQueue(PackedQueue)
Packed virtqueue type in virtio v1.2 spec: https://docs.oasis-open.org/virtio/virtio/v1.2/csd01/virtio-v1.2-csd01.html#x1-720008
Implementations§
source§impl Queue
impl Queue
sourcepub async fn next_async(
&mut self,
eventfd: &mut EventAsync
) -> Result<DescriptorChain, AsyncError>
pub async fn next_async( &mut self, eventfd: &mut EventAsync ) -> Result<DescriptorChain, AsyncError>
Asynchronously read the next descriptor chain from the queue.
Returns a DescriptorChain
when it is await
ed.
sourcepub fn peek(&mut self) -> Option<PeekedDescriptorChain<'_>>
pub fn peek(&mut self) -> Option<PeekedDescriptorChain<'_>>
Get the first available descriptor chain without removing it from the queue.
Call pop()
on the returned PeekedDescriptorChain
to remove it from the queue.
sourcepub fn pop(&mut self) -> Option<DescriptorChain>
pub fn pop(&mut self) -> Option<DescriptorChain>
If a new DescriptorChain is available, returns one and removes it from the queue.
sourcepub async fn next_async_interruptable(
&mut self,
queue_event: &mut EventAsync,
stop_rx: &mut Receiver<()>
) -> Result<Option<DescriptorChain>, AsyncError>
pub async fn next_async_interruptable( &mut self, queue_event: &mut EventAsync, stop_rx: &mut Receiver<()> ) -> Result<Option<DescriptorChain>, AsyncError>
Returns None
if stop_rx receives a value; otherwise returns the result
of waiting for the next descriptor.
sourcepub fn trigger_interrupt(&mut self) -> bool
pub fn trigger_interrupt(&mut self) -> bool
inject interrupt into guest on this queue return true: interrupt is injected into guest for this queue false: interrupt isn’t injected
sourcepub fn restore(
queue_config: &QueueConfig,
queue_value: Value,
mem: &GuestMemory,
event: Event,
interrupt: Interrupt
) -> Result<Queue>
pub fn restore( queue_config: &QueueConfig, queue_value: Value, mem: &GuestMemory, event: Event, interrupt: Interrupt ) -> Result<Queue>
Restore queue from snapshot
sourcepub fn vhost_user_reclaim(&mut self, vring_base: u16)
pub fn vhost_user_reclaim(&mut self, vring_base: u16)
“Reclaim” a queue that was given to a vhost-user backend and is now being taken back using VHOST_USER_GET_VRING_BASE.
The Queue
will have stale fields if the vhost-user backend fulfilled any virtqueue
requests. This function updates the Queue
to pick up where the backend left off.
sourcepub fn next_avail_to_process(&self) -> u16
pub fn next_avail_to_process(&self) -> u16
Getter for the next index of the available ring that device will process.
Not to be confused with the available ring’s index field, which is the next index for the driver to fill.
sourcepub fn desc_table(&self) -> GuestAddress
pub fn desc_table(&self) -> GuestAddress
Getter for descriptor area
sourcepub fn avail_ring(&self) -> GuestAddress
pub fn avail_ring(&self) -> GuestAddress
Getter for driver area
sourcepub fn used_ring(&self) -> GuestAddress
pub fn used_ring(&self) -> GuestAddress
Getter for device area
sourcepub fn size(&self) -> u16
pub fn size(&self) -> u16
Return the actual size of the queue, as the driver may not set up a queue as big as the device allows.
sourcepub fn add_used(&mut self, desc_chain: DescriptorChain, len: u32)
pub fn add_used(&mut self, desc_chain: DescriptorChain, len: u32)
Puts an available descriptor head into the used ring for use by the guest.
Trait Implementations§
Auto Trait Implementations§
impl !RefUnwindSafe for Queue
impl Send for Queue
impl Sync for Queue
impl Unpin for Queue
impl !UnwindSafe for Queue
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait>
(where Trait: Downcast
) to Box<dyn Any>
. Box<dyn Any>
can
then be further downcast
into Box<ConcreteType>
where ConcreteType
implements Trait
.§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait>
(where Trait: Downcast
) to Rc<Any>
. Rc<Any>
can then be
further downcast
into Rc<ConcreteType>
where ConcreteType
implements Trait
.§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &Any
’s vtable from &Trait
’s.§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &mut Any
’s vtable from &mut Trait
’s.