Repository navigation
guest: make the guest's space private to the crate (SL6.13b) - #1548
Merged
Pedro Henrique Penna (ppenna) merged 1 commit intoNov 12, 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 3 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
Relocated unchanged: 0; added: 1. Compared the merge base |
Contributor
There was a problem hiding this comment.
🟢 Approval recommended
No active review issues block the change to make nvx-init’s guest-space implementation crate-private.
No open issues 🎉
What changed in this PR
This PR implements SL6.13b of #1127, making nvx-init’s guest-space implementation crate-private as part of the library slimming workstream. It preserves public mapping values and contracts while narrowing visibility without changing runtime behavior.
Changes:
- Makes guest root, view, GPT, mapper, and activation-application APIs crate-private.
- Updates documentation and activation examples to distinguish public mechanisms from nvx-init’s internal implementation.
- Adjusts test imports, preserves the GPT example as a compile-only unit test, and removes 384 hidden entries from the Linux API snapshot.
| File | Description |
|---|---|
nvx-rs/src/lib.rs |
Describes the guest space as crate-private. |
nvx-rs/src/guest/view.rs |
Makes view operations and types crate-private. |
nvx-rs/src/guest/root/tests/view.rs |
Imports NetworkError from its definition. |
nvx-rs/src/guest/root/share.rs |
Restricts share types and mounting methods. |
nvx-rs/src/guest/root.rs |
Restricts root assembly, types, and operations. |
nvx-rs/src/guest/mod.rs |
Makes root, view, and GPT modules crate-private. |
nvx-rs/src/guest/mappings/mapper.rs |
Restricts mapper types and methods. |
nvx-rs/src/guest/mappings.rs |
Narrows mapper visibility while preserving public mapping contracts. |
nvx-rs/src/guest/managed_agent/session/tests.rs |
Updates the network-error construction path. |
nvx-rs/src/guest/init/boot/tests.rs |
Updates the network-error import. |
nvx-rs/src/guest/gpt/tests.rs |
Preserves the former example as a compile-only unit test. |
nvx-rs/src/guest/gpt.rs |
Restricts guest disk-reading APIs and removes the migrated example. |
nvx-rs/src/guest/activation/state/apply.rs |
Makes activation application and related types crate-private. |
nvx-rs/src/guest/activation/state.rs |
Narrows re-exports and rewrites the example around agent-owned application. |
nvx-rs/src/guest/activation.rs |
Updates application documentation and crate-private re-exports. |
nvx-rs/README.md |
Separates private guest-space documentation from the public module overview. |
nvx-rs/public-api/linux.txt |
Removes the newly private guest-space API entries. |
doc/guest-agent-guidelines.md |
States that other inits build or adapt their own space. |
doc/acceptance-case-matrix.md |
Records the example migration and updated doctest locations. |
Review effort: Balanced
Pedro Henrique Penna (ppenna)
force-pushed
the
agents/slim-sl6-11d-space-test-only
branch
from
November 12, 2026 17:28
d929dde to
1b348b4
Compare
Pedro Henrique Penna (ppenna)
force-pushed
the
agents/slim-sl6-13b-space-private
branch
from
November 12, 2026 17:30
1fdbe71 to
451dff4
Compare
Pedro Henrique Penna (ppenna)
force-pushed
the
agents/slim-sl6-11d-space-test-only
branch
from
November 12, 2026 17:48
1b348b4 to
fb903d5
Compare
Pedro Henrique Penna (ppenna)
force-pushed
the
agents/slim-sl6-13b-space-private
branch
from
November 12, 2026 17:48
451dff4 to
5f45de3
Compare
Base automatically changed from
agents/slim-sl6-11d-space-test-only
to
feature/nvx-refactor
November 12, 2026 18:06
The guest's space, the root that nvx-init assembles and what it mounts in it, is nvx-init's internal reference code, not a library API, and the guest-agent guidelines tell other inits to build their own. It was public but hidden from the documentation, waiting until nothing outside NVX used it. SL6.13b (#1127) makes it private to the crate where it is. - guest::root, guest::view and guest::gpt become pub(crate) modules, and their items pub(crate), within the guest module's gate. - The mapper, guest::mappings::mapper with its kernel seam, becomes pub(crate). guest::mappings re-exports, crate-privately, only the items that NVX's programs use: Mapped, Mapper, MappingError, Reserved, SourceRoot, Step, TargetRoot and unbind_with. The mapping values, Mapping, Access, Kind, InvalidMapping and MAX_PATH_BYTES, and MappingTable, Refusal and TableError stay public. - The activation's application, apply, Applied, RootTemplate, ApplyError, AppliedTeardownError and NetworkError, becomes pub(crate) where it is. guest::activation re-exports apply, Applied, ApplyError and RootTemplate, which nvx-init and the managed agent use at those paths; activation::state and state::apply are crate-visible, so that the three tests that build a NetworkError import it from its definition. MACHINE_ID_FILE and RESOLVER_FILE stay public. Nothing moves, and no behavior changes: nvx-init and the managed agent keep using the space at its paths, and its unit tests stay at their owners. Paths and window_directories stay where they are. The docs and examples of snapshot and activation no longer use the space. Activation's example agent applies the record in its own space, whose result it passes to Activation::complete, and the activation's module docs describe nvx-init's application, its internal reference code, without its private names. The GPT module's example becomes the unit test a_disk_s_steps_compile, and the case matrix names it, with the doc tests' new lines. The README's module table drops root, view and gpt, whose sections move into the guest binaries' new "nvx-init's space" section, and the crate's, the guest module's, the space's and the guidelines' docs say that the space is private rather than hidden. The public API snapshot drops the space's 384 hidden lines, and still lists MappingTable and the mapping values. Part of #1127 (SL6.13b). Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Pedro Henrique Penna (ppenna)
force-pushed
the
agents/slim-sl6-13b-space-private
branch
from
November 12, 2026 18:07
5f45de3 to
27b341e
Compare
Pedro Henrique Penna (ppenna)
marked this pull request as ready for review
November 12, 2026 18:08
Pedro Henrique Penna (ppenna)
merged commit Nov 12, 2026
c0cf126
into
feature/nvx-refactor
81 of 84 checks passed
Pedro Henrique Penna (ppenna)
deleted the
agents/slim-sl6-13b-space-private
branch
November 12, 2026 18:36
This was referenced Nov 12, 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 #1127 (SL6.13b, "The guest's space is private"). Umbrella #1076.
Stacked on #1547 (SL6.11d).
What and why
The guest's space, the root that nvx-init assembles and what it mounts in it, is nvx-init's internal reference code, not a library API: the guest-agent guidelines tell another init to build its own. It was public but hidden from the documentation, waiting until nothing outside NVX used it. This PR makes it crate-private where it is, as SL6.13b's Scope says; SL6.11d (#1547), below it, first deleted the space's items that only tests used, so that none becomes dead here. One commit,
451dff46.Visibility
guest::{root, view, gpt}becomepub(crate)modules, with their itemspub(crate), inside theguestmodule's gate,all(feature = "guest", target_os = "linux").guest::mappings::mapperwith its kernel seam, becomespub(crate).guest::mappingsre-exports, crate-privately, only what NVX's programs use:Mapped,Mapper,MappingError,Reserved,SourceRoot,Step,TargetRootandunbind_with; the re-exports ofApplyError,TeardownErrorandUnmountFailure, which nothing reads at that path, go. The mapping values (Mapping,Access,Kind,InvalidMapping,MAX_PATH_BYTES) andMappingTable,RefusalandTableErrorstay public.apply,Applied,RootTemplate,ApplyError,AppliedTeardownErrorandNetworkErrorbecomepub(crate)where they are, inguest::activation::state::apply.guest::activationre-exportsapply,Applied,ApplyErrorandRootTemplate, which nvx-init and the managed agent use at those paths, and no longerAppliedTeardownErrorandNetworkError, which nothing uses there.activation::stateandstate::applybecome crate-visible, so that the three tests that build aNetworkErrorimport it from its definition.MACHINE_ID_FILEandRESOLVER_FILEstay public.Nothing moves and no behavior changes: nvx-init and the managed agent keep using the space at its paths, its unit tests stay with their owners, and
Pathsandwindow_directoriesstay where they are. rustfmt rewrapsRoot::mount_share's signature, whichpub(crate)made longer.Docs and examples
activation:Activation's example (guest/activation/state.rs) no longer usesapply,AppliedorRootTemplate: its agent applies the record in its own space,Agent::activate, and passes the result toActivation::complete, asexamples/guest-workflows.rsdoes. The module docs ofguest::activation,ActivationandActivationAction::Applydescribe nvx-init's application of a record as its internal reference code, private to the crate, without the space's names (apply,root::assemble,RootTemplate,Root::mount_export,view::apply,Applied,ApplyError).snapshot's docs and example didn't use the space; they don't change. Its repair still readsroot::Pathscrate-privately.gpt:guest::gpt's example becomes the compile-only unit testguest::gpt::tests::a_disk_s_steps_compile, as the case matrix said.lib.rs),guest's,guest::mappings', the space's own module docs anddoc/guest-agent-guidelines.mdsay that the space is private to the crate, rather than hidden until nothing outside NVX uses it.nvx::guest::{root, view, gpt}, whose sections move, as####sections, into a new "nvx-init's space" section of "Guest binaries", which says what the space is and links the guidelines' rules.nvx::guest::activation's section describes nvx-init's application without the space's names, as the rustdoc does, and dropsEntry::check, which left with SL6.11b.nvx::guest::mappings' section, the guest binaries' introduction andnvx::protocol::export's section say "private" and stop pointing other inits to the mapper.doc/acceptance-case-matrix.md):guest::gpt's doc test (line 18) names its unit test;Activation's doc test moves to line 54, with a note on its rewrite,guest::activation's to line 151 andguest's to line 33.nvx-rs/public-api/linux.txtdrops the space's 384 hidden lines, and adds none:guest::{root, view, gpt}, the mapper's items atguest::mappingsand inguest::mappings::mapper, and the application's items atguest::activationandguest::clone. It still listsMappingTable,Refusal,TableError, the mapping values, andMACHINE_ID_FILEandRESOLVER_FILE.windows.txtdoesn't change.Old tests of the area
python3 scripts/check_test_changes.py --base origin/agents/slim-sl6-11d-space-test-onlylists 3 changes to existing tests and 1 addition, so the PR has thetests-modifiedlabel:guest::init::boot::tests::a_failed_activation_ends_the_vm_with_the_status_of_its_class,guest::managed_agent::session::tests::a_failed_restored_activation_gives_init_the_status_of_its_classandguest::root::tests::view::actual_resolver_failures_keep_the_network_class_and_root_owned_bindimportNetworkErrorfrom its definition,guest::activation::state::apply, sinceguest::activationno longer re-exports it. Only the path changes.guest::gpt::tests::a_disk_s_steps_compile,guest::gpt's former example.guest::gpt's leaves for its unit test, andActivation's is rewritten, as above; the root, view, mapper and activation-apply unit tests run unchanged at their owners.Size
Measured as #1076 defines them, against SL6.11d's head
1b348b47:Every edit of a Rust file outside tests makes items crate-private, with the re-export edits that this forces and rustfmt's rewrap of one signature, or changes rustdoc only, so none counts.
Validation
The runs below ran at
1fdbe71e, on SL6.11d's earlier headd929dde4. The head,451dff46, is the same commit rebased onto SL6.11d's1b348b47, whose review fix changes only the rustdoc ofMappingTableand the mapper:git range-diffshows no change in this commit. At451dff46, these passed: on Windows,cargo fmt --all --check,cargo clippy --locked ... -- -D warningsforx86_64-unknown-linux-gnu(--all-targets --all-features, and--lib --no-default-features --features guest) and forx86_64-unknown-linux-musl(--all-targets --no-default-features --features guest),RUSTDOCFLAGS='-D warnings' cargo doc --locked --no-deps --all-features --target x86_64-unknown-linux-gnu, and the case matrix's check; onnvx-kvm-test,cargo clippy --locked --all-targets --all-features -- -D warnings,cargo test --locked --all-features --doc(14 and 1 passed),RUSTDOCFLAGS='-D warnings' cargo doc --locked --no-deps --all-featuresandpython3 scripts/public_api.py.Windows (local, at
1fdbe71e, Rust 1.95.0):cargo fmt --all --check: passed.cargo clippy --locked ... -- -D warnings, each passed:--all-targets --all-features;--lib;--lib --no-default-features;--lib --no-default-features --features serde;--lib --bins --features cli;--lib --bins --no-default-features --features testing;--all-targets --no-default-features --features guest; and, for the guest's code,--target x86_64-unknown-linux-gnuwith--all-targets --all-features,--all-targets --no-default-features --features guest,--lib --bins --features cli,--lib --bins --no-default-features --features testingand--lib --no-default-features, and--target x86_64-unknown-linux-musl --all-targets --no-default-features --features guest.RUSTDOCFLAGS='-D warnings' cargo doc --locked --no-deps --all-features, for Windows and forx86_64-unknown-linux-gnu: passed.python scripts/public_api.py --update:linux.txtdrops 384 hidden lines;python scripts/public_api.pythen passed.python scripts/check_test_layout.py,python scripts/check_markdown_links.py, and the case matrix's check against its baseline99d2022085f: passed..github/actions/validate-nvx: 1803 ran, 73 skipped, and 1 failed,test_nvx_tools.NvxRsTests.test_readme_gives_each_module_a_short_row_and_a_section, which guest: delete the process modules and cgroups (SL6.11b) #1542's and guest: delete the space items that only tests use (SL6.11d) #1547's heads fail too: since SL6.11b, the README's module table has fewer than the 41 rows that the test wants (39), and this PR's three fewer rows leave 36.Linux,
nvx-kvm-test(KVM, Azure Linux 3.0, kernel 6.6.159, Rust 1.95.0), the commands of.github/actions/check-nvx-rsat1fdbe71e, with default signal handling:cargo fmt --all --checkand the Clippy matrix, with--all-targets --no-default-features --features guestfor the host's target: passed.cargo test --locked --all-features: 1719 passed, 25 failed, 56 ignored in the library's unit tests, which run the root, view, mapper, GPT and activation-apply tests at their owners; every other target passed, the doc tests 14 of 14. The 25 failures are the same names as guest: delete the process modules and cgroups (SL6.11b) #1542's and guest: delete the space items that only tests use (SL6.11d) #1547's heads on this host, whose kernel 6.6 they need a later one for:guest::init::tests::exec(4) andguest::managed_agent::{dispatch::tests, tests::loopback::tests}(21).cargo test --locked,cargo build --locked --lib --no-default-featuresandcargo test --locked --lib --no-default-features: passed.RUSTDOCFLAGS='-D warnings' cargo doc --locked --no-deps --all-features,cargo +1.89 check --locked --all-targets --all-features(MSRV) andcargo check --locked --all-targets --all-features --target aarch64-apple-darwin: passed.python3 scripts/public_api.py: passed.python3 scripts/nvx.py check-guest-binaries --toolchain 1.95.0: Clippy passed; the musl tests 844 passed, 4 failed, the same 4guest::init::tests::execnames as guest: delete the process modules and cgroups (SL6.11b) #1542's and guest: delete the space items that only tests use (SL6.11d) #1547's heads on this host.python3 scripts/nvx.py build-guest-binariesandtest-guest-binaries: passed (33 of 33).MicroVM scenarios,
nvx-kvm-test(KVM), at1fdbe71e: the kernel built from this head in CI's Docker image (kernel-artifacts,vmlinux8b133efd…, identical to #1542's K1 kernel, withoutCONFIG_MAGIC_SYSRQ), the Alpine, Ubuntu and Azure Linux initramfs images built from this head (build-initramfs), nvx-rs built from this head, and CI run 43242544111's OpenVMM (14dc4116,75fb488d…), Ubuntu distro layer and sandbox scratch template, checked by SHA-256:test-microvm --backend kvm, unsharded: all 52 scenarios passed, 58 runs withconsole-exitandsmpat 1, 2, 4 and 8 vCPUs. Among them, the guest scenarios, the public sandboxes on EROFS and GPT roots with scratch and RAM uppers (sandbox-lifecycle,sandbox-proxy-only,sandbox-ram-upper,sandbox-gpt-layer,sandbox-blocks,managed-exec-config,vm-lifecycle), exports and mappings (filesystem-*,platform-aggregate-export,platform-filesystem), and the snapshots and restore activations (snapshot-core,snapshot-tiers,snapshot-rollback,scratch-snapshot,restore-*,platform-restore-processors,untiered-network-policy).--guest ubuntu --processors 1:guest-boot,guest-identity,console-exit,lifecycle,virtio-net,filesystem-snapshot), the Azure Linux smoke tests (--guest azurelinux --processors 1:guest-boot,guest-identity,console-exit,virtio-net,network-snapshot,workload-identity,managed-lifecycle) and the extended Ubuntu tests on KVM (--guest ubuntu:managed-lifecycle,network-snapshot,smp,workload-identity): all 20 runs passed.Code review: a review subagent read the whole diff, and found no significant issue.
Not run: the ignored privileged tests, which need root on the host; MSHV and WHP, since only the guest's code changes and it builds for Linux only; the debug kernel's suite. CI doesn't run on a Draft.
Deliberately left
guest::clone, the compatibility alias, andCaptureStage::Fence, which SL6.11c left: they don't change.scripts/nvx_tools/kernel_features.py, which namesnvx::guest::rootandnvx::guest::gptas consumers of kernel features: the modules keep their paths, and guest: delete the process modules and cgroups (SL6.11b) #1542's K1 owns the file.doc/modules, whose diagrams CI redraws.