Skip to content

Commit 0258d48

Browse files
ppennaCopilot
andcommitted
doc: align the guest-agent guidelines with nvx-init
The first draft of the guidelines predates the nvx-init that feature/nvx-refactor now holds: #1453 routes the new sandbox boots to it, #1431 serves capture requests, #1447 activates repaired sessions, and #1439 keeps a restore's announcer as a helper. Check each statement against that code, and correct those that did not hold: - an execution takes the VM's one workload identity, which nvx-init resolves, or creates, once before its switch, not an account mode of its own request, which nothing selects yet; - the child also drops its capability bounding set, and nvx-init kills an execution's process group when its leader ends; - nvx-init captures only the Fresh boot of a platform capture, refuses a session with a root with ENOTSUP, and shares one 30-second deadline among its checks, its sweep and the capture; - the restored broker restarts at its first epoch with a reset queued, and nvx-init fails on anything but that reset; - the host sends no MAPS for an empty mapping table, which no nvx_maps token announces; - the crate still keeps older calls that start processes, which nvx-init does not use. Quote, and compile, the space's steps in the order of nvx-init's cold boot and restore, and replace the capture excerpt with one that handles each outcome and disposition. The steps compile in SL5.1a's unit test of nvx-init's boot, the_reference_space_steps_compile, which now holds them as the guidelines quote them, and the guidelines link SL5.1a's guest-workflows example. Organize the page by ownership, the space, the executions, the capture, the transport, the restore, failures and replay. Trim design 4.2 and 4.3 to the architecture and boundaries of nvx-init and of the older layered and blockless roots, which still run. Link the guidelines from the rustdoc of guest::activation too, list the page in the project structure, and give the case matrix the doc tests that the guidelines quote, and the lines to which the links move two others. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent 70b72ae commit 0258d48

10 files changed

Lines changed: 611 additions & 390 deletions

‎doc/acceptance-case-matrix.md‎

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ its own in turn.
3030
| [The adapter's other tests](#the-adapters-other-tests) | 166 | 0 | 9 | 157 |
3131
| [MicroVM scenarios](#microvm-scenarios) | 52 | 49 | 3 | 0 |
3232
| [CI](#ci) | 69 | 43 | 3 | 23 |
33-
| [Docs](#docs) | 34 | 33 | 1 | 0 |
33+
| [Docs](#docs) | 36 | 35 | 1 | 0 |
3434

3535
## The adapter's scenarios
3636

@@ -411,17 +411,18 @@ their own. The tests that a step runs have rows of their own where they concern
411411
## Docs
412412

413413
Rustdoc checks the code of the crate's documentation, which these rows name as rustdoc does, by
414-
file and line where this matrix was added: it compiles each, runs those that aren't `no_run`, and
415-
checks that those marked `compile_fail` don't compile. The examples compile with the crate's
416-
other targets; `host-workflows` and `guest-workflows`, which came with this matrix, are new, and
417-
have no row. The README's own code is no doctest.
414+
file and line: it compiles each, runs those that aren't `no_run`, and checks that those marked
415+
`compile_fail` don't compile. The examples compile with the crate's other targets;
416+
`host-workflows` and `guest-workflows`, which came with this matrix, are new, and have no row.
417+
The code of `guest` and `guest::snapshot`, which the guest-agent guidelines quote, came after
418+
this matrix. The README's own code is no doctest.
418419

419420
| Code | Fate | Note |
420421
| --- | --- | --- |
421-
| `nvx-rs/src/activation/mod.rs - activation (line 123)` | kept | |
422+
| `nvx-rs/src/activation/mod.rs - activation (line 130)` | kept | |
422423
| `nvx-rs/src/exec/mod.rs - exec (line 113)` | kept | Its module leaves with the exec engine (#1087), whose PR retires it |
423424
| `nvx-rs/src/gpt/mod.rs - gpt (line 43)` | kept | |
424-
| `nvx-rs/src/guest/activation.rs - guest::activation (line 189)` | kept | Its capture preparation and admission fence leave (#1087), whose PR rewrites it on `guest::snapshot::capture` |
425+
| `nvx-rs/src/guest/activation.rs - guest::activation (line 195)` | kept | Its capture preparation and admission fence leave (#1087), whose PR rewrites it on `guest::snapshot::capture` |
425426
| `nvx-rs/src/guest/activation/state.rs - guest::activation::state::Activation (line 56)` | kept | |
426427
| `nvx-rs/src/guest/cgroup.rs - guest::cgroup (line 36)` | kept | Its module leaves with the exec engine (#1087), whose PR retires it |
427428
| `nvx-rs/src/guest/entry.rs - guest::entry (line 90)` | kept | Its module leaves with the exec engine (#1087), whose PR retires it |
@@ -430,11 +431,13 @@ have no row. The README's own code is no doctest.
430431
| `nvx-rs/src/guest/gpt.rs - guest::gpt (line 18)` | kept | The guest's space becomes private (#1127), whose PR moves it to the space's unit tests |
431432
| `nvx-rs/src/guest/mappings/mapper.rs - guest::mappings::mapper (line 107)` | kept | The guest's space becomes private (#1127), whose PR moves it to the space's unit tests |
432433
| `nvx-rs/src/guest/mappings/table.rs - guest::mappings::table::MappingTable (line 47)` | kept | |
434+
| `nvx-rs/src/guest/mod.rs - guest (line 41)` | kept | The guest-agent guidelines quote it |
433435
| `nvx-rs/src/guest/nvxs.rs - guest::nvxs (line 22)` | kept | |
434436
| `nvx-rs/src/guest/process.rs - guest::process (line 12)` | kept | Its module leaves with the exec engine (#1087), whose PR retires it |
435437
| `nvx-rs/src/guest/process.rs - guest::process (line 39)` | kept | Its module leaves with the exec engine (#1087), whose PR retires it |
436438
| `nvx-rs/src/guest/reseed.rs - guest::reseed (line 17)` | kept | |
437439
| `nvx-rs/src/guest/root.rs - guest::root (line 130)` | kept | The guest's space becomes private (#1127), whose PR moves it to the space's unit tests |
440+
| `nvx-rs/src/guest/snapshot.rs - guest::snapshot (line 25)` | kept | The guest-agent guidelines quote it |
438441
| `nvx-rs/src/guest/spawn.rs - guest::spawn (line 41)` | kept | Its module leaves with the exec engine (#1087), whose PR retires it |
439442
| `nvx-rs/src/guest/spawn.rs - guest::spawn::LaunchStage::from_code (line 201)` | kept | Its module leaves with the exec engine (#1087), whose PR retires it |
440443
| `nvx-rs/src/guest/terminal.rs - guest::terminal (line 10)` | kept | |

‎doc/design/4.2-guest-agents-and-workload-model.md‎

Lines changed: 53 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -3,59 +3,69 @@
33
[Architecture documentation](README.md) >
44
[4. Guest Runtime Architecture](4-guest-runtime-architecture.md)
55

6-
The init agent is the guest's long-lived lifecycle authority. It owns the
7-
VM-wide space, helpers, control session and executions. `nvx` supplies contract
8-
parsers, capture and restore-activation mechanisms, but builds no space, runs
9-
no executions and enforces none of the reference init's lifecycle obligations.
10-
`TimeAbi::start_daemon` is the reference workflow's named daemon-fork exception,
11-
not a global no-fork guarantee for every retained API. The
12-
[guidelines](../guest-agent-guidelines.md#ownership) record the retained
13-
announcer and report-only restore-finish compatibility paths.
14-
15-
The VM-wide reference model below is `nvx-init`'s. The retained
16-
[layered sandbox root](4.1-guest-filesystem-and-image-model.md#411-layered-sandbox-root)
17-
has private execution mount, PID and UTS namespaces and sibling guest-agent
18-
and workload cgroups; the blockless managed root retains its plain-process
19-
model. Those boot paths are separate from the reference space.
6+
The guest's init agent is its long-lived lifecycle authority: it owns the
7+
guest's space, its helpers, its control session and its executions. `nvx`
8+
parses the contracts, captures the guest and drives a restore's activation,
9+
but builds no space, runs no executions and enforces none of the init's
10+
obligations; the one exception is the time daemon, which
11+
`TimeAbi::start_daemon` forks. The
12+
[guest-agent guidelines](../guest-agent-guidelines.md) give the init's
13+
contract, with nvx-init as the worked example.
14+
15+
A layered root's guest runs one of two inits. nvx-init, NVX's PID 1 for
16+
layered roots, runs the new launches, and the restores of platform captures,
17+
in one VM-wide space, as Figure 4.2 shows; it also serves the Fresh boot that
18+
a platform capture takes, which has no root yet. The older CLI launches, which
19+
carry the `nvx_lifecycle=` token, still run the older init agent, whose
20+
sandbox agent gives each execution private namespaces and a cgroup in the
21+
[layered sandbox root](4.1-guest-filesystem-and-image-model.md#411-layered-sandbox-root).
22+
The agent of the
23+
[blockless managed root](4.1-guest-filesystem-and-image-model.md#413-blockless-managed-root)
24+
is PID 1 in the guest's initramfs root, and runs its executions with
25+
nvx-init's plain-process core.
2026

2127
```mermaid
2228
flowchart TB
2329
Kernel["Linux kernel"]
24-
Agents["Init agent<br/>space and lifecycle owner"]
25-
Root["One VM-wide space<br/>root, view and mappings"]
26-
Workload["Execution children<br/>one process group each"]
27-
28-
Kernel --> Agents
29-
Agents --> Root
30-
Root --> Workload
31-
Agents -->|"supervise and reap"| Workload
32-
```
30+
Init["nvx-init, PID 1<br/>space, helpers and control session"]
31+
Space["One VM-wide space<br/>root, view and mappings"]
32+
Workload["Executions<br/>a process group each"]
3333
34-
**Figure 4.2.** Init and workload ownership in nvx-init's VM-wide reference model.
34+
Kernel --> Init
35+
Init --> Space
36+
Space --> Workload
37+
Init -->|"supervise and reap"| Workload
38+
```
3539

36-
The workload remains a child; it does not replace the init, whose continued
37-
existence supports supervision, orphan reaping and the control service.
38-
`nvx-init` is the reference implementation, using one shared root and sequential
39-
executions. An init with concurrent executions owns its own workspace
40-
coordination; the library provides no workspace trait.
40+
**Figure 4.2.** nvx-init, its space and its executions.
4141

42-
The detailed construction, execution, capture, transport and restore rules,
43-
with checked excerpts of the reference implementation, live in the
44-
[guest-agent guidelines](../guest-agent-guidelines.md).
42+
The workload is always a child of a guest agent, which never replaces itself
43+
with it: supervision, orphan reaping and the control service depend on the
44+
agent remaining alive. In a one-shot lifecycle, the guest agents start one
45+
workload, configured by non-secret kernel command-line tokens, and shut down
46+
the VM when it exits. In a managed lifecycle, they run a sequence of
47+
workloads, one at a time, on request over the authenticated control channel.
48+
An init that runs concurrent executions coordinates them for a capture
49+
itself: `nvx` provides no workspace.
4550

4651
## 4.2.1 Execution Launch
4752

48-
In nvx-init's reference model, execution launch belongs to the init, not the
49-
library's capture or activation mechanisms. Children use the VM-wide space and
50-
the init's selected credentials and working directory. This reference model
51-
has no per-execution root entry or placement barrier; the retained layered
52-
sandbox root keeps its separate execution entry and placement boundary.
53+
Launching an execution belongs to the init, not to the library's capture or
54+
activation. nvx-init's executions, and those of the blockless managed root,
55+
are plain processes of their agent: each child takes its credentials and
56+
enters its working directory itself, in its agent's space, without a root of
57+
its own or a placement barrier. The older layered sandbox root keeps its
58+
execution entry, which enters private namespaces and the workload root, and
59+
its placement barrier.
60+
[Run the executions](../guest-agent-guidelines.md#run-the-executions) gives
61+
nvx-init's steps.
5362

5463
## 4.2.2 Containment
5564

56-
For nvx-init's reference model, the VM is the isolation and resource boundary.
57-
Process groups provide an execution cleanup scope, not a namespace or cgroup
58-
containment guarantee. The init owns termination, capture admission and cleanup;
59-
no library workspace or per-execution enforcement layer supplies them. This
60-
does not remove the retained layered sandbox root's namespace and cgroup
61-
boundaries.
65+
For nvx-init and the blockless managed root, the VM is the isolation and
66+
resource boundary. An execution's process group, which its end,
67+
cancellation, timeout and reset kill, is a cleanup scope, not a namespace or
68+
a cgroup: a process that leaves the group escapes it. The init owns
69+
termination, capture admission and cleanup; no workspace or per-execution
70+
enforcement of `nvx` supplies them. The older layered sandbox root keeps its
71+
namespace and cgroup cleanup.

‎doc/design/4.3-isolation-and-resource-model.md‎

Lines changed: 65 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -5,52 +5,80 @@
55

66
## 4.3.1 Identity and Credentials
77

8-
The init owns execution identity and privilege separation from PID 1 and its
9-
helpers. Workloads use the selected non-root user and primary group, without
10-
the helpers' priority or capability privileges. Empty capability sets confer
11-
no port I/O: capture and restore repair stay on the privileged init side, not
12-
with workloads. `nvx` parses the contracts but does not enforce the reference
13-
init's execution policy. Its credential and launch sequence is specified in
14-
the [guest-agent guidelines](../guest-agent-guidelines.md#own-the-executions).
8+
The workload runs under a host-selected, non-root numeric UID and GID, which
9+
the boot fixes for the VM, or, for a restored nvx-init, its activation. The
10+
guest agents require an exact user and primary-group match in the workload
11+
root, and reject an unavailable identity before starting the workload:
12+
nvx-init resolves the account once, before it switches into its root, and the
13+
older layered sandbox root's entry checks it again for each execution. When
14+
the boot configuration requests it, nvx-init and the guest agents of the
15+
blockless managed root instead create an account for a host-selected identity
16+
that the image lacks, and replace an image account that uses the UID with
17+
another primary group or without a usable home. The older layered sandbox
18+
root creates no accounts, so it does not advertise
19+
[account creation](4.4-host-guest-control-interface.md#442-feature-negotiation).
1520

16-
## 4.3.2 Namespaces and Mounts
21+
Before the workload runs, its child clears supplementary groups and every
22+
capability set and enables `no_new_privs`, so the workload keeps none of the
23+
privileges of the guest agents and their helpers. With every capability
24+
cleared, the workload cannot perform port I/O, so only the guest agents can
25+
request a capture or acknowledge restore repair. `nvx` enforces none of this:
26+
[Run the executions](../guest-agent-guidelines.md#run-the-executions) gives
27+
nvx-init's steps.
1728

18-
In nvx-init's internal reference space, the view is VM-wide: one root, runtime
19-
filesystem set, hostname, machine ID and resolver view. It switches into that
20-
root once; executions need no separate root entry. This reference model adds
21-
no per-execution mount, PID or UTS namespaces. Its root's `/dev` omits the
22-
control device; PID 1 opens that device before the switch and retains its
23-
descriptor.
29+
## 4.3.2 Namespaces and Mounts
2430

25-
The root owns its mounts and view binds, and the init retains mapping handles
26-
across the switch. After switching, shutdown ends the VM rather than unmounting
27-
the root. The construction and ownership contract is in
28-
[Construct the space](../guest-agent-guidelines.md#construct-the-space).
31+
nvx-init's space is VM-wide: one root, with one set of runtime file systems,
32+
one hostname, machine ID and resolver file, and the host's mappings, into
33+
which PID 1 switches once. Its executions share that root and PID 1's mount,
34+
PID and UTS namespaces: no execution has a namespace or a root of its own.
35+
The root's `/dev` holds no control device: PID 1 opens it before the switch
36+
and keeps its descriptor, and the helpers, which run from the initramfs,
37+
start before the switch too. Once switched, nothing unmounts the root, and
38+
the VM ends by powering off.
39+
[Build the space](../guest-agent-guidelines.md#build-the-space) gives the
40+
space's rules.
2941

30-
The retained
31-
[layered sandbox root](4.1-guest-filesystem-and-image-model.md#411-layered-sandbox-root)
32-
still has private execution mount, PID and UTS namespaces, with the control
33-
device outside the workload's view. The blockless managed root instead uses
34-
the guest's initramfs view without those execution namespaces.
42+
The older layered sandbox root gives each workload private mount, PID, and
43+
UTS namespaces, in which every mount is private, with a private `/proc`, a
44+
read-only `/sys`, a restricted `/dev`, the workload root, only the live shares
45+
that the host declared, and the workload's machine ID and the guest's time
46+
status, bound read-only. Its guest agents never pivot away from the
47+
initramfs, so they stay outside the workload's namespaces, where they
48+
supervise and tear down the workload, and the control device is never exposed
49+
inside them. The blockless managed root runs each execution in the guest's
50+
initramfs root, in the guest agents' own namespaces, without a private mount,
51+
process, hostname, or device view.
3552

3653
## 4.3.3 Cgroups and Resources
3754

38-
For nvx-init's reference model, the VM is the resource limit. The init and its
39-
helpers have priority over workload children, not a sibling cgroup reservation.
40-
This reference model configures no cgroups or per-execution limits. Its sole
41-
additional limit is the RAM upper's cap; scratch and host-device access keep
55+
For nvx-init and the blockless managed root, the VM is the resource limit:
56+
they configure no cgroups and no per-execution limits. nvx-init runs PID 1 and
57+
its helpers ahead of the executions, whose children give up that priority,
58+
instead of reserving memory for them in a sibling cgroup. Its one limit
59+
within the VM is the RAM upper's cap; the scratch and the host's devices keep
4260
their own storage boundaries.
4361

44-
The retained layered sandbox root keeps sibling guest-agent and workload
45-
cgroups, workload memory/PID accounting and cgroup writeback. Its soft
46-
supervisor memory protection is not a survival guarantee. The blockless
47-
managed root has no execution cgroup; these retained boundaries are not
48-
replaced by the reference model.
62+
The older layered sandbox root keeps sibling guest-agent and workload cgroups.
63+
The workload is placed in its cgroup behind a barrier before it is released.
64+
The guest agents' cgroup carries a default memory protection of 16 MiB, a
65+
soft reservation that shields the supervisor from reclaim under workload
66+
memory pressure but does not guarantee its survival. The workload cgroup
67+
carries optional memory and process-count limits and is the unit of capture
68+
freeze, termination, and descendant cleanup. When the overlay's upper is in
69+
guest memory, the files that the workload writes into its root are charged to
70+
the workload cgroup, so its memory limit also bounds them; see
71+
[Layered Sandbox Root](4.1-guest-filesystem-and-image-model.md#411-layered-sandbox-root).
4972

5073
## 4.3.4 Enforcement Layers
5174

52-
The init applies the guest's credentials and space contract; the library does
53-
not enforce its workspace, capture-admission or replay obligations. Host
54-
devices independently enforce block mutability, network policy and
55-
host-filesystem access. Guest mounts and routing cannot widen those host
56-
permissions.
75+
Isolation has two enforcement layers:
76+
77+
- Guest policy, which the init applies and `nvx` does not enforce: the
78+
workload's credentials and capabilities, the mounts of its space, and, in
79+
the older layered sandbox root, its namespaces and cgroups.
80+
- Host devices independently enforce block mutability, network policy, and
81+
host-filesystem access.
82+
83+
The guest cannot widen a host policy by remounting a filesystem, changing a
84+
route, creating a link, or issuing a different device request.

0 commit comments

Comments
 (0)