Repository navigation
nvx-rs: capture preparation in the guest, and template mode in the test adapter's guest #840
Description
Parent: #834 (#833), steps 1 and 2. Needs: nothing; its VM tests run with #841. Unblocks: #841, #842.
Goal. A template's guest captures before root assembly, through a typed preparation in nvx::guest that a privileged guest agent can call without being PID 1. The test adapter's guest gets a template mode that uses it.
Today (dev d04d9fb):
- The shell
nvx-snapshotchecks the host-configured tier, reads the generation ID, runsnvx-time pre-capture, freezes the workload cgroup (and the scratch, when paired), then runsnvx-time capture. A successful capture ends the source VM (guest/common/nvx-snapshot:256-280,:448-497). nvx::guest::time::TimeAbi::capture(CaptureRequest)returnsCaptureOutcome::ContinuedorCaptureOutcome::Restored(Restore)(nvx-rs/src/guest/time/api.rs:96-160,:264-355).time::systemsaves and restores the stall detectors' settings: RCU stalls, soft lockups and hung tasks (nvx-rs/src/guest/time/system.rs:104-108,:473-507).- NVX's layered init assembles the root first, so no capture can come before root assembly. The test adapter's guest runs a PID 1 that supervises a worker, which assembles the root when the host sends
RootConfig(tests/runtime-adapter/src/bin/runtime-adapter-guest.rs,src/worker.rs:518-601,src/frame.rs).
Stacked PRs. PR 2 builds on PR 1; each lands with its own tests.
PR 1 of 2: capture preparation in nvx::guest. Step 1; needs nothing.
- A new module,
nvx::guest::clone, withCapturePreparation. The caller supplies its workload-admission fence and the device identities ofdistro, the scratch and the filesystem tag. CapturePreparation::preparereturns an ownedCaptureBarrierafter it:- fences workload admission through the caller's fence, so that no execution starts;
- checks, with a bounded read of
/proc/self/mountinfo, that nothing is mounted fromdistro, the overlay, the scratch or the filesystem tag; - waits for the time ABI's boot checks, runs the capture checks, and suppresses the stall detectors through
time::system.
CaptureBarrier::capturecallsTimeAbi::capturewith the platform tier's request. It returnsCaptured::Continued, for a source that keeps running, with the barriers released, orCaptured::Restored, which hands the restore result to repair (nvx-rs: repair a restored clone in the guest, with an owned seed and one acknowledgment #842), with the detectors still suppressed. For a platform template, OpenVMM ends the source VM after the capture, so only clones return from it.CaptureBarrier::cancel, and dropping the barrier, release the fence and restore the detectors.- A typed
CaptureError, with the stage and the cause. - Tests, with fakes for
mountinfo, the fence and the time ABI: the order (the fence before the checks, and the detectors suppressed before the capture); each mount that blocks a capture;canceland drop restore the detectors and release the fence.
PR 2 of 2: template mode in the test adapter's guest. Step 2; needs PR 1.
- The guest reads
/proc/cmdlineearly, throughnvx::protocol::cmdline::parameters. Withnvx_snapshot_tier=platform, it accepts only the platform allowlist's tokens, and refuses any other. - It skips root assembly, attaches the control session with
nvx::guest::nvxs::GuestConnection::attach, and runs the preparation and the capture. No application session runs before the capture. - A restored guest continues with repair. Until nvx-rs: repair a restored clone in the guest, with an owned seed and one acknowledgment #842 lands, it shuts down with a documented status.
CaptureErrormaps to the guest's exit status. - Tests: template mode refuses a token outside the allowlist. nvx-rs: lower, capture and publish platform templates #841's captures run this mode in VMs on KVM, MSHV and WHP.
Not in scope: NVX's init (#852); repair (#842); the host's capture (#841).
Guide (#591's numbering): 3.1.3 (the snapshot request), 5.3.2 (guest preparation, before root assembly), 5.3.6 (the guest's barriers), 4.1.4 (template mode skips the managed layered root's assembly).
Done when: both PRs are merged with their tests.
Activity
guest: prepare a template's guest for a capture before root assembly
guest: keep a clone's admission closed until repair, and own the supp…
guest: keep the suppression record when a failed save cannot undo itself
guest: let a retained port permission outrank a failed restore
guest: report a capture's failure to restore the detectors
Integrate #887 with #840 PR 2 for #841 PR 3
guest: prepare a template's guest for a capture before root assembly
guest: keep a clone's admission closed until repair, and own the supp…
guest: keep the suppression record when a failed save cannot undo itself
guest: let a retained port permission outrank a failed restore
guest: report a capture's failure to restore the detectors