Skip to content

Latest commit

 

History

History
141 lines (120 loc) · 7.56 KB

4.4-host-guest-control-interface.md

File metadata and controls

141 lines (120 loc) · 7.56 KB

4.4 Host-Guest Control Interface

Architecture documentation > 4. Guest Runtime Architecture

Managed operation uses the dedicated control console rather than the boot console. The VMM owns the outer transport: bounded framing, same-user local endpoint authorization, capability authentication, reconnect epochs, and receive-credit backpressure; see Control Console. The guest agents own the workload protocol carried inside that stream. Boot diagnostics and kernel messages stay on the consoles, so framed control traffic never shares an unstructured byte stream with them.

4.4.1 Operations

Table 4.2 lists the operations of the control protocol. nvx-init also takes a platform capture's request, and answers a restored clone's request for READY once it has applied the activation record of its restore packet, as the guest-agent guidelines' Coordinate a capture and Complete a restore before Ready describe.

Table 4.2. Control operations.

Operation Purpose
READY Reports readiness, and is the success reply to requests that return no other data
MAPS Delivers a contiguous range of host mapping-table entries
EXEC Runs one workload with a timeout, arguments, and an optional working directory and environment
CANCEL Kills the process group of the running execution that the request names
Shutdown Shuts the VM down gracefully, ending a running execution first

A mapping request carries a contiguous range of the host mapping table's entries, each with its access, a source relative to the guest's mount of the host's export, and an absolute target in the guest's root. An empty source names the export's root itself, as the table of a host whose export is one directory maps the whole directory. NVX's hosts, whose exports are aggregates of host directories and files, whose roots list them, send none, and NVX's guest agents refuse one: the MappingTable that keeps their account of the table refuses an empty source.

An execution request carries a 32-bit timeout and length-prefixed arguments, and optionally an absolute working directory of at most 4,096 bytes and up to 256 KEY=VALUE environment entries of at most 4,096 bytes each, with distinct, non-empty keys. The environment either replaces the default environment or is layered over it, each entry replacing the default variable of the same name. In version 2 of the protocol, which NVX's host and guest agents speak alone, the host streams an execution's standard input, which the guest agents acknowledge as they write it, with at most 64 KiB unacknowledged, until the host ends it, and output returns as separate standard output and standard error streams within the credit window, without a total limit. As Table 4.3 shows, an execution that runs ends with an exit report, which carries an outcome category and a status.

Table 4.3. Exit outcomes.

Outcome Meaning
exit The workload exited; the status is its exit status
signal A signal ended the workload; the status is 128 plus the signal number
timeout The workload exceeded its timeout and was killed; the status is 124
cancelled A cancellation killed the workload; the status is 137
failed The guest agents could not supervise the workload; the status is 125

Otherwise, the guest agents answer a request of Table 4.2 with an error, which carries a status and one of the categories in Table 4.4, or, while an execution runs, with BUSY, which carries neither. An error refuses a request that the guest agents cannot carry out, or takes the place of the exit report of an execution that could not start.

Table 4.4. Error categories.

Category Meaning
launch-failed The guest agents could not prepare the execution
cwd-failed The workload could not enter its working directory; the status is the error number
mapping-failed A host mapping could not be mounted
mappings-incomplete Not every announced host mapping is mounted yet
invalid-request The request is malformed or invalid in the current configuration
unsupported-operation The guest does not implement the operation

4.4.2 Feature Negotiation

The protocol negotiates nothing: every frame names its version, the guest's READY names the version that its agents speak, and NVX's host requires version 2, whose guest agents provide every behavior that the host depends on. nvx-init and the managed agent serve the control session through one dispatcher, which gives both the operations of Table 4.2. A peer of another version is refused: the host refuses a READY that names another version, and the guest agents refuse a frame of another version as a malformed one, which ends the session. Version 1, whose FEATURES request reported the control behaviors that a guest image provided, is gone.

4.4.3 Session Semantics

Requests are typed, length-bounded, ordered, and associated with one VM instance and epoch. Credit limits bound queued data in both directions. Malformed, unauthenticated, stale, duplicated, or out-of-order records fail closed. Only one execution runs at a time: while it runs, the guest agents take its standard input, a cancellation and a shutdown, and refuse any other request of Table 4.2, such as another execution or a mapping request, with BUSY. A shutdown cancels the running execution, whose exit report precedes the shutdown's acknowledgement. A reset of the session ends a running execution: the guest agents kill its process group, and report none of its output on the new session.

The control session is process-local even when guest parser state is snapshotted. Restore establishes a fresh host capability, peer identity, instance, and epoch, and the guest agents acknowledge the new instance before any host data reaches them. A request from before the capture therefore can never be replayed into a clone or a resumed process.

Secrets and per-execution environments belong on the authenticated control channel, not in the kernel command line, image layers, scratch, or snapshot metadata. Boot configuration that the machine profile owns contains only the non-secret invariants needed before the control channel exists.

4.4.4 Conformance Vectors

Conformance vectors give the bytes that every host and guest agent must produce and accept, whatever code they share. nvxc-v1.txt holds those of version 1 of the control protocol, which no peer speaks any longer: its frames, which version 2 refuses, their execution and mapping payloads, which version 2 carries unchanged, its feature payloads, and records of the session that carries them. Version 2's frames have no vector file: their tests pin their bytes. openvmm/ holds the VMM's own vectors and cases of the session's records, unchanged. A vector changes only with a protocol version, which gets vector files of its own, and the bytes of an earlier version that it refuses become its rejection vectors. Version 1 has one exception: the bytes of a mapping with an empty source were a rejection vector until an empty source came to name the export's root, for a host whose export is one directory. NVX's hosts, whose exports are aggregates, send none, and a host whose export is one directory sends one only to a guest that deploys with it, so no earlier guest receives one. The vectors' README describes their line format.