vm inspect: expose the guest console path - #202
Merged
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #201. Also applies the two review leftovers from #199.
What
vm inspect(andvm status --format json) now reportconsole_pathfor a running VM: theconsole.sockUDS (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.ToVMnow zeroes the runtime socket fields for non-running VMs. Clone and restore persist boot-time paths into the record, which previously leaked as stalesocket_path/vsock_socketon stopped clones, contradicting the documented State==running contract.ReconcileStateclears the same paths when it flips a dead-PID VM tostopped (stale), and the one-shotvm status/vm listJSON path now applies it too — a reused PTY number must not be advertised.noWatchdogpass-through and drop the unreachable clone-pathvalidateBackendFlagscall.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 toconsole.ptyin 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 FAILmake fmt-check, golangci-lint andasl ./...— 0 issues on linux and darwinToVMstale-clear + console resolution (sock preferred / PTY fallback / absent),saveConsolePTYagainst a UDSvm.infostub + UEFI skip,ReconcileStatepath clearing