Expand description
Cross-platform IPC to QEMU’s monitor (HMP) and QMP endpoints.
Unix: unix-domain sockets. Windows: named pipes (QEMU’s pipe: chardev
on the QEMU side, interprocess client on ours). One Stream type, one
connect, per-platform QEMU argv — all protocol code above this is
transport-agnostic.
Single-client transports (Windows named pipes, and QEMU’s single-slot
unix listen backlog while its main loop is busy in hvf init) mean two
rules, learned live: never probe-connect (a connect-and-drop occupies
the only slot and refuses the real handshake with ECONNREFUSED), and
never overlap sessions. Monitor enforces the second: one handle per
VM run, shared by reference with every task of that run.
NOTE (Windows): compiled, never run here — no Windows host in this lab.
Pipe names and the pipe: argv form follow QEMU docs; expect iteration.
Structs§
- Monitor
- 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.
Constants§
Functions§
- connect
- Connect to the endpoint at
path: socket path in the VM dir on Unix (filesystem-path name, used verbatim), pipe base name fromvm_endpointon Windows (namespaced name). - endpoint_
alive - True when something accepts on the endpoint (i.e. our QEMU is alive).
Advisory only: connect-and-drop, so never call it while a
Monitoror QMP session to the same endpoint is open on single-client transports (it would steal the slot / report down). All our flows drop sessions before probing — seecmd_stop. - qemu_
arg - QEMU
-monitor/-qmparg forpath:unix:vspipe:. - qmp_
alive - Backwards-compatible name used across the codebase.
- runtime_
dir - Runtime dir for sockets:
$XDG_RUNTIME_DIRon Linux (RAM, 0700, cleared on reboot),$TMPDIRon macOS (per-user, private). Never the VM dir itself:~/.cachelives on persistent (sometimes network) storage, andsun_pathcaps socket paths at 104 bytes on macOS — deep checkouts breach it. Per-VM subdirs preserve isolation. - stale_
remove - Remove a stale endpoint. Named pipes aren’t fs entries: no-op there.
- vm_
endpoint - Transport address for
namescoped tovm_dir. Unix: socket file in a per-VM subdir ofruntime_dir(private, short, never NFS home — only the dir stem travels, so deep checkouts can’t breachsun_path). Windows: bare pipe base name (flat\\.\pipe\namespace;qemu_argadds the prefix for QEMU’spipe:chardev).
Type Aliases§
- Stream
- Byte stream to a QEMU endpoint: Unix-domain socket on Unix, named
pipe on Windows. One enum from
interprocess— no platform branches at use sites.