Repository navigation
tests: enforce the runtime adapter's networks in VMs - #883
Open
Enrique Saurez (esaurez) wants to merge 2 commits into
Conversation
This was referenced Oct 24, 2026
Contributor
There was a problem hiding this comment.
🟢 Approval recommended
The test-only changes have no identified blocking issues and check network behavior using positive controls and host-side observations.
No open issues 🎉
What changed in this PR
Adds VM-level network enforcement tests for the runtime adapter, completing the network validation portion of #822 on top of #882’s execution settings.
Changes:
- Adds six scenarios covering denied traffic, allow rules, proxy-only access, host-loopback access, and port forwarding.
- Uses open-network positive controls and host-side traffic checks to distinguish policy enforcement from broken probes.
- Documents the scenarios, dynamic port selection, and listener-publication checks.
| File | Description |
|---|---|
tests/runtime-adapter/tests/vm_layered.rs |
Adds network scenarios, host socket fixtures, traffic probes, and listener checks. |
tests/runtime-adapter/README.md |
Documents network enforcement coverage and the test setup. |
Review effort: Balanced
The layered scenarios check what each kind of network lets the guest's executions reach, as NVX's proxy-only scenario probes its network: a network that denies everything, which attaches no network device; an allow rule; a proxy-only network, whose other destinations never arrive; outbound host-loopback access, which publishes no listener of the guest; and host-loopback access in both directions, through which the host reaches a listener of the guest, at its port or through a forward. Before the launch, the test binds the host's side of the network, whose ports the network names, each drawn at random from the dynamic range: a test proxy on host loopback, and the sockets of the probes' destinations. A scenario whose network stops traffic first boots a VM of an open network over the same sockets, the positive control, in which every probe arrives and the host reaches the guest's listener. Each VM with a network has its network devices checked, and that OpenVMM asks /init to publish the guest's listeners exactly where the root configuration says that they are published. The scenarios' guest moves to 192.0.2.2/24, in a range reserved for documentation, so that no host's own address is on its network, and the proxy-only network's proxy is the test proxy, at a port of its own. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: a7c15634-094a-4a66-af59-25a58e732f4b
Enrique Saurez (esaurez)
force-pushed
the
esaurez/822-pr11-network-enforcement-vms-20261023
branch
from
October 24, 2026 21:09
a992b8f to
6a46c2a
Compare
The VM scenarios run at the same time. The host's side of a network draws the ports of a listener of the guest and of a forward, then releases them, since OpenVMM binds them only once it runs, and again for the scenario's VM after the positive control's. Another scenario could draw the same ports in between, and one of the two VMs would then fail to bind them. Each host's side now holds the ports that it drew, in a set that the scenarios share, until its scenario ends, and draws none that another holds. A scenario that ends confirmed that its VMs ended; one that fails keeps its ports for good, since one of its VMs might still run. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: a7c15634-094a-4a66-af59-25a58e732f4b
Enrique Saurez (esaurez)
force-pushed
the
esaurez/822-pr11-network-enforcement-vms-20261023
branch
from
October 24, 2026 21:34
2a000ad to
b3c6c74
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.

Stacked on #882; this PR retargets when its parent merges.
Chain: #863 → #867 → #869 → #865 → #864 → #872 → #875 → #878 → #862 → #868 → #870 → #866 → #882 → #883 (this PR).
Part of #822: PR 11 of 11, enforcement in VMs (C4).
What changed
Tests only, in
tests/vm_layered.rs, with the adapter's README. The layered scenarios check what each kind of network lets the guest's executions reach, on NVX's Ubuntu EROFS image over a scratch, as NVX's proxy-only scenario (scripts/nvx_tools/sandbox_proxy_tests.py) probes its network:a_denied_network_lets_no_probe_through: a network that lets nothing through, which attaches no network device, and in which an execution reaches neither the test proxy nor any destination;an_allow_rule_lets_only_its_destination_through: egress denied but for one rule, TCP to a port of host loopback at the gateway, which alone arrives;a_proxy_only_network_lets_only_its_proxy_through: an execution reaches the test proxy through the URL in its environment, while the other destinations never arrive;outbound_host_loopback_publishes_no_listener: outbound host-loopback access, through which an execution reaches host loopback, while the host does not reach the guest's listener, which OpenVMM does not publish;allowed_host_loopback_publishes_the_listeners: host-loopback access allowed, with egress denied, through which the host reaches the guest's listener at the guest's port of host loopback, while an execution reaches nothing;a_forward_reaches_its_guest_port: the host reaches the guest's listener through a forward of a port of host loopback.How:
Host, whose ports the network names, each drawn at random from the dynamic range and free on every host address and on loopback: a test proxy on host IPv4 loopback, which the guest reaches at the same port of its gateway, and the sockets of the probes' destinations: another port of host loopback over TCP, the proxy's port over UDP, and the proxy's port over TCP at the host's own address and on host IPv6 loopback, where the host has them. Scenarios run at the same time, so eachHostholds the ports that it drew until its scenario ends, or for good if the scenario fails, and draws none that another holds: OpenVMM binds the ports of a listener and of a forward only once it runs, and again for the scenario's VM after the positive control's.Expect::Controlled: a VM of an open network over the same host's side, in which every probe arrives and the host reaches a listener of the guest. The host then discards what is left at its sockets, and the scenario's own VM runs the same checks, so that what does not arrive there shows the network's policy, not a broken probe. The control's VM is staged, launched, and checked as every scenario's: the table applied, its mappings counted, and the sandbox started./initon the kernel command line to publish the guest's listeners exactly where the root configuration says that they are published.192.0.2.2/24, in a range reserved for documentation, so that no host's own address is on its network; the proxy-only network's proxy is the test proxy, at a port of its own.Validation
vm_layered(43 scenarios: runtime adapter: run cold sandboxes end to end on KVM, MSHV and WHP #822's and runtime adapter: settle executions through cgroups and run them in a VM #805's 35, tests: give the runtime adapter's executions their network's settings #882's 2, and these 6),vm_restart(3), andvm_steps(3) on WHP (local) and MSHV (Linux x86_64, as root).tests/runtime-adapter:cargo fmt --all --check; the protocol-only and host-only configurations'cargo clippy --locked --all-targets [--features host] -- -D warnings,cargo build --locked,cargo test --locked, andcargo +1.89 check --locked --all-targets.tests/runtime-adapter: the same, plus the guest-only configuration (--features guest --target x86_64-unknown-linux-musl): clippy, build, tests, and the MSRV check; the guest-only library andguest_sessiontests as root; and a stress run ofguest_session, 10 times as root and 10 times as a user, and of the library's tests, 3 times as root.python scripts/check_markdown_links.py.dev, KVM's VM tests included; a stacked PR runs no NVX CI.