pub struct Monitor { /* private fields */ }Expand description
One HMP session per VM run. Holds the single connection behind a mutex
so the VNC handshake, screenshot task, and idle poll of the same run
serialize instead of overlapping (fatal on single-client transports).
Create after spawn, share by reference (&Monitor) with every task.
Implementations§
Source§impl Monitor
impl Monitor
Sourcepub async fn connect(sock: &str) -> Result<Self>
pub async fn connect(sock: &str) -> Result<Self>
Connect once. Consumes the initial (qemu) greeting so Monitor::command
can write-then-read on every call. For spawn races (slow hvf init)
use Monitor::connect_retry instead.
Sourcepub async fn connect_retry(
sock: &str,
timeout_secs: u64,
alive: impl FnMut() -> bool,
) -> Result<Self>
pub async fn connect_retry( sock: &str, timeout_secs: u64, alive: impl FnMut() -> bool, ) -> Result<Self>
Keep connecting while alive() says the child lives, up to
timeout_secs. Never fails fast on a live-but-slow QEMU — the old
fixed-sleep spawn check murdered slow starters via kill_on_drop.
Sourcepub async fn command(&self, cmd: &str) -> Result<String>
pub async fn command(&self, cmd: &str) -> Result<String>
Run one HMP command; returns everything printed after it. The
connection persists across commands, so this is write-then-read:
the greeting was consumed at connect time. Reads raw bytes until
the (qemu) marker: the prompt has no trailing newline, so
line-based reads deadlock here (observed live).