Struct virtio_queue::QueueStateSync [−][src]
pub struct QueueStateSync { /* fields omitted */ }
Expand description
Struct to maintain information and manipulate state of a virtio queue for multi-threaded context.
Example
use virtio_queue::{Queue, QueueState, QueueStateSync, QueueStateT};
use vm_memory::{Bytes, GuestAddress, GuestAddressSpace, GuestMemoryMmap};
let m = &GuestMemoryMmap::<()>::from_ranges(&[(GuestAddress(0), 0x10000)]).unwrap();
let mut queue = QueueStateSync::new(1024);
// First, the driver sets up the queue; this set up is done via writes on the bus (PCI, MMIO).
queue.set_size(8);
queue.set_desc_table_address(Some(0x1000), None);
queue.set_avail_ring_address(Some(0x2000), None);
queue.set_used_ring_address(Some(0x3000), None);
queue.set_ready(true);
// The user should check if the queue is valid before starting to use it.
assert!(queue.is_valid(m.memory()));
// The memory object is not embedded in the `QueueStateSync`, so we have to pass it as a
// parameter to the methods that access the guest memory. Examples would be:
queue.add_used(m.memory(), 1, 0x100).unwrap();
queue.needs_notification(m.memory()).unwrap();
Trait Implementations
type G = MutexGuard<'a, QueueState>
type G = MutexGuard<'a, QueueState>
Type for guard returned by Self::lock()
.
Construct an empty virtio queue state object with the given max_size
.
Check whether the queue configuration is valid.
Get an exclusive reference to the underlying QueueState
object. Read more
Set the descriptor table address for the queue. Read more
Set the available ring address for the queue. Read more
Set the used ring address for the queue. Read more
Enable/disable the VIRTIO_F_RING_EVENT_IDX feature for interrupt coalescing.
Read the idx
field from the available ring.
Put a used descriptor head into the used ring.
Enable notification events from the guest driver. Read more
Disable notification events from the guest driver.
Check whether a notification to the guest is needed. Read more
Return the index of the next entry in the available ring.
Set the index of the next entry in the available ring.
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. Read more
Auto Trait Implementations
impl RefUnwindSafe for QueueStateSync
impl Send for QueueStateSync
impl Sync for QueueStateSync
impl Unpin for QueueStateSync
impl UnwindSafe for QueueStateSync
Blanket Implementations
Mutably borrows from an owned value. Read more