[nanvix] Add Linux/KVM Support#445
Merged
Merged
Conversation
ppenna
force-pushed
the
user/ppenna/nanvix-kvm-support
branch
from
May 28, 2026 03:50
fd59aa6 to
d05e1b1
Compare
Contributor
There was a problem hiding this comment.
Pull request overview
Adds Linux/KVM support for the NanVix MicroVM backend, aligning the Rust runtime and build/staging pipeline with the existing Windows/WHP implementation, and introduces a Linux-focused E2E test suite plus new test configs.
Changes:
- Extends
NanVixScriptRunnerand staging logic to compile/run on Linux (cold-boot via KVM; Windows keeps snapshot warm-start). - Adds Linux E2E tests that invoke
lxc-execwithcontainment=microvm, along with new Linux microvmtest_configs/. - Updates build + binary acquisition to support Linux NanVix artifacts (new versions/checksums layout) and adds a
--with-microvmoption tobuild.sh.
Show a summary per file
| File | Description |
|---|---|
| test_configs/microvm_hello_linux.json | New Linux MicroVM “hello” config. |
| test_configs/microvm_exit_code_linux.json | New Linux MicroVM exit-code propagation config. |
| test_configs/microvm_multiline_linux.json | New Linux MicroVM multi-line script config. |
| test_configs/microvm_stdlib_linux.json | New Linux MicroVM stdlib import/use config. |
| test_configs/microvm_large_output_linux.json | New Linux MicroVM large-output config. |
| test_configs/microvm_error_linux.json | New Linux MicroVM exception config. |
| test_configs/microvm_timeout_linux.json | New Linux MicroVM timeout config. |
| src/wxc_e2e_tests/tests/e2e_linux_microvm.rs | Adds a Linux MicroVM E2E suite + perf output + stress test. |
| src/wxc_e2e_tests/src/lib.rs | Adds Linux target triples and helpers to locate/run lxc-exec + prerequisites (/dev/kvm, staged NanVix binaries). |
| src/wxc_common/src/nanvix_runner.rs | Splits Windows vs Linux runner behavior; Linux KVM cold-boot; Linux watchdog uses SIGKILL. Adds unit tests. |
| src/wxc_common/src/microvm_staging.rs | Fixes Linux absolute-path handling by stripping leading slashes; updates/adds tests. |
| src/wxc_common/src/lib.rs | Builds microvm modules when feature="microvm" is enabled (now not Windows-only). |
| src/wxc_common/Cargo.toml | Moves microvm deps out of Windows-only section; adds Linux-only libc dep. |
| src/nanvix_common/src/lib.rs | Adds platform-conditional REQUIRED_BINARIES + NANVIXD_BINARY; extends repo config for Linux; updates checksum loader to accept platform-keyed format. |
| src/nanvix_binaries/versions.json | Bumps pinned tag; adds Linux asset/binaries fields. |
| src/nanvix_binaries/checksums.json | Restructures checksums into { windows: {...}, linux: {...} } with updated hashes. |
| src/nanvix_binaries/build.rs | Adds Linux download/extract/verify flow for tar.gz assets; retains Windows snapshot pre-generation behavior. |
| src/lxc/src/main.rs | Wires ContainmentBackend::MicroVm for lxc-exec behind --experimental and the microvm feature. |
| src/lxc/Cargo.toml | Adds microvm feature (pulls in wxc_common/microvm + nanvix_binaries) and a build-dependency on nanvix_common. |
| src/lxc/build.rs | Copies staged NanVix artifacts next to the built lxc-exec when microvm is enabled. |
| src/Cargo.lock | Updates dependency graph for new feature/deps. |
| docs/nanvix-microvm/nanvix.md | Documents Linux/KVM prerequisites and clarifies Windows-only snapshot warm-start. |
| build.sh | Adds --with-microvm and composes features with --with-hyperlight. |
Copilot's findings
Comments suppressed due to low confidence (1)
src/wxc_common/Cargo.toml:48
- On Linux,
libcis only used by the MicroVM watchdog path (nanvix_runner), but it is currently an unconditional dependency for all Linux builds ofwxc_common. Making it an optional dependency enabled by themicrovmfeature would avoid pullinglibcinto non-microvm builds.
[target.'cfg(target_os = "linux")'.dependencies]
libc = { workspace = true }
- Files reviewed: 22/23 changed files
- Comments generated: 3
ppenna
marked this pull request as draft
May 28, 2026 03:54
ppenna
force-pushed
the
user/ppenna/nanvix-kvm-support
branch
2 times, most recently
from
May 28, 2026 06:25
8910e8f to
8e98fd0
Compare
ppenna
marked this pull request as ready for review
May 28, 2026 15:18
huzaifa-d
reviewed
May 28, 2026
huzaifa-d
reviewed
May 28, 2026
huzaifa-d
approved these changes
May 28, 2026
huzaifa-d
approved these changes
May 28, 2026
Extends the Nanvix MicroVM containment backend to run on Linux via KVM,
mirroring the existing Windows/WHP implementation. The `lxc-exec` binary
gains a `microvm` containment option behind the `microvm` cargo feature
and the `--experimental` runtime flag.
Runtime (src/wxc_common/src/nanvix_runner.rs)
- Split runner internals along target_os: Windows keeps WHP snapshot
warm-start; Linux cold-boots the VM via KVM on every invocation
(no snapshot, no `-snapshot`/`-bin-dir` args; cwd set to exe dir).
- Generalize watchdog: `usize` carries a duplicated process HANDLE on
Windows and the child PID on Linux; on timeout, Linux delivers
SIGKILL via `libc::kill` instead of `TerminateProcess`.
- Gate snapshot resolution, `NANVIX_HOME`, `DEFAULT_HOME_LEAF`, and
`SNAPSHOT_CBOR` behind `cfg(target_os = "windows")`.
- Use `nanvix_common::NANVIXD_BINARY` for the platform-correct daemon
name (`nanvixd.exe` / `nanvixd.elf`).
- New unit tests: signal-killed copyback skip, platform constant check,
total_timeout sentinel/overflow, NanVixError display variants.
Staging (src/wxc_common/src/microvm_staging.rs)
- Fix `host_path_to_guest_relative` to strip leading slashes so Linux
absolute paths (`/tmp/xyz`) become guest-relative (`tmp/xyz`).
- Update existing rewrite test to handle the Linux case where the host
path is a substring of the guest path; add two new tests covering
leading-slash stripping.
lxc binary (src/lxc)
- Add `microvm` feature that enables `wxc_common/microvm` and depends
on `nanvix_binaries` so KVM artifacts are downloaded/staged.
- New `build.rs` copies the staged Nanvix artifacts next to `lxc-exec`
using `nanvix_common::copy_artifacts_to_target` and
`DEP_NANVIX_BINARIES_BIN_DIR`.
- Wire `ContainmentBackend::MicroVm` in main.rs: gated by
`--experimental`, returns `NanVixScriptRunner` when compiled with
`microvm`, otherwise exits with a clear error.
nanvix_binaries (src/nanvix_binaries)
- Build script now handles `target_os = "linux"` in addition to
Windows: downloads `microvm-standalone-256mb.tar.gz`, extracts flat
binaries from `<prefix>/` and kernel files from `<prefix>/bin/` via
`tar --strip-components`, and verifies SHA256 sums using
`sha256sum`. Snapshot pre-generation is Windows-only.
- versions.json: add `asset_linux` / `binaries_linux` fields for
the Linux tar.gz asset (Windows tag/asset unchanged).
- checksums.json: restructured into per-platform `{ "windows": ..,
"linux": .. }` sub-maps; new Linux hashes added, Windows hashes
unchanged.
nanvix_common (src/nanvix_common)
- `REQUIRED_BINARIES` and new `NANVIXD_BINARY` are now cfg-gated per
target_os so both daemons can be referenced symbolically.
- `RepoConfig` gains optional `asset_linux` / `binaries_linux` fields
(serde default).
- `load_checksums` accepts either the legacy flat map or the new
platform-keyed form, selected by a `platform: &str` argument.
wxc_common (src/wxc_common/Cargo.toml + src/lib.rs)
- Move `nanvix_common` and `uuid` out of the Windows-only target
section so the `microvm` feature works on Linux; add Linux-only
`libc` dep used by the watchdog SIGKILL path.
- Drop `target_os = "windows"` gate from `microvm_staging` and
`nanvix_runner` module declarations (the runner now compiles on
Linux too).
Build & docs
- build.sh: add `--with-microvm` flag, composed with `--with-hyperlight`
via a `FEATURES_LIST` array.
- docs/nanvix-microvm/nanvix.md: document Linux prerequisites
(`/dev/kvm`, `lxc-exec`, `--with-microvm`) and note that warm-start
via snapshots is Windows-only.
No schema or SDK changes; backend selection still uses
`"containment": "microvm"`.
Mirrors the Windows MicroVM E2E suite in `tests/e2e_linux_microvm.rs`, invoking `lxc-exec` directly with `containment=microvm`. Adds skip guards (`has_lxc_exe`, `has_lxc_nanvix_binaries`, `has_kvm`), a full-suite test with per-case timing emitted to `microvm-perf-results-linux.json`, and an `#[ignore]` repeat-stress test. Includes 7 new `test_configs/microvm_*_linux.json` covering hello, exit code, multiline, stdlib, large output, exception, and timeout cases.
ppenna
force-pushed
the
user/ppenna/nanvix-kvm-support
branch
from
May 28, 2026 18:54
b473954 to
9f3c274
Compare
Collaborator
|
closing and reopening to see if that updates the ADO status syncing |
Contributor
|
/azp run |
|
Azure Pipelines successfully started running 1 pipeline(s). |
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.
📖 Description
Extends the Nanvix MicroVM containment backend to Linux via KVM, mirroring the existing Windows/WHP implementation, and adds a Linux E2E test suite to cover it.
Runtime (
wxc_common/src/nanvix_runner.rs)target_os: Windows keeps the WHP snapshot warm-start; Linux cold-boots the VM via KVM on every invocation (no snapshot, no-snapshot/-bin-dirargs; cwd set to exe dir).usizecarries a duplicated processHANDLEon Windows and the child PID on Linux; on timeout, Linux deliversSIGKILLvialibc::killinstead ofTerminateProcess.NANVIX_HOME,DEFAULT_HOME_LEAF, andSNAPSHOT_CBORbehindcfg(target_os = "windows").nanvix_common::NANVIXD_BINARYfor the platform-correct daemon name (nanvixd.exe/nanvixd.elf).NanVixErrordisplay variants.Staging (
wxc_common/src/microvm_staging.rs)host_path_to_guest_relativeto strip leading slashes so Linux absolute paths (/tmp/xyz) become guest-relative (tmp/xyz).lxcbinary (src/lxc)microvmcargo feature that enableswxc_common/microvmand depends onnanvix_binariesso KVM artifacts are downloaded/staged.build.rscopies staged Nanvix artifacts next tolxc-execusingnanvix_common::copy_artifacts_to_targetandDEP_NANVIX_BINARIES_BIN_DIR.ContainmentBackend::MicroVminmain.rs: gated by--experimental, returnsNanVixScriptRunnerwhen compiled withmicrovm, otherwise exits with a clear error.nanvix_binaries(src/nanvix_binaries)target_os = "linux"in addition to Windows: downloadsmicrovm-standalone-256mb.tar.gz, extracts flat binaries from<prefix>/and kernel files from<prefix>/bin/viatar --strip-components, and verifies SHA256 sums viasha256sum. Snapshot pre-generation remains Windows-only.versions.json: bump tag to3.12.3-nanvix-0.15.19-9558cffand addasset_linux/binaries_linuxfields.checksums.json: restructured into per-platform{ "windows": .., "linux": .. }sub-maps with new hashes for both targets.nanvix_common(src/nanvix_common)REQUIRED_BINARIESand newNANVIXD_BINARYare cfg-gated pertarget_osso both daemons can be referenced symbolically.RepoConfiggains optionalasset_linux/binaries_linuxfields (serde default).load_checksumsaccepts either the legacy flat map or the new platform-keyed form, selected by aplatform: &strargument.wxc_common(Cargo.toml+lib.rs)nanvix_commonanduuidout of the Windows-only target section so themicrovmfeature works on Linux; add a Linux-onlylibcdep used by the watchdogSIGKILLpath.target_os = "windows"gate frommicrovm_stagingandnanvix_runnermodule declarations (the runner now compiles on Linux too).Build & docs
build.sh: add--with-microvmflag, composed with--with-hyperlightvia aFEATURES_LISTarray.docs/nanvix-microvm/nanvix.md: document Linux prerequisites (/dev/kvm,lxc-exec,--with-microvm) and note that warm-start via snapshots is Windows-only.E2E tests (
tests/e2e_linux_microvm.rs+test_configs/microvm_*_linux.json)lxc-execdirectly withcontainment=microvm.has_lxc_exe,has_lxc_nanvix_binaries,has_kvm), a full-suite test with per-case timing emitted tomicrovm-perf-results-linux.json, and an#[ignore]repeat-stress test.test_configs/microvm_*_linux.jsoncovering hello, exit code, multiline, stdlib, large output, exception, and timeout cases.No schema or SDK changes — backend selection still uses
"containment": "microvm".🔗 References
None.
🔍 Validation
cargo build --release -p lxc --features microvmon Linux x86_64.cargo test -p wxc_common— new unit tests for the watchdog signal-kill skip, platform constants, timeout sentinel/overflow,NanVixErrordisplay, and the staging leading-slash stripping all pass.cargo test -p wxc_e2e_tests --test e2e_linux_microvmagainst a host with/dev/kvmand a builtlxc-exec— all 7 cases pass andmicrovm-perf-results-linux.jsonis emitted.✅ Checklist
📋 Issue Type
Microsoft Reviewers: Open in CodeFlow