Skip to content

Snapshot/restore workstream: start sandboxes from captured templates through the shared host and guest libraries #833

Closed
3 of 3 issues completed

Description

Objective. Let a sandbox start by restoring a template instead of booting. A template is a tenant-free VM, captured once after boot and before any tenant input. Each restore becomes a separate sandbox, a clone, with its own image, upper, export, network settings and identity. The shared host and guest libraries that #535 delivered get clones, and the in-repo test adapter (tests/runtime-adapter) proves them. NVX's own adapter (its CLI and its guest init) gets them in stage 5 (#837), outside this issue. The cold path stays as it is.

Today (dev d04d9fb) and after:

Area Today After
Starting a sandbox Every sandbox cold-boots, and its guest assembles the root from boot tokens. A sandbox can also start as a clone of a template.
Snapshot support nvx-rs run restores a raw OpenVMM snapshot on the terminal, and test scripts drive platform snapshots. nvx::host has no capture, template store or clone restore. nvx::host captures templates into a store and restores clones from it, for both adapters.
Guest at capture The shell nvx-snapshot requests captures. The layered init mounts the image, the scratch and the overlay first, so no capture can come before root assembly. Template mode captures before root assembly: no image, overlay, workload or application session.
Guest after a restore Shell tools repair time, CPUs, memory and entropy. The guest keeps its captured configuration and binds, and takes the first 32 hex digits of the seed's SHA-256 as its machine ID. Repair runs in-process, through nvx::guest. Each clone then gets its own configuration in an Activate message, and assembles its root through the same nvx::guest::root operations as a cold boot.
Host control The host attaches, then asks for readiness. NVXC v1 has no Activate. The host connects after OpenVMM's restore-ready event, sends Activate on a restricted session, checks that Ready reports the activation applied, with its transaction ID, then sends MAPS and Start.
Image A disk's size is its file length, and a restore needs a disk of exactly the captured length. The clone's image replaces the template's placeholder distro. With zero fill, OpenVMM presents the placeholder's size and reads zeros past a shorter image.
Upper A platform capture needs an unmounted scratch disk, and a RAM upper can't be captured. Every template has a dormant scratch device, and each clone picks tmpfs or the scratch at activation. A scratch clone brings its own scratch file; with zero fill, a tmpfs clone brings none.
CPUs and memory Restore can grow memory, but a platform snapshot keeps its boot CPU count. Memory targets per clone, and CPU targets per clone with #801.
Network A restore needs the captured policy, and snapshots refuse ingress, host loopback and forwards. A per-clone policy on a deny-all template, with #536, including ingress, host loopback and forwards.
Exports A restore keeps the binds that its boot made. A dormant filesystem slot accepts one directory at restore. Zero or one export per clone, on the dormant slot: one directory at first, then an aggregate of directories and files with #540. MAPS binds paths inside it after Ready.
Hashing A platform capture hashes each read-only disk by default, then discards the hash. Captures pass OpenVMM's generation identity flags, so capture and restore hash no large content.

Design.

Stages. Stages 1 to 3 need nothing of NVX's own binaries, so they start and finish with the test adapter. This issue tracks them. Stage 4 is the NVX library wiring workstream (#816), which also holds stage 5 (#837) and the acceptance for both adapters (#855).

Stage Issue Content Needs
1 #834 The libraries on today's OpenVMM, through the test adapter, under interim rules The PRs of #822 and #805 that #834 lists, and #860's PR 1, before its VM work
2 #835 The OpenVMM changes: zero fill (#856), CPU targets for platform snapshots (#796), a new network policy at restore (#536) and an aggregate export at restore (#540) —
3 #836 Their features in the libraries and the test adapter. Each removes an interim rule. Stage 1, and each item's OpenVMM change in NVX's pin
4 #816 The NVX library wiring workstream: NVX's binaries and tools move onto the shared libraries That workstream's own order
5 #837, in #816 NVX's adapter, with every stage 3 feature from the start, then the acceptance Stage 1; stage 3, unless an OpenVMM change is late (#837's fallback); #817, #818, #820, #821 and #624

Dependencies on the NVX library wiring workstream (#816). That workstream keeps this work; the snapshot/restore workstream depends on it explicitly:

Issue in #816 Needed by For
#822, with #805 #843, #845, #841, #844, #846, #847 The test adapter end to end, in stacked PRs that #834 lists: the adapter plan and checked handoff, executions in the VM, Ready, MAPS and Start in order, the export mount, and network policy
#860 #845 A layered root's resolver, and runtime binds that a teardown can remove (its PR 1)
#817 #852 NVX's Rust layered init, which gets template mode
#818 #853 The CLI's image formats and protected paths
#820 #853 The guest build ID, in the compatibility key
#821 #851 NVXC v2 with a validated Ready, which embeds #838's ReadyActivation and reserves the Activate request's type
#624 #855 The acceptance harness

In the other direction, #821's Ready embeds #838's ReadyActivation, so #838 comes first.

Dependencies on OpenVMM. Four OpenVMM changes, described in #835. Each lets a stage 3 item remove one of stage 1's interim rules:

Change Tracking Needed by Until it lands
Zero fill: a platform restore presents the template's distro capacity and reads zeros past a shorter image; a fresh scratch declared absent reads zeros and fails writes #856 #848 Images of exactly the placeholder's length; a sparse scratch file for each tmpfs clone
CPU targets for platform snapshots, and the authentication timer during a gated restore #796, fixed by PR #801, which is stacked on #797 #849 One template per CPU count; the host connects after the restore-ready event
A new network policy at restore, for deny-all templates #536 #850 One template per network policy, with no ingress, host loopback or forwards
An aggregate export on the dormant filesystem slot at restore #540 #857 One directory export per clone: an export plan with several children, or a file child, is refused before launch

Children and order. Each stage's issue lists its PR issues. Stage 1's issues each split their work into stacked PRs, which #834 orders. Stage 5's PR issues stay children of #837, which is under #816.

Issue Stage Scope Needs
#838 1 The activation record and Ready's activation —
#839 1 The compatibility key, the template store and leases —
#840 1 Capture preparation, and template mode in the test adapter's guest —
#841 1 Template lowering, capture and publication #839, #840; #822
#842 1 Repair of a restored clone in the guest #840
#843 1 The restricted control state, Activate, and Ready's activation and transaction #838, #842; #822
#844 1 Clone restore through Activate, Ready and Start #841, #843; #822
#845 1 Root activation: every image format and upper, the export, DNS and the proxy, and the workload view #844; #822, #860
#846 1 Exports, MAPS and network templates #845; #822
#847 1 The test adapter's template and clone operations #846; #805
#856 2 Zero fill: zeros past a shorter image, and an absent scratch —
#536 2 A new network policy at restore; #796 is referenced above —
#540 2 An aggregate export on the dormant filesystem slot at restore —
#848 3 Shorter images, and tmpfs clones without a scratch Stage 1; #856
#849 3 Per-clone CPU targets Stage 1; #801
#850 3 Per-clone network policies Stage 1; #536
#857 3 Aggregate exports for clones Stage 1; #540
#851 5 Activate, and the restore transaction in Ready, in NVXC v2 Stage 1; #821
#852 5 Template mode, repair and activation in NVX's init #851, stage 3 or #837's fallback; #817
#853 5 The CLI's template and clone commands #852; #818, #820
#854 5 NVX's clone scenarios and documentation #853
#855 5 Acceptance for both adapters #854, every stage 3 item; #624

Not in scope:

Acceptance. Stages 1 to 3's (#834, #835, #836): the test adapter runs platform clones end to end through the shared code on KVM, MSHV and WHP, for every image format and upper, with every stage 3 feature and no interim rule. The acceptance for both adapters, with bundled serving the release that includes this work, is #855's, under #837.

Related:

Activity

  1. changed the title [-]Platform clones: start sandboxes from captured templates through the shared host and guest libraries[/-] [+]Snapshot/restore workstream: start sandboxes from captured templates through the shared host and guest libraries[/+] on Oct 24, 2026
  2. ppenna commented on Oct 29, 2026

    @ppenna
    Contributor

    Stages 1 to 3 are complete in dev (6b485c82), so this issue stays closed. It now tracks only them: its objective, stages and acceptance say so. NVX's own adapter, stage 5 (#837), and the acceptance for both adapters (#855) continue in the NVX library wiring workstream (#816), which also holds stage 4.

    Stage Issue In dev
    1 #834 All 30 PRs that #834 orders are merged: #871, #873 and #874 (#838); #879, #881, #885 and #886 (#839); #877 and #932 (#840); #884, #887 and #933 (#841); #880, #936 and #937 (#842); #939, #940 and #941 (#843); #888, #949, #950, #951 and #954 (#844); #957, #959 and #960 (#845); #955 and #958 (#846); #962 and #963 (#847). #956 and #961 were folded into #955, #957 and #959. What stage 1 needs from #816 is in dev too: #822's and #805's PRs, and #860's PR 1 (#876).
    2 #835 microsoft/openvmm#4749, microsoft/openvmm#4735, microsoft/openvmm#4767 and microsoft/openvmm#4775 are ancestors of NVX's pin, c32c57d1, through #901, #801, #931 and #948, as #835's last comment shows.
    3 #836 #925 (#848), #926 (#849), #978 (#850) and #992 (#857) are merged: shorter images and an absent scratch, --restore-processors, --restore-network-policy and --mount-aggregate. No interim rule remains in the code or the documentation.

    Tests. tests/runtime-adapter/scenarios.txt names the stage's suite, which CI's "Guests and sandboxes" jobs run on each backend. It passed on KVM, MSHV and WHP in run 40943638955, at dev with #992's stack, before #953, #1011 and #1016 merged. The tree that the merges left, 6fb8b242, is that of run 40948332355, which was cancelled, and no run on it has completed yet: the dev runs queued for the merges will cover it. Run 40959568606, at d0498448, skipped the Linux suites after an unrelated failure in scripts/test_nvx_rs_mutants.py, which #1023 fixed, and was cancelled before WHP's finished.

    Remaining work, elsewhere:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

No labels
No labels

Type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions