Repository navigation
tests: run the host's order of a layered root in the adapter's host program - #875
Open
Enrique Saurez (esaurez) wants to merge 1 commit into
Open
Enrique Saurez (esaurez) wants to merge 1 commit into
Enrique Saurez (esaurez) wants to merge 1 commit into
Conversation
Contributor
There was a problem hiding this comment.
🔵 Needs a closer look
Cross-platform host-path authorization and failure-driven VM teardown warrant final human review despite no confirmed defects.
No open issues 🎉
What changed in this PR
Adds the host-side layered-root startup sequence to the runtime adapter, complementing #872’s guest-side work toward #822’s end-to-end cold sandboxes.
Changes:
- Adds authorized host shares, export validation, and mapping-table configuration.
- Checks the guest build, sends mapping parts sequentially, and waits for
Startedbefore committing; failed mappings trigger teardown. - Extends protocol, launch, and VM tests, and documents the new options and lifecycle.
| File | Description |
|---|---|
| tests/runtime-adapter/tests/vm_restart.rs | Tests build-mismatch teardown and subsequent scratch reuse. |
| tests/runtime-adapter/tests/vm_layered.rs | Checks build, mapping, and sandbox-start output. |
| tests/runtime-adapter/tests/layered_launch.rs | Tests share parsing, authorization, exports, and refusals. |
| tests/runtime-adapter/tests/host_session.rs | Tests startup ordering, mapping replies, and failure handling. |
| tests/runtime-adapter/src/root.rs | Exposes guest-path validation within the crate. |
| tests/runtime-adapter/src/lib.rs | Documents host shares and startup ordering. |
| tests/runtime-adapter/src/layered.rs | Plans authorized exports and attaches them to launches. |
| tests/runtime-adapter/src/host.rs | Adds mapping and start requests with ordered startup handling. |
| tests/runtime-adapter/src/hook.rs | Updates lifecycle step documentation. |
| tests/runtime-adapter/src/bin/runtime-adapter-host.rs | Integrates share options, startup ordering, and mapping-failure cleanup. |
| tests/runtime-adapter/README.md | Documents shares, startup behavior, exit statuses, and tests. |
Review effort: Balanced
This was referenced Oct 24, 2026
Enrique Saurez (esaurez)
force-pushed
the
esaurez/822-pr06-guest-order-20261023
branch
from
October 25, 2026 16:26
597cd3a to
e3071ec
Compare
Enrique Saurez (esaurez)
force-pushed
the
esaurez/822-pr07-host-order-20261023
branch
from
October 26, 2026 18:28
d224816 to
8031d11
Compare
Enrique Saurez (esaurez)
force-pushed
the
esaurez/822-pr07-host-order-20261023
branch
from
October 26, 2026 18:37
8031d11 to
eaa4ebf
Compare
7 tasks
Pedro Henrique Penna (ppenna)
left a comment
Contributor
There was a problem hiding this comment.
LGTM
…rogram The runtime adapter's host program sent the root configuration, took any Ready as the guest's readiness, whatever the guest agent's build, and went on to its exchanges: it shared no host path with the root, sent no mapping table, and never started the sandbox, so the worker's order had no host side, and a guest agent of another build than the host ships went on serving. launch now takes shares: --share HOST:TARGET[:ro], each a host directory or file at a guest path in the root; --deny PATH, host paths hidden inside them; --reserved TARGET, guest trees that the adapter keeps beside the container root's; and --share-root DIR, the host directories that the adapter authorizes. The new sharing module holds them as a HostFsSharing of Shares, neither of which exposes its fields: each field has a getter and a setter, and each of HostFsSharing's lists a method that adds an entry, as its option does. HostFsSharing::plan refuses a share outside the authorized directories, once links are resolved, before it plans the export with nvx::host::filesystem::plan, and checks the export's directories and files again. The launch refuses what it cannot export before it touches the store. LayeredLaunch::share attaches the export, which LayeredLaunch::export returns, and whose table the root configuration announces; LayeredLaunch::prepare checks it with ExportPlan::verify, and OpenVMM's arguments export it, as ExportPlan::openvmm_arguments renders them. Once attached, host::ready sends the root configuration and checks that the Ready names the build that the host ships; a guest agent of another build gets nothing more, and the launch fails, which ends the VM. host::start_sandbox then sends the table, each part once the guest applied the one before, with Client::map, then Start, with Client::start, and waits for Started; the launch commits only after. A part that the guest fails ends the order: the host sends no more of the table, nor Start, but Stop, which tears the root down, then waits for the VM to end, and exits with 6 once it ended with a success and a complete teardown. The order fails with an OrderError, and Client::map answers a part with a MapReply, each in a module of its own below host, which re-exports both. The launch prints build, table, mapped, and sandbox. Part of #822. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 04632931-537b-49f9-acc9-b12024ad6f3a
Pedro Henrique Penna (ppenna)
force-pushed
the
esaurez/822-pr07-host-order-20261023
branch
from
October 26, 2026 19:19
eaa4ebf to
e54abbc
Compare
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 #822 (PR 7 of 11: the host's order).
The runtime adapter's host program sent the root configuration, took any
Readyas the guest's readiness, whatever the guest agent's build, and went on to its exchanges. It shared no host path with the root, sent no mapping table, and never started the sandbox, so the worker's order (#872) had no host side, and a guest agent of another build than the host ships went on serving.Changes
Shares.
launchtakes:--share HOST:TARGET[:ro], each a host directory or regular file at an absolute guest path in the root (the guest path starts at the last:/, so Windows drive letters work);--deny PATH, host paths hidden inside the shares;--reserved TARGET, guest trees that the adapter keeps, beside the container root'sReservedTargets::CONTAINER_ROOT(nvx-rs/src/host/filesystem.rs:85-125at this base);--share-root DIR, the host directories that the adapter authorizes.The new
sharingmodule holds them as aHostFsSharingofShares, whose fields are private: each has a getter and a setter, and each list a method that adds an entry, as its option does.HostFsSharing::planrefuses a share outside the authorized directories, once links are resolved, before it plans the export withnvx::host::filesystem::planthrough anExportRequest. It then checks the export's directories and files again. The launch refuses what it cannot export before it touches the store.LayeredLaunch::shareattaches the export, whichLayeredLaunch::exportreturns, and announces its table in the root configuration's mapping count.LayeredLaunch::preparechecks the export withExportPlan::verify, and the launch's OpenVMM arguments includeExportPlan::openvmm_arguments. A launch without shares is unchanged.The order. In the new
hostorder layer:host::readysends the root configuration and waits forReady, whose build must be the one that the host ships (GUEST_BUILDunless--guest-buildnames another). A guest agent of another build gets nothing more, and the launch fails, which ends the VM.host::start_sandboxsends the table in the parts thatroot::encode_mapssplits it into, each once the guest applied the one before, thenStart, and waits forStarted. The launch commits only afterStarted.A part that the guest fails ends the order: the host sends no more of the table, nor
Start, butStop, which tears the root down. The launch then waits for the VM to end, and exits with the new status 6 once the VM ended with a success and a complete teardown; anything else exits 1.Clientgainsmap, which answers a part with aMapReply, andstart; failures are anOrderError. Each lives in a module of its own belowhost(host/map_reply.rs,host/order_error.rs), which re-exports both.The launch prints
build,table,mapped, andsandbox. The step hook'sreadystep now comes before the table, andcommitafterStarted.Tests
tests/host_session.rs, with the test broker: the order with tables of no mapping, of one, and of several parts, also in 7-byte records; another build and each root failure, after which the host sends nothing more; a table that does not encode, of which nothing is sent; a mapping failed at the first, a middle, and the last part, after which onlyStopfollows, with and without a teardown failure, and with a session that ends; wrong answers toMapsandStart, and undecodableMapFailedbodies, which end the client.tests/layered_launch.rs: share parsing; the export of a table of shares, its arguments and mapping count; the export thatprepareverifies; refusals outside the authorized directories (also through a link on Linux), of reserved targets, of a read-only share inside a read-write one, and of a missing hidden path; a launch with fake artifacts that refuses shares before it creates the store; usage errors.tests/vm_restart.rs: a launch whose guest agent is of another build is torn down, and the next launch claims the scratch image.tests/vm_layered.rschecks the new keys of every launch that starts the sandbox.Validation
On
dev(4c29c1c5, with #872 merged):On #872's head (
e3071ecf), with this PR's files unchanged since:host_session20 times on Linux and on Windows, without a failure.vm_layered25,vm_restart3,vm_steps3): WHP 31/31 and MSHV 31/31. CI runs them on KVM, MSHV, and WHP.dev: a launch with four shares applied all four mappings and started the sandbox; a launch whose mapping the guest refused exited 6 after a graceful stop withsuccess 0, and the next launch started the sandbox.After the review (
e54abbce), which moves code and adds accessors without changing behavior, on Windows: the protocol-only and host-only configurations: fmt, clippy, build, tests, MSRV. The exit statuses' enum follows in #906.Mapping tables in VMs, with the probes on the host export, follow in PR 8.