Repository navigation
guest: switch into a layered root once - #1295
Merged
Pedro Henrique Penna (ppenna) merged 1 commit intoNov 6, 2026
Merged
Pedro Henrique Penna (ppenna) merged 1 commit into
Pedro Henrique Penna (ppenna) merged 1 commit into
Conversation
Contributor
This pull request changes existing testsIt modifies or removes 4 existing test asset(s), listed below. Review each with care: a change to a test can hide a regression that the test caught. See doc/contribute.md#changes-to-existing-tests. Test code
Test policy
Relocated unchanged: 0; added: 12. Compared the merge base |
Contributor
There was a problem hiding this comment.
🟢 Approval recommended
No active review issues are recorded for the internal layered-root switch.
No open issues 🎉
What changed in this PR
Adds a one-time layered-root switch to NVX’s internal guest implementation for the future nvx-init caller in #1115, completing the SL7.1b step of #1104 without changing the public API.
Changes:
- Adds crate-private
Root::switch, moving the root mount onto/and entering it through an open descriptor. - Tracks switched state so repeat switches and teardown refuse, while dropping the root preserves its mounts.
- Adds fake-kernel and privileged tests covering failure handling, mount preservation, and mappings through pre-switch descriptors.
| File | Description |
|---|---|
scripts/test-layout-allowlist.json |
Allows the temporary dead-code expectation’s additional test hook. |
nvx-rs/src/guest/sys/spawn.rs |
Makes the existing descriptor-based root-entry helper crate-visible. |
nvx-rs/src/guest/sys/mod.rs |
Re-exports the root-entry helper internally. |
nvx-rs/src/guest/root/tests/switch.rs |
Adds four tests for switching, failures, and mount preservation. |
nvx-rs/src/guest/root/tests/privileged.rs |
Tests real root switching and mappings through retained descriptors. |
nvx-rs/src/guest/root/tests.rs |
Registers the switch test module. |
nvx-rs/src/guest/root/kernel/tests.rs |
Adds root-entry recording and failure injection to the fake kernel. |
nvx-rs/src/guest/root/kernel.rs |
Adds root entry to the kernel interface and system implementation. |
nvx-rs/src/guest/root.rs |
Implements switching, switched-state guards, and error reporting. |
nvx-rs/README.md |
Documents switching behavior and privileged test coverage. |
Review effort: Balanced
Enrique Saurez (esaurez)
force-pushed
the
esaurez/slim-2.4.1-sl7.1a-20261103
branch
2 times, most recently
from
November 5, 2026 23:28
423fed0 to
e4d4bca
Compare
Enrique Saurez (esaurez)
force-pushed
the
esaurez/slim-2.4.1-sl7.1b-20261103
branch
from
November 6, 2026 00:18
9d8fa14 to
4d5d746
Compare
Base automatically changed from
esaurez/slim-2.4.1-sl7.1a-20261103
to
feature/nvx-refactor
November 6, 2026 05:01
Part of #1104. Move the assembled root onto /, enter it through a descriptor opened before the move, then change the working directory to the new root. Once the mount moves, refuse another switch and teardown and leave all mounts in place when the root is dropped, even if entering it fails. Keep the switch crate-private until nvx-init calls it. Cover the irreversible state and failures with the kernel seam, and preserve mappings through descriptors opened before a real root switch. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 0a2abff7-0f1b-453d-80eb-f9e7f2daefaf
Enrique Saurez (esaurez)
force-pushed
the
esaurez/slim-2.4.1-sl7.1b-20261103
branch
from
November 6, 2026 07:07
4d5d746 to
203891f
Compare
Enrique Saurez (esaurez)
marked this pull request as ready for review
November 6, 2026 07:28
Pedro Henrique Penna (ppenna)
merged commit Nov 6, 2026
4114e87
into
feature/nvx-refactor
107 of 108 checks passed
Pedro Henrique Penna (ppenna)
deleted the
esaurez/slim-2.4.1-sl7.1b-20261103
branch
November 6, 2026 21:11
This was referenced Nov 7, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Part of #1104: SL7.1b. Rebased onto
feature/nvx-refactorafter #1276was squash-merged. Only this pull request's own commit was replayed; its
patch is unchanged.
What changes
Add the crate-private
Root::switchandSwitchErrorin the hiddenguest::rootreference implementation. An init can make its assembled root/once for the whole VM:/withMS_MOVE, then reuse the descriptor-basedchrootand change directory to/. A failed move leaves teardown available.the failure latch. A second switch and teardown refuse, and dropping the
root unmounts nothing, including when entering the moved root fails.
SourceRootandTargetRootdescriptors opened before the switchusable for later mappings. Required descriptors remain the caller's job.
The switch stays crate-private until nvx-init calls it in #1115, with the
prescribed dead-code expectation.
SwitchErrorandTeardownError::is_switchedstay crate-private too. The latter recognizesteardown refusal through its empty failure list, preserving the size of errors
that nest
TeardownError. The getter documentation states thatRoot::pathkeeps returning the original mount-point path after switching.
There is no new caller, reversible switch, per-execution behavior change,
runtime-mount redesign, VM view operation, crate, or public error contract.
The public-API snapshots are unchanged. The restack preserves the parent's
runtime attachment ownership and rollback changes.
Size
64 core lines in 4 production files:
root.rs(57),root/kernel.rs(5),sys/mod.rs(1), andsys/spawn.rs(1). Including the test-layout allowlist'sone policy line, the raw measurement is 65 core lines in 5 files, below the
issue's 400-line stop.
Tests
Add four fake-kernel tests in
guest::root::tests::switch:a_root_switches_once_and_its_teardown_then_unmounts_nothing,a_switched_root_that_is_dropped_unmounts_nothing,a_move_that_fails_leaves_the_root_unswitched, anda_root_whose_entry_fails_has_switched.Add the privileged
guest::root::tests::privileged::a_switched_root_keeps_its_mounts_and_maps_through_earlier_descriptors.It switches in a thread with its own root and working directories, checks the
new root and earlier mapping, maps another file through previously opened
descriptors, and checks that teardown and drop leave every mount.
All 115 existing tests listed below are kept, with their bodies unchanged;
none is renamed or retired.
check_test_changes.py --base d8f1e45dreportsfour existing-test changes:
guest::root::kernel::tests::OperationgainsEnterRootfor failureinjection, and
Callgains the corresponding recorded operation.Scene::rootinitializesswitchedto false.cfg_attr(not(test), expect(dead_code, ...))hook inroot.rs; its futurecaller removes that expectation and hook.
The 115 kept tests
Validation
Qualification uses source
203891ffe84626a584947e71a787c29119417936,on the exact feature-branch parent
d8f1e45d14dce3b525f958f52d7895b8ba2ac840, the squash merge of #1276.Earlier
4d5d7463or pinned-256ebe3dresults are not this commit'squalification.
The target subsequently advanced to
3d243e59. A nonmutating Git mergeanalysis is conflict-free; that integrated tree is not claimed as tested.
Rust, Windows and Linux: all applicable
check-nvx-rscommands passed:rustfmt, the five warning-denied Clippy feature sets, all/default/no-feature
tests and the no-feature build, synthetic bundling with
NVX_BUNDLEunset,warning-denied rustdoc, MSRV 1.89, and OpenVMM vector/CPU-profile comparisons.
The complete Linux all-feature command used serialized libtest fixtures;
assertions, test selection and timeouts were unchanged.
Linux-only Rust: the macOS check, both public-API snapshots, guest-binary
lint/tests, guest-profile build, exact source digest, static-ELF checks, and
the 39 guest-tool integration tests passed. All runtime-adapter action
commands passed in protocol-only/host-only configurations on both systems
and in the static musl guest-only configuration on Linux.
Quality: every applicable Linux
check-qualitycommand passed,including pinned shell-linter images, both Pyright platforms, Markdown links,
test layout, kernel configuration, all 25 Specula tests, and PowerShell
syntax. The quality action is Linux-only.
CLI, both systems: complete runs each reported 1814 tests and
OK,with 67 platform skips on Windows and 35 on Linux.
The canceled-capture shell test executed successfully. Both adversarial
runs reported 84 tests (11 Linux-only skips on Windows); all four
host-profile tests and every action help command passed.
Independent review: no remaining findings at this exact head.
Native runtime, WHP and MSHV: all five privileged root tests actually
executed on each backend, including the switch-and-retained-descriptor test,
with no skipped cases. All six selected microVM scenarios and teardown passed
with one processor:
managed-exec-config,sandbox-lifecycle,sandbox-proxy-only,sandbox-ram-upper,private-network-ingress, andtime-abi-conformance. The normal canonical adapter driver reported all156 scenarios across 11 targets passed on each backend, using source- and
hash-bound precompiled executables. Windows used one libtest thread; its
concurrent-clone assertions were unchanged. Consumed input hashes were
unchanged after all runs, and the post-run lifecycle guards passed.
The host CLI was built from this commit on each system. Alpine/Ubuntu
initramfses, Rust guest executables and the Ubuntu layer were built from this
commit's source. Their guest-source digest is
613df803bf776e2e88ecc9ee7ae99424ebe708c976998afc8d3ffae5b53650e6.Both native VMMs match the inherited OpenVMM revision
14dc4116ec7e57567633c4b7b07892aca3a58522. The WHP VMM was built locallyfrom that clean revision. The MSHV VMM is a checksum- and provenance-verified
native input from
v0.1.0-dev.4cfe8330e719; none of that release's guestimages or host CLIs was used as candidate proof. The kernel 6.18.38 input from
v0.1.0-dev.256ebe3dd9c2still matches this commit's kernel build inputs.The runtime and Ubuntu source-provenance validators passed.
Environment corrections touched no tests, assertions or timeouts: native
CPython 3.14.9 and Git's
usr/bin/shon Windows; private Linux PID/mountnamespaces with a reaping Bash PID 1; isolated retained temporary fixtures;
and restored tool prerequisites. Interrupted Linux attempts were not counted:
after recovering space in inactive, owned build targets, each complete
affected action command was rerun successfully. Only owned build-output
permissions and provenance placement were corrected. Read-only shared
artifacts were not changed. After the three successful Linux VM commands, an
unprivileged process-inventory postflight lacked access; the read-only inventory
was repeated with the runtime's normal privilege and confirmed cleanup. The
failed outer launcher is retained separately, not counted as a passing test
command.
KVM was not run locally. The group's full default and multi-distribution
microVM matrix remains for its final pull request and CI.