Repository navigation
nvx-rs: expose optional native control transport handles - #1258
Merged
Merged
Conversation
Let native adapters duplicate the verified control connection without reconnecting or requiring an asynchronous runtime in nvx. Keep custom transports compatible with a default no-handle result, and document the ownership and shared blocking-mode requirements. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 6ad5bb7a-f74a-4ef1-9f3a-bca77b23c8a6
Contributor
There was a problem hiding this comment.
🟢 Approval recommended
No active review issues remain for the optional native transport-handle changes.
No open issues 🎉
What changed in this PR
Adds optional native control-transport handles so asynchronous adapters can reuse NVX’s existing peer-verified connection without reconnecting or introducing an async runtime dependency.
Changes:
- Adds
Transport::try_clone_handleand platform-specific owned handle aliases, with a defaultOk(None)for compatibility. - Implements Unix socket and Windows named-pipe duplication, documenting that the original transport must be dropped before using the duplicate.
- Adds tests for fallback behavior, independent ownership, connection reuse, and EOF after the last handle closes.
| File | Description |
|---|---|
nvx-rs/src/host/platform/windows/endpoint/tests.rs |
Tests duplicated pipe ownership, connection reuse, and EOF. |
nvx-rs/src/host/platform/windows/endpoint.rs |
Implements native pipe handle duplication. |
nvx-rs/src/host/platform/tests.rs |
Tests the default fallback for custom transports. |
nvx-rs/src/host/platform/mod.rs |
Defines the optional cloning API, handle aliases, and usage contract. |
nvx-rs/src/host/platform/linux/tests.rs |
Tests socket duplication after endpoint removal, ownership, and EOF. |
nvx-rs/src/host/platform/linux/endpoint.rs |
Implements native Unix socket duplication. |
nvx-rs/README.md |
Documents native handles and adapter handoff requirements. |
Review effort: Balanced
Enrique Saurez (esaurez)
marked this pull request as ready for review
November 4, 2026 01:51
Pedro Henrique Penna (ppenna)
approved these changes
Nov 4, 2026
Pedro Henrique Penna (ppenna)
left a comment
Contributor
There was a problem hiding this comment.
LGTM
This was referenced Nov 4, 2026
longhun12346
pushed a commit
to longhun12346/nvx
that referenced
this pull request
Nov 6, 2026
microsoft#1258 added two public items, the trait method host::platform::Transport::try_clone_handle and the type alias host::platform::TransportHandle, while microsoft#1261 was in review, so the public-API snapshots that microsoft#1261 committed lack them, and the API check fails on dev. Regenerate both snapshots with scripts/public_api.py --update: each gains those two lines and nothing else. Part of microsoft#1091. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: c2e22d0d-c583-4401-a947-31781d4fec41
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.
Add the optional
Transport::try_clone_handleAPI on Linux and Windows.Native transports duplicate their existing peer-verified Unix socket or
overlapped named-pipe connection rather than reconnecting. The default
Ok(None)preserves compatibility for transports without native handles.Document that callers must drop the blocking transport before using or
registering the duplicate, or changing the shared blocking mode. No async
runtime dependency, release version, lockfile, or existing deadline behavior
changes.
New tests cover the default fallback, independent handle ownership, reuse of
the same verified connection after the original transport is dropped, and
peer EOF after the last duplicate is dropped. The Linux test also removes
the listening endpoint before duplication. Existing tests are unchanged.
Validation
On Rust 1.95.0, with
NVX_BUNDLE=skipexcept for the synthetic bundle fixture:cargo test --lockedcargo build --locked --lib --no-default-featuresandcargo test --locked --lib --no-default-featuresCounts include integration tests and doctests where the command runs them.
Also passed:
check-nvx-rs: formatting; all-feature/default/protocolClippy with warnings denied; rustdoc with warnings denied; Rust 1.89 MSRV;
and the independent runtime adapter's protocol-only and host-only matrix.
adapter's protocol-only, host-only, and static musl guest-only matrices.
The built static guest tools passed all 38 integration tests.
four explicit pinned-source comparisons: 232 passed, 15 expected ignored.
The remaining static-musl guest integration/doctest targets: 90 passed,
4 expected ignored.
all four explicit comparisons with the pinned OpenVMM vectors/profiles.
and recommended approval, with no open issues or review threads.
Linux kernel execution context
The local WSL 5.15 kernel lacks the semantics needed by three existing guest
tests: unique mount IDs and
pidfd_openreturningESRCHfor a reaped groupleader. These failures were reproduced on untouched
dev, then all threeunchanged tests passed on the pinned Linux 6.18.38 kernel under local WHP.
The complete all-feature library used the same Cargo-built executable
in two exhaustive, disjoint groups:
guest::group, including protocol guest-codec tests:735 passed, 13 existing ignored.
All 1,870 enumerated test names are accounted for; no test was omitted.
The host group runs where host
/proc/*/ioaccounting and curl are available;the guest group runs on NVX's actual guest kernel. Full static-musl guest
library coverage also passed there. Ordinary-user execution matches CI;
normal Unix device links, devpts, and fixture-directory prerequisites were
prepared only inside disposable test VMs.
No test assertions, capability guards, kernel configuration, or CI policy
were changed, and shared WSL configuration was untouched.
CI result
The full ready-triggered CI run
passed on
a7318b77adad1e3f7e06873eea096bc2a883e365: all 34 selected jobssucceeded, including both standard Rust matrices and
Required status check.The nine conditional skips match the existing pull-request/pin-selection
policy; none is an unexpected missing gate. This is the completed ready run,
not the earlier draft-skipped graph. Both requested reviews remain clean.