Repository navigation
nvx-rs: parse fake OpenVMM --mount-child values with one function - #613
Merged
Pedro Henrique Penna (ppenna) merged 1 commit intoOct 20, 2026
Merged
Conversation
The fake OpenVMM reads --mount-child NAME,HOST,MODE[,file] values on two paths: sandbox_shares, for the children of a sandbox's aggregate at /run/nvx/shares, and mapped_children, for the children of the host mapping table's export. Each repeated the same parser: split off the name, strip the file flag, split off the mode, check that the host path is a directory or, with the flag, a regular file, check that the mode is ro or rw, and fail with "invalid --mount-child VALUE". The copies differed only in that mapped_children also requires each name to be the child's index. mount_child_host now holds that parser once and takes the index that the name must match, if any. Both loops shrink to one line each, and the two option paths can no longer drift apart in the syntax that they accept. Behavior is unchanged. Every refusal keeps its message, the checks and the filesystem probes run in the same order, mapped_children still requires each name to be its index, and sandbox_shares still accepts any name. A new unit test pins the accepted children and each refusal, which no existing test reaches. The lifecycle scenarios of the CLI golden tests share directories and a file through a sandbox aggregate, and the aci_edge_sandboxes fake-OpenVMM tests map directories and files, so existing tests drive both callers. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Contributor
There was a problem hiding this comment.
🟢 Approval recommended
The focused refactor preserves existing behavior, with regression coverage and no identified blocking issues.
No open issues 🎉
What changed in this PR
Consolidates duplicate --mount-child parsing in the test-only fake OpenVMM while preserving both callers’ validation and error messages.
Changes:
- Extracts
mount_child_hostand uses it for sandbox shares and mapped children. - Adds regression coverage for valid inputs and validation failures.
| File | Description |
|---|---|
nvx-rs/src/testing/fake_openvmm.rs |
Shares mount-child parsing between callers and adds focused tests. |
Review effort: Balanced
Pedro Henrique Penna (ppenna)
deleted the
nvx-rs-quality/fake-mount-child
branch
October 20, 2026 00:19
This was referenced Oct 20, 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.
Summary
The fake OpenVMM (
nvx::testing::fake_openvmm) parsed--mount-child NAME,HOST,MODE[,file]values with two copies of the same parser: one insandbox_shares, for the children of a sandbox's aggregate at/run/nvx/shares, and one inmapped_children, for the children of the host mapping table's export. This change keeps that parser once, in the private functionmount_child_host, so that the fake's two option paths accept the same syntax by construction. The production--mount-childproducers and OpenVMM itself are untouched.Changes
All in
nvx-rs/src/testing/fake_openvmm.rs:mount_child_host(child, index)returns the host path of a--mount-childvalue, or fails withinvalid --mount-child VALUEunless the host path is a directory or, with thefileflag, a regular file, the mode isroorrw, and, ifindexis given, the name is that index.sandbox_sharescalls it without an index, for the children of a sandbox's aggregate, whose names are digests;mapped_childrencalls it with each child's index, for the numbered children of the host mapping table.mount_children_resolve_to_hosts_of_their_kindcovers the accepted directory and file children, a child without an index, and each refusal: another name, a file without the flag, a directory with it, a missing host path, another mode, a missing mode, and a value with only a name.Behavior
Nothing observable changes:
invalid --mount-child VALUE, and every other message of the fake is untouched.fileflag, splits off the mode, probes the host path withis_fileoris_dir, and then checks the name, the kind, and the mode, as the condition ofmapped_childrendid.mapped_childrenstill requires the names0,1, ... in order, andsandbox_sharesstill accepts any name.testingfeature. No public API,ErrorKind, protocol byte, golden fixture, guest binary, ornvx-rsCLI changes; the CLI build (--features cli) doesn't compile this module.Existing tests drive both callers: the CLI golden lifecycle scenarios
lifecycle: several sharesandlifecycle: file share, in both the POSIX and Windows sections oftests/fixtures/cli.json, run the fake with directory and file children of a sandbox aggregate, andaci_edge_sandboxes/tests/openvmm_fake.rsmaps directories and files through the host mapping table.Follow-ups
The survey turned these up, and this change leaves them alone.
sandbox_sharesaccepts--mount-aggregate /run/nvx/shareswithout any--mount-child, and repeated child names, while OpenVMM'sMicrovmFilesystemConfig::new_aggregaterefuses both (InvalidChildCountandDuplicateChildName), andmapped_childrenrefuses an aggregate without children. The fake's sandbox path is thus more lenient than OpenVMM. Making it strict changes what the fake accepts, so it wants its own change.host/session.rs,features,map_host_paths, andnext_exec_eventrepeat the request-ID check with the same message,map_host_pathsandnext_exec_eventtruncate an error category to 64 characters the same way, andpingandstopdiffer only in their request and reply kinds and their message.host/sandbox/mount.rs,MountAccess,MountOwner, andMountKindrepeatfrom_namewith the same message form,unsupported sandbox mount WHAT 'NAME'; choose A or B, andhost/sandbox/mount/tests.rsandhost/sandbox/tests.rsdefine the samepolicytest helper.Instance::runtimeandInstance::launchinhost/instance.rs;host/filesystem.rs,host/network/mod.rs, andhost/sandbox/options/tests.rs;host/process.rsandhost/cli/sandbox/identity.rs;console_pending.rsandmmio_write.rs,run_fileandrun_networkindevice_io.rs, thedevice_iohelper intests/guest_tools.rs, and the time tools' watcher-violation sites and port-window lock failures.Validation
2fc63e7465decee7a7764e937472d0f7416d9c82,origin/devwhen the run started.b976a1f3140a207ae31bcd82ddb439e72150c20a, the tree of this commit, applied as a patch on BASE on each host.v0.1.0-dev.ff95973ba9da, whichnvx.py downloadinstalled on each host as the nearest released first-parent ancestor of BASE, with OpenVMMd0bdbed8f6e3b86271277dc22658109e2e633b2d, the pinned revision.build-guest-binaries, rantest-guest-binarieson them, and built the Alpine initramfs from them withNVX_GUEST_BINARIES. All three hosts ran the sameinitramfs.cpio.gz(SHA-256b5832af0e8e9985ed4d0e684253be3ec03956f960b36c133ac26daa2e900598b), package manifest, and provenance. Each host also rebuilt thenvx-rsCLI from TREE and recorded its provenance before its hypervisor tests.cargo fmt --check; Clippy with-D warningsfor all targets and features and for the library without default features;cargo testwith all features and with the defaults; and rustdoc with-D warnings. This machine also ran the steps for which the hosts lack a toolchain or target: the Rust 1.89 MSRV check of both crates on Windows, and theaarch64-apple-darwincheck of both crates, which CI runs on Linux.check-guest-binariesbuild-guest-binaries,test-guest-binaries, andbuild-initramfspassdirectories_on_another_volume_are_mappedpasses by skipping on hosts without a second volume, as on all three.Left to CI: the
test-microvmscenarios that run only when named (smp-lapic,managed-exec-config, andsandbox-lifecycle), the Ubuntu and Azure Linux guests, the OpenVMM suites, guest determinism, benchmarks, and check-quality and validate-nvx, which this change doesn't affect: it changes no Python, shell, or Markdown file, and adds, moves, or deletes none.