1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
//! Stable guest paths used to coordinate a live branch.
/// Directory privately inherited by each restored VM.
pub const STATE_DIR: &str = "/run/smolvm/forkpoint";
/// Marker written by the workload when it reaches a safe fork boundary.
pub const READY_PATH: &str = "/run/smolvm/forkpoint/ready";
/// First line of every supported forkpoint readiness marker.
pub const READY_VERSION: &str = "smolvm-forkpoint-v1";
/// Prefix of the per-invocation token in a readiness marker. The token lets a
/// releaser distinguish a new forkpoint from the previous helper's marker.
pub const GENERATION_PREFIX: &str = "generation=";
/// Readiness-marker capability indicating that the helper holds an advisory
/// lock on the marker for its entire parked lifetime. The agent uses the lock
/// to distinguish a live helper from a marker left behind by a killed process.
pub const READY_LEASE_HINT: &str = "ready-lease=flock-v1";
/// Optional readiness-marker capability requesting eager clone module loading.
pub const CUDA_PRELOAD_MODULES_HINT: &str = "cuda-preload-modules";
/// The agent capability the branch protocol requires: the branchpoint
/// handshake is driven by typed requests (`AgentRequest::Branchpoint*`) the
/// agent executes natively. A host refuses to branch a machine whose agent
/// does not advertise it, rather than degrading to an older mechanism.
pub const TYPED_BRANCHPOINT_CAPABILITY: &str = "branchpoint-typed-v1";
/// Error codes the agent returns for branchpoint requests, so the host can
/// act on the cause rather than parse a message.
/// Host marker that asks the branchpoint helper to enter its capture-safe loop.
pub const ARM_PATH: &str = "/run/smolvm/forkpoint/arm";
/// Helper acknowledgement that it is safe for the host to capture the vCPU.
pub const ARMED_PATH: &str = "/run/smolvm/forkpoint/armed";
/// Generation-addressed arm marker prefix.
pub const ARM_PREFIX: &str = "smolvm-forkpoint-arm-v1:";
/// Generation-addressed arm acknowledgement prefix.
pub const ARMED_PREFIX: &str = "smolvm-forkpoint-armed-v1:";
/// Marker written after a restored clone can safely enter ordinary timed waits.
pub const RESTORED_PATH: &str = "/run/smolvm/forkpoint/restored";
/// Container ID inherited with a live VM snapshot.
///
/// The restored container remains the owner of the workload's live process
/// state, but new commands must join its namespaces directly: a post-restore
/// `crun exec` can fail after trivial commands have already succeeded.
pub const RESTORED_CONTAINER_PATH: &str = "/run/smolvm/forkpoint/restored-container";
/// Marker written by the host after a clone is ready to resume.
///
/// Its first line is the release token (see [`RELEASE_PREFIX`]). A typed
/// agent appends the clone's identity as `KEY=VALUE` lines, so the helper
/// receives the go-ahead and the identity in one atomic rename and never has
/// to order this file against [`FORK_ENV_PATH`]; a marker with no such lines
/// is a clone with no parameters, such as a plain single branch.
pub const RELEASE_PATH: &str = "/run/smolvm/forkpoint/release";
/// Prefix of a generation-addressed release marker.
pub const RELEASE_PREFIX: &str = "smolvm-forkpoint-release-v2:";
/// Marker written after a released worker finishes clone-local preparation.
pub const WORKER_READY_PATH: &str = "/run/smolvm/forkpoint/worker-ready";
/// Per-clone environment installed by the host before workload release, as
/// plain dotenv (`KEY=VALUE` per line) for machine readers.
pub const FORK_ENV_PATH: &str = "/etc/smolvm/fork-env";
/// The same parameters as a shell-sourceable file (`export KEY='VALUE'`,
/// single-quoted). A workload that continues past `smolvm-branch-ready` runs
/// `. /etc/smolvm/branch-env` to take its identity into its environment.
pub const BRANCH_ENV_PATH: &str = "/etc/smolvm/branch-env";
/// Host-generated readiness token delivered through [`FORK_ENV_PATH`].
pub const WORKER_READY_TOKEN_ENV: &str = "SMOLVM_WORKER_READY_TOKEN";
/// Workload-facing helper installed in bare VMs and workload containers.
pub const HELPER_PATH: &str = "/usr/local/bin/smolvm-fork-ready";
/// Preferred branch-lifecycle alias for [`HELPER_PATH`].
pub const BRANCH_HELPER_PATH: &str = "/usr/local/bin/smolvm-branch-ready";
/// Argument that puts the agent binary into container-init mode: the reaper
/// every workload container runs as PID 1. A branch helper that finds itself
/// as PID 1 `exec`s its own binary with this argument on release, so it
/// becomes that init by construction — a fresh, single-threaded image — rather
/// than calling the reaper in-process and relying on no thread having been
/// spawned.
pub const CONTAINER_INIT_ARG: &str = "container-init";
/// `argv[0]` the helper gives that init, so it reads clearly in `ps`.
pub const CONTAINER_INIT_NAME: &str = "smolvm-container-init";
/// Helper used by a released workload after clone-local preparation finishes.
pub const WORKER_READY_HELPER_PATH: &str = "/usr/local/bin/smolvm-worker-ready";