Skip to content

vm inspect: expose the guest console path - #202

Merged
CMGS merged 4 commits into
masterfrom
fix/watchdog-nits-console-path
Aug 26, 2026
Merged

vm inspect: expose the guest console path#202
CMGS merged 4 commits into
masterfrom
fix/watchdog-nits-console-path

Conversation

@CMGS

@CMGS CMGS commented Aug 26, 2026

Copy link
Copy Markdown
Contributor

Closes #201. Also applies the two review leftovers from #199.

What

  • vm inspect (and vm status --format json) now report console_path for a running VM: the console.sock UDS (UEFI serial, Firecracker relay) or the Cloud Hypervisor-allocated PTY (direct-boot OCI), refreshed on every start/clone/restore. External supervisors that cannot open the owner-only CH API socket can record where to read a VM's console.
  • ToVM now zeroes the runtime socket fields for non-running VMs. Clone and restore persist boot-time paths into the record, which previously leaked as stale socket_path/vsock_socket on stopped clones, contradicting the documented State==running contract.
  • ReconcileState clears the same paths when it flips a dead-PID VM to stopped (stale), and the one-shot vm status/vm list JSON path now applies it too — a reused PTY number must not be advertised.
  • feat(cloudhypervisor): make watchdog policy configurable #199 leftovers: inline the clone-side noWatchdog pass-through and drop the unreachable clone-path validateBackendFlags call.

Mechanism

Pidfile-style: the console UDS resolves by a stat at inspect time; the direct-boot PTY is queried once per boot via vm.info (after resume, best-effort) and saved to console.pty in the run dir, which joins the CH runtime-file list for cleanup. Inspect and list stay free of API calls — the hot-path cost is one stat plus one small file read per running VM, the same class as the existing pidfile read. Boot paths pay one sub-ms UDS GET plus a buffered ~20-byte write, direct boot only. A VM booted by an older cocoon reports the path from its next start (documented).

Validation

  • go test ./... — 34 packages ok, 0 FAIL
  • make fmt-check, golangci-lint and asl ./... — 0 issues on linux and darwin
  • New tests: ToVM stale-clear + console resolution (sock preferred / PTY fallback / absent), saveConsolePTY against a UDS vm.info stub + UEFI skip, ReconcileState path clearing

CMGS added 4 commits August 26, 2026 09:59
CloneVMConfigFromFlags passes the snapshot policy straight through, so
the local only existed for the removed override branch. The clone-path
validateBackendFlags call is unreachable by construction: every knob it
gates is inherited from the snapshot, and create already rejects them
on Firecracker.
Consumers driving cocoon over the CLI cannot query the CH API socket
(0700, owner-only) to find where a VM's console lives. Inspect now
reports console_path for running VMs: the console.sock UDS (UEFI
serial, FC relay) resolved by a stat, or the CH-allocated PTY for
direct boot, which each boot path (start, clone, restore) queries once
via vm.info after the VMM is up and saves to console.pty in the run
dir, pidfile-style. Inspect and list stay free of API calls; boot
paths pay one vm.info GET plus a small buffered write, direct boot
only, after resume.

ToVM now also zeroes the runtime socket fields for non-running VMs:
clone and restore persist boot-time paths into the record, which
previously leaked as stale socket_path/vsock_socket on stopped clones,
contradicting the documented State==running contract.
ReconcileState flips a dead-PID VM to stopped (stale) for display, but
ToVM had already populated socket_path/vsock_socket/console_path from
the persisted Running state; a reused PTY number could point a
supervisor at another process's terminal. Clear the paths at the flip.
statusOnce serialized ToVM output directly, so vm status/list
--format json skipped the dead-PID flip and its runtime-path
clearing that inspect, table, and event modes already apply.
@CMGS
CMGS merged commit 3980067 into master Aug 26, 2026
4 checks passed
@CMGS
CMGS deleted the fix/watchdog-nits-console-path branch August 26, 2026 03:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

vm inspect: expose the guest console path

1 participant