pub struct NetworkFrameQueues {
pub guest_to_host: ArrayQueue<Vec<u8>>,
pub host_to_guest: ArrayQueue<Vec<u8>>,
pub guest_wake: WakePipe,
pub host_wake: WakePipe,
pub relay_wake: WakePipe,
/* private fields */
}Expand description
Shared queues and wake handles for the host-side virtio-net runtime.
One NetworkFrameQueues is shared across all helper threads for a single
guest NIC.
A useful mental model is:
queues = ownership transfer for frame bytes
wakes = "go look at the queue now"
shutdown= sticky flag + wake all blocked waitersFields§
§guest_to_host: ArrayQueue<Vec<u8>>Raw ethernet frames emitted by the guest and waiting for smoltcp.
host_to_guest: ArrayQueue<Vec<u8>>Raw ethernet frames emitted by smoltcp and waiting for libkrun.
guest_wake: WakePipeWake the smoltcp poll loop when a guest frame arrives.
guest_wake and relay_wake deliberately share one underlying poller:
the smoltcp loop blocks on that single poller and either wake unblocks
it. The loop re-runs its whole pipeline on every wakeup, so it does not
need to know which side fired.
host_wake: WakePipeWake the libkrun writer thread when a host frame is ready.
relay_wake: WakePipeWake the smoltcp poll loop when a TCP relay thread has new data.
Implementations§
Source§impl NetworkFrameQueues
impl NetworkFrameQueues
Create a new shared queue set wrapped in Arc.
Sourcepub fn add_egress_bytes(&self, n: u64)
pub fn add_egress_bytes(&self, n: u64)
Add n guest-outbound bytes to the egress counter. Relaxed ordering is
fine: the counter is a monotonic statistic, not a synchronization point.
Sourcepub fn egress_bytes(&self) -> u64
pub fn egress_bytes(&self) -> u64
Cumulative guest-outbound bytes for this NIC since boot.
Sourcepub fn egress_counter(&self) -> Arc<AtomicU64>
pub fn egress_counter(&self) -> Arc<AtomicU64>
A cheap, cloneable read handle to the egress counter, for a flush thread
owned by the launcher (the runtime itself is not Clone).
Sourcepub fn begin_shutdown(&self)
pub fn begin_shutdown(&self)
Mark the runtime as shutting down and wake all waiters.
The wakes are part of shutdown correctness. Without them, a thread blocked waiting on socket readiness could sleep indefinitely even though the shutdown flag was already set.
Sourcepub fn is_shutting_down(&self) -> bool
pub fn is_shutting_down(&self) -> bool
Whether shutdown has been requested.