Skip to content

nvx-rs: capture preparation in the guest, and template mode in the test adapter's guest #840

Closed

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-snapshot checks the host-configured tier, reads the generation ID, runs nvx-time pre-capture, freezes the workload cgroup (and the scratch, when paired), then runs nvx-time capture. A successful capture ends the source VM (guest/common/nvx-snapshot:256-280, :448-497).
  • nvx::guest::time::TimeAbi::capture(CaptureRequest) returns CaptureOutcome::Continued or CaptureOutcome::Restored(Restore) (nvx-rs/src/guest/time/api.rs:96-160, :264-355). time::system saves 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, with CapturePreparation. The caller supplies its workload-admission fence and the device identities of distro, the scratch and the filesystem tag.
  • CapturePreparation::prepare returns an owned CaptureBarrier after 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 from distro, 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::capture calls TimeAbi::capture with the platform tier's request. It returns Captured::Continued, for a source that keeps running, with the barriers released, or Captured::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; cancel and 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/cmdline early, through nvx::protocol::cmdline::parameters. With nvx_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. CaptureError maps 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.

Metadata

Metadata

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions