Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 35 additions & 1 deletion aci_edge_sandboxes/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 4 additions & 3 deletions doc/usage.md
Original file line number Diff line number Diff line change
Expand Up @@ -161,12 +161,13 @@ python3 scripts/nvx.py build-guest-binaries --output DIRECTORY
```

The Linux-only build command checks the exact `rust-toolchain.toml` pin and
builds the five PR 1 guest executables for `x86_64-unknown-linux-musl` with one
builds the six Rust guest executables for `x86_64-unknown-linux-musl` with one
`cargo build` of the `guest` profile, a fresh target directory, Cargo's locked
mode, incremental compilation disabled, inherited Cargo profile overrides
removed, remapped source paths, and no linker build IDs. It runs the static-ELF
check and writes `manifest.json` with the source and executable SHA-256 digests.
It updates the output of an earlier build in place, removing the retired
It updates the output of an earlier build in place, adding `nvx-managed-agent`
when that build's manifest does not record it and removing the retired
`nvx-port-io` executable when that build's manifest records it, and refuses any
other existing `DIRECTORY`.

Expand All @@ -176,7 +177,7 @@ other existing `DIRECTORY`.
python3 scripts/nvx.py test-guest-binaries --binaries DIRECTORY
```

The Linux-only test command validates the five binaries and build manifest,
The Linux-only test command validates the six binaries and build manifest,
sets `NVX_GUEST_BINARIES`, and runs the musl `guest_tools` integration test
against that exact directory.

Expand Down
1 change: 0 additions & 1 deletion nvx-rs/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

17 changes: 11 additions & 6 deletions nvx-rs/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,13 @@ name = "nvx"
default = ["host"]
# The host side: artifact discovery, launch, network and filesystem lowering, control sessions,
# process and platform primitives, and the supervision of VM instances.
host = ["serde", "dep:getrandom", "dep:serde_json", "dep:libc", "dep:windows-sys"]
host = ["serde", "dep:getrandom", "dep:serde_json", "dep:nix", "dep:windows-sys"]
# Stages the OpenVMM executable, guest kernel, and control initramfs at build time; see
# `Artifacts::bundled`. The build script downloads the release pinned in `artifacts.json`, or
# copies the release directory named by `NVX_BUNDLE_DIR`.
bundled = ["host", "dep:sha2"]
# Test doubles: the fake OpenVMM of `testing::fake_openvmm` and its `nvx-fake-openvmm` binary.
testing = ["dep:getrandom", "dep:serde", "dep:serde_json", "dep:libc", "dep:windows-sys"]
testing = ["dep:getrandom", "dep:serde", "dep:serde_json", "dep:nix", "dep:windows-sys"]
# The serde form of `Hypervisor`. The `host` feature enables it.
serde = ["dep:serde"]
# The programs that run in Linux guests: the `guest` module and the `nvx-*` guest binaries. Build
Expand All @@ -38,9 +38,6 @@ getrandom = { version = "0.4", optional = true }
serde = { version = "1.0.200", features = ["derive"], optional = true }
serde_json = { version = "1.0.120", optional = true }

[target.'cfg(unix)'.dependencies]
libc = { version = "0.2.160", optional = true }

[target.'cfg(windows)'.dependencies]
windows-sys = { version = "0.61", optional = true, features = [
"Win32_Foundation",
Expand All @@ -52,7 +49,8 @@ windows-sys = { version = "0.61", optional = true, features = [
"Win32_System_Threading",
] }

[target.'cfg(target_os = "linux")'.dependencies]
# The host and the fake OpenVMM also build on Unix hosts other than Linux, such as macOS.
[target.'cfg(unix)'.dependencies]
nix = { version = "0.31.3", default-features = false, optional = true, features = [
"fs",
"ioctl",
Expand Down Expand Up @@ -121,6 +119,13 @@ required-features = ["guest"]
doc = false
test = false

[[bin]]
name = "nvx-managed-agent"
path = "src/bin/nvx-managed-agent.rs"
required-features = ["guest"]
doc = false
test = false

# The guest binaries: small, static, and stripped.
[profile.guest]
inherits = "release"
Expand Down
7 changes: 5 additions & 2 deletions nvx-rs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,7 @@ executables as `/sbin/nvx-*`.
| `nvx-reseed [--generation-only] SEED_FILE [PREVIOUS]`, `nvx-reseed --sample` | Reseeds the kernel's random number generator from a seed file and checks its VM generation ID, or prints a random sample |
| `nvx-exit [CODE]` | Stops the VM with an 8-bit exit code through OpenVMM's control port 0x604 (x86_64) |
| `nvx-device-io file ...`, `nvx-device-io network ...` | The benchmark helper that measures file and UDP round-trip I/O and prints one JSON line (x86_64) |
| `nvx-managed-agent CONTROL_TTY ROOTFS HOSTNAME UID GID USER HOME` | Serves the managed control session and supervises sequential workloads; `--exec-config-fd FD -- WORKLOAD ...` is its internal launch helper |

Each binary's command line, exit statuses, and byte output are compatibility
contracts; the [`nvx::guest`](src/guest/mod.rs) documentation describes each
Expand All @@ -187,8 +188,10 @@ NVX_BUNDLE=skip cargo test --all-features # unit, golden-fixture, and fake-Ope
The tests need no hypervisor. The fake-OpenVMM test drives `Instance` end to end
against `nvx-fake-openvmm`, and the protocol tests compare the wire constants
with the guest agent's source in `guest/common/nvx-managed-agent.c`. On Linux,
`nvx.py` also lints and tests the guest binaries, and runs their integration
tests against a build of them:
a loopback test drives the host `ControlSession` through a broker shim into the
real managed agent's session, dispatch, and execution engine, and `nvx.py` also
lints and tests the guest binaries, and runs their integration tests against a
build of them:

```bash
python3 ../scripts/nvx.py check-guest-binaries
Expand Down
19 changes: 19 additions & 0 deletions nvx-rs/src/bin/nvx-managed-agent.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
//! The managed guest agent. It serves NVX's authenticated control session on the guest's control
//! TTY and runs one workload at a time, either as the guest's PID 1 or in a sandbox's root
//! filesystem.
//!
//! `nvx-managed-agent CONTROL_TTY ROOTFS HOSTNAME UID GID USER HOME` starts the agent, and
//! `nvx-managed-agent --exec-config-fd FD -- WORKLOAD...` is its internal execution helper. See
//! `nvx::guest::managed_agent`.

#[cfg(target_os = "linux")]
fn main() -> std::process::ExitCode {
nvx::guest::managed_agent::main()
}

// The agent runs only in Linux guests. Elsewhere this stub fails, so that every target that CI
// checks with `--all-features` still builds.
#[cfg(not(target_os = "linux"))]
fn main() -> std::process::ExitCode {
std::process::ExitCode::FAILURE
}
Loading
Loading