pub struct VirtioNetworkRuntime { /* private fields */ }Expand description
Running host-side virtio-net runtime for one guest NIC.
Ownership model:
- one runtime instance corresponds to one guest virtio NIC
- it owns the queue set shared by the worker threads
- it owns the libkrun Unix-stream bridge threads
- it owns the published-port listener threads
- it owns the smoltcp poll thread
Dropping the runtime is the shutdown signal. Drop marks the shared queues
as shutting down, wakes blocked workers, and joins the poll thread.
Implementations§
Source§impl VirtioNetworkRuntime
impl VirtioNetworkRuntime
Sourcepub fn egress_bytes(&self) -> u64
pub fn egress_bytes(&self) -> u64
Cumulative guest-outbound (egress) bytes on this NIC since boot, at the ethernet-frame level. The launcher polls this to surface per-machine egress to the node API for billing. TSI VMs have no virtio runtime, so egress is unavailable for them (a documented metering gap).
Sourcepub fn egress_counter(&self) -> Arc<AtomicU64>
pub fn egress_counter(&self) -> Arc<AtomicU64>
A cheap, cloneable read handle to this NIC’s egress counter, so the
launcher can spawn a thread that periodically flushes the value to the
VM’s runtime dir for the node API to read (the runtime is not Clone).
Sourcepub fn block_until_shutdown(self)
pub fn block_until_shutdown(self)
Take ownership of the runtime and block until the libkrun stream closes
(the frame reader marks the queues shutting down on EOF), then drop it for
a graceful shutdown. Used on Windows, where the runtime is built on the
accept thread: that thread parks here so the runtime — and its worker
threads — live for the whole VM lifetime instead of being dropped at the
end of the accept callback.