[nanvixd] E: Enable HTTP mode on Windows#18
Open
esaurez wants to merge 1 commit into
Open
Conversation
esaurez
commented
May 18, 2026
esaurez
commented
May 18, 2026
esaurez
commented
May 18, 2026
| return Err(anyhow::anyhow!("wrong usage")); | ||
| }, | ||
| #[cfg(unix)] | ||
| #[cfg(any(unix, windows))] |
Owner
Author
There was a problem hiding this comment.
WE are only supporting unix or windows, so I think this config is now redundant
esaurez
commented
May 18, 2026
|
|
||
| #[test] | ||
| fn resolve_windows_sink_path_includes_pid() { | ||
| ::std::env::remove_var("NANVIXD_GUEST_STDIO_DIR"); |
Owner
Author
There was a problem hiding this comment.
Update test based on the fix to the other comment
esaurez
commented
May 18, 2026
5fe718c to
f9252b4
Compare
f9252b4 to
03203a8
Compare
esaurez
commented
May 19, 2026
esaurez
commented
May 19, 2026
esaurez
commented
May 19, 2026
esaurez
commented
May 19, 2026
| /// - Unix: Unix-domain socket path | ||
| /// - Windows: Named pipe path (e.g. `\\.\pipe\nanvix-standalone-gw-<pid>`) | ||
| /// | ||
| /// In standalone mode this is always populated regardless of OS. |
Owner
Author
There was a problem hiding this comment.
This comment is probably unnecessary and confusing
esaurez
commented
May 19, 2026
| /// Optional GDB server port for debugging the guest. | ||
| #[cfg(feature = "gdb")] | ||
| gdb_port: Option<u16>, | ||
| /// Optional path at which to expose the **gateway endpoint** — a |
Owner
Author
There was a problem hiding this comment.
Another comment that may need to be rewritten to not include information about how this was implemented, but focus on only on the aspects that matter for the code.
esaurez
commented
May 19, 2026
| {allow_host_networking} Enable host networking for the guest (disabled when \ | ||
| omitted).{gdb_port_line} | ||
| omitted). | ||
| {gateway_sockaddr} <path> (Standalone) Expose the gateway endpoint at <path>. \ |
Owner
Author
There was a problem hiding this comment.
what is the gateway endpoint? It would be clear ohn what this does, and what it is useful for
* nanvixd accepts -http-addr <sockaddr> on Windows. Drops the cfg(unix) gates in args.rs and main.rs and the cfg(windows) bail block that previously refused the flag. * nanvix-http becomes an unconditional workspace dependency in src/libs/nanvix/Cargo.toml. The pub re-export in nanvix/lib.rs is no longer cfg(unix)-gated. * nanvix-http server uses a cross-platform shutdown signal future: SIGINT on Unix, tokio::signal::ctrl_c() on Windows. * nanvix-http standalone serve_new exposes a cross-platform gateway endpoint -- Unix-domain socket on Unix, named pipe on Windows -- with a single gateway_bridge_task pumping bytes between the connected client and the guest's IKC channels on both OSes. The accept primitive differs (UnixListener vs tokio NamedPipeServer); the bridge body is generic over AsyncRead/AsyncWrite via a shared run_bridge helper. * New -gateway-sockaddr CLI flag in nanvixd lets the caller pick the endpoint path explicitly. When unset, nanvix-http falls back to a per-process default (/tmp/nvx-standalone-gw-<pid>.sock on Unix, \\.\pipe\nanvix-standalone-gw-<pid> on Windows) so nanvix-bench and nanvix-terminal continue to work without the flag. * NewResponse.gateway_sockaddr keeps its wire name; the doc comment is updated to describe the cross-platform semantics (UDS path on Unix, named pipe path on Windows). * doc/run-linux.md: short note that the shim manages -console-file and -gateway-sockaddr. The cross-platform gateway endpoint must ship with the HTTP-mode unblock: io_handler in uservm::standalone::handle_write_request always sends guest stdout/stderr through output_tx, expecting a consumer to read output_rx. Without the gateway every guest write returns -1, CPython exits 120, pods die ~60s after boot with no diagnostic trail. The Windows shim cannot drive nanvixd without HTTP, and HTTP-mode requires the gateway consumer; both must land together to avoid an intermediate state that breaks every networked workload. Tests: * New nanvixd args::tests cover -http-addr parsing on every target, mutual-exclusion / required-mode validation, and -gateway-sockaddr parsing (default None, missing-value error). Verified end-to-end on Win Server 2025: containerd shim spawns nanvixd, posts NEW, the guest application binds a TCP port and serves traffic via the shim's gateway-pipe consumer. Future rename suggestion (out of scope here): 'gateway' is overloaded across deployment modes; a follow-up could rename the standalone variant to 'host_io' across both repos. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
03203a8 to
3052d99
Compare
This was referenced May 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
Enables HTTP mode for
nanvixdon Windows and lifts the standalone gateway endpoint from a Unix-only Unix-domain socket to a single cross-platform endpoint (UDS on Unix, named pipe on Windows). Samegateway_bridge_taskruns on both OSes; only the binding primitive differs. This is the structural change the Nanvix containerd shim needs to drivenanvixdend-to-end on Windows.What changed
Enabling HTTP mode on Windows
nanvixd: drop thecfg(unix)gates around-http-addrparsing/validation inargs.rsand around the HTTP-mode block inmain.rs::async_main. Remove thecfg(windows)bail!block that previously refused the flag.src/libs/nanvix/Cargo.toml:nanvix-httpbecomes an unconditional workspace dependency (nooptional, notarget.'cfg(unix)'.dependencies); feature lines drop the?suffix onnanvix-http?/x.src/libs/nanvix/src/lib.rs: thepub use nanvix_http as http;re-export is no longercfg(unix)-gated.nanvix-http::server: replace the eagertokio::signal::unix::signal(SignalKind::interrupt())with a pinned cross-platform shutdown future — SIGINT on Unix,tokio::signal::ctrl_c()on Windows. Unix behaviour is preserved.Cross-platform standalone gateway endpoint
nanvix-http::client::standalone::serve_new: replace the Unix-onlyUnixListener/gateway_bridge_taskpair with a cross-platformGatewayEndpointenum (Unix(UnixListener)on Unix,Pipe { server: NamedPipeServer }on Windows). The accept primitive differs per-OS; the bidirectional pump is shared via a genericrun_bridge<R: AsyncRead, W: AsyncWrite>helper.bind_gateway_endpoint(&path)anddefault_gateway_path()per-OS helpers:/tmp/nvx-standalone-gw-<pid>.sock\\.\pipe\nanvix-standalone-gw-<pid>0600so only the owner can connect (closes a pre-existing world-accessible-socket hole —UnixListener::bindinherits the process umask, typically 0755/0775).gateway_sockaddrfield onRunningVmis only used to populate theNEWresponse, and is therefore annotated#[cfg_attr(windows, allow(dead_code))].New
-gateway-sockaddrCLI flagnanvixdaccepts an optional-gateway-sockaddr <path>flag (with matchingStandaloneConfig::gateway_sockaddrfield and accessor) so callers can pre-allocate a predictable per-VM endpoint path. When unset,nanvix-httpfalls back to the per-process default above, preserving existingnanvix-bench/nanvix-terminalbehaviour without any flag.NewResponse.gateway_sockaddrkeeps its wire name; the doc comment is updated to describe the cross-platform semantics (UDS path on Unix, named pipe path on Windows).Documentation
doc/run-linux.mdgets a short note that the shim manages both-console-fileand-gateway-sockaddritself; any value passed inextra_argsis stripped with a warning.Why this matters
The Nanvix containerd shim drives
nanvixdexclusively over HTTP (NEW/KILL/READYrequests). Without this PR:nanvixdrefuses to start in HTTP mode on Windows; the shim'swait_for_servertimes out on every pod create.uservm::standalone::handle_write_requestalways pushes guest stdout/stderr throughoutput_txexpecting a consumer to drainoutput_rx. Without a consumer, every guest write returns-1, CPython raisesBrokenPipeErrorat shutdown, and pods exit 120 about a minute after boot with no diagnostic trail.The cross-platform gateway endpoint must ship in the same change as the gating removal — splitting them would land an intermediate state that breaks every networked workload on Windows.
Tests
New
nanvixd::args::testscover:parses_http_mode_with_sockaddr—-http-addron every target.parses_interactive_mode—--separator still works.rejects_both_http_and_interactive/rejects_neither_http_nor_interactive— mutual-exclusion / required-mode rules.parses_gateway_sockaddr_flag—-gateway-sockaddr <path>is captured.gateway_sockaddr_is_none_when_unset— default isNone.rejects_gateway_sockaddr_without_value— missing-value error message.z.ps1 build,z.ps1 build -- format-check,z.ps1 build -- lint-check, andz.ps1 build -- spellcheckall pass on Windows.End-to-end verification
Tested on Win Server 2025 with the Nanvix containerd shim and a CPython HTTP-server pod:
nanvixd.exe -http-addr <addr> -gateway-sockaddr \\.\pipe\nanvix-standalone-gw-<container-id> ….wait_for_server()succeeds; shim POSTsNEW, then connects to the per-sandbox gateway pipe.0.0.0.0:9999, and servesHello from Nanvix!to a probe inside the L2Bridge HCN compartment.print()output reachescrictl logs.Notes for reviewers
-gateway-sockaddrflag.get_stderr_writeron Windows (independent; lets-console-fileaccept\\.\pipe\…).serve_killwaits for VM exit before aborting the bridge (stacked on this PR; logically correct on both platforms; only user-visible on Windows once this PR lands).nanvixd -log-to-stdoutflag (independent; lets the shim capturenanvixd's own logrus output).host_io) across both repos in one coordinated change.chmod 0600on the gateway UDS, which closes a pre-existing world-accessible-socket hole. The only Unix-visible refactor is the cross-platform shutdown-signal future, which still routes SIGINT exactly like before.