Skip to content
Closed
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
13 changes: 9 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,12 @@ The guest has no network device.
## The vendored driver

`vendor/openshell` holds one crate: OpenShell's VM driver (`openshell-driver-vm`), taken from
NVIDIA/OpenShell `main` at commit `f16795b` (after `v0.1.9`; not a release; pinned in [`driver/UPSTREAM.env`](driver/UPSTREAM.env)) and
trimmed. It is its own cargo workspace. The other OpenShell crates it uses (`openshell-core`
the `patched` branch of the fork [mr-miles/OpenShell](https://github.com/mr-miles/OpenShell) at commit
`36761e1` (pinned in [`driver/UPSTREAM.env`](driver/UPSTREAM.env)) and trimmed. That branch is OpenShell
`main` at `f16795b` (after `v0.1.9`; not a release) plus fixes not yet merged upstream: the L7
proxy keeps percent-encoded path bytes and signs S3 paths as AWS does, and the VM driver
perf changes of ai-openshell/openshell#6056 and #6057 (fewer `debugfs` runs, hashes and worker
processes per launch). It is its own cargo workspace. The other OpenShell crates it uses (`openshell-core`
and friends) are **git dependencies on the same commit**, not copies, so building needs
network access to GitHub. The changes from upstream are listed in
[its README](vendor/openshell/crates/openshell-driver-vm/README.md): image `ENV` and
Expand All @@ -61,8 +65,9 @@ pinned commit when a release is made. `mise run driver:check-pin` fails if the r
### Compatibility

The supervisor protocol is not stable across OpenShell revisions, so the gateway must come
from a revision compatible with the one in `driver/UPSTREAM.env`, currently `main`
at `f16795b`, which is not a release: build the gateway from that commit. Released gateways,
from a revision compatible with the one in `driver/UPSTREAM.env`, currently the fork's `patched`
branch at `36761e1`, which is not a release: build the gateway from that commit (or from upstream
`f16795b`, its base; the stack changes no gateway protocol). Released gateways,
`v0.1.9` included, have not been checked against it. `install.sh` prints
the commit the installed driver was built from and the gateway's reported version, and leaves
the comparison to you.
Expand Down
4 changes: 2 additions & 2 deletions driver/UPSTREAM.env
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
# protocol is not stable across revisions. To move to another revision, re-vendor the
# driver crate from it (see crates/openshell-driver-vm/README.md), then change the commit here
# and the `rev` in vendor/openshell/Cargo.toml.
OPENSHELL_REPO=https://github.com/NVIDIA/OpenShell
OPENSHELL_COMMIT=f16795bc76b13fcc35d8b0d2b49cfc788c701ef9
OPENSHELL_REPO=https://github.com/mr-miles/OpenShell
OPENSHELL_COMMIT=36761e1a7b6d67a6a10417a5a56674d629594092
OPENSHELL_TAG=

# Optional: build the embedded runtime (host supervisor, guest sandbox, guest init) from
Expand Down
20 changes: 10 additions & 10 deletions vendor/openshell/Cargo.lock

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

14 changes: 7 additions & 7 deletions vendor/openshell/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,13 @@ repository = "https://github.com/NVIDIA/OpenShell"
# The rest of OpenShell, from the revision driver/UPSTREAM.env names (keep the two in sync:
# `mise run driver:check-pin` checks). The host supervisor and guest binaries the driver
# embeds are built from that revision too.
openshell-core = { git = "https://github.com/NVIDIA/OpenShell", rev = "f16795bc76b13fcc35d8b0d2b49cfc788c701ef9", default-features = false }
openshell-isolation-interface = { git = "https://github.com/NVIDIA/OpenShell", rev = "f16795bc76b13fcc35d8b0d2b49cfc788c701ef9" }
openshell-sandbox-backend = { git = "https://github.com/NVIDIA/OpenShell", rev = "f16795bc76b13fcc35d8b0d2b49cfc788c701ef9" }
openshell-otel = { git = "https://github.com/NVIDIA/OpenShell", rev = "f16795bc76b13fcc35d8b0d2b49cfc788c701ef9" }
openshell-otel-test-support = { git = "https://github.com/NVIDIA/OpenShell", rev = "f16795bc76b13fcc35d8b0d2b49cfc788c701ef9" }
openshell-spiffe = { git = "https://github.com/NVIDIA/OpenShell", rev = "f16795bc76b13fcc35d8b0d2b49cfc788c701ef9" }
openshell-crypto = { git = "https://github.com/NVIDIA/OpenShell", rev = "f16795bc76b13fcc35d8b0d2b49cfc788c701ef9", default-features = false, features = ["aws-lc"] }
openshell-core = { git = "https://github.com/mr-miles/OpenShell", rev = "36761e1a7b6d67a6a10417a5a56674d629594092", default-features = false }
openshell-isolation-interface = { git = "https://github.com/mr-miles/OpenShell", rev = "36761e1a7b6d67a6a10417a5a56674d629594092" }
openshell-sandbox-backend = { git = "https://github.com/mr-miles/OpenShell", rev = "36761e1a7b6d67a6a10417a5a56674d629594092" }
openshell-otel = { git = "https://github.com/mr-miles/OpenShell", rev = "36761e1a7b6d67a6a10417a5a56674d629594092" }
openshell-otel-test-support = { git = "https://github.com/mr-miles/OpenShell", rev = "36761e1a7b6d67a6a10417a5a56674d629594092" }
openshell-spiffe = { git = "https://github.com/mr-miles/OpenShell", rev = "36761e1a7b6d67a6a10417a5a56674d629594092" }
openshell-crypto = { git = "https://github.com/mr-miles/OpenShell", rev = "36761e1a7b6d67a6a10417a5a56674d629594092", default-features = false, features = ["aws-lc"] }
# Async runtime
tokio = { version = "1.53.3", features = ["full"] }

Expand Down
2 changes: 2 additions & 0 deletions vendor/openshell/crates/openshell-driver-vm/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,8 @@ defaults-without-telemetry = ["compute-driver"]
[build-dependencies]
# Generates the SPIFFE Workload API server stub without protoc.
tonic-build = { version = "0.14", optional = true }
# The guest runtime identity is hashed once, at build time (build.rs).
sha2 = { workspace = true }

[dev-dependencies]
spiffe = { workspace = true }
Expand Down
7 changes: 7 additions & 0 deletions vendor/openshell/crates/openshell-driver-vm/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,13 @@ Changes from upstream:
`off`) and `OPENSHELL_VM_LOCAL_IMAGE_SOURCE_SOCKET` choose the engine. `DOCKER_HOST`,
`OPENSHELL_PODMAN_SOCKET` and `podman info` are no longer consulted. See
`src/local_images.rs`.
- **Launch bookkeeping (from the fork's `patched` branch, ai-openshell/openshell#6056 and
#6057, not yet upstream).** A launch writes its overlay files in one `debugfs` run, the guest
runtime identity is hashed at build time, a cached host supervisor is re-hashed only when the
file changes, and a cached digest-pinned bootstrap image is resolved without a preparation
worker. Adapted here: no mount manifest is written (bind mounts are refused), and the
worker is skipped only for a name with a registry host, since those never consult a local
engine (see Image sources), so no engine is probed.
- **Removed.** libkrun and its embedded runtime, QEMU, GPU passthrough and `openshell-vfio`,
virtiofs bind mounts, and the backend negotiation in the lifecycle extension API. A
sandbox that asks for a GPU or bind mounts is rejected.
Expand Down
42 changes: 39 additions & 3 deletions vendor/openshell/crates/openshell-driver-vm/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
//! artifacts it needs to prepare images and run sandboxes without a separate
//! runtime download. The VMM is an external launcher, so no VMM is embedded.

use sha2::{Digest, Sha256};
use std::path::{Path, PathBuf};
use std::{env, fs};

Expand All @@ -22,10 +23,45 @@ fn main() {
return;
}

println!("cargo:rerun-if-env-changed=OPENSHELL_VM_RUNTIME_COMPRESSED_DIR");

let out_dir = PathBuf::from(env::var("OUT_DIR").expect("OUT_DIR not set"));
generate_workload_api_server(&out_dir);
embed_runtime_artifacts(&out_dir);
write_guest_runtime_identity(&out_dir);
}

/// The guest runtime identity (`rootfs::sandbox_guest_runtime_identity`):
/// SHA-256 over the embedded sandbox, vm-init and umoci blobs and the guest
/// init script, exactly the bytes the crate embeds. It keys the image
/// cache, so a changed guest runtime invalidates cached root disks. Hashed
/// here once instead of in every image preparation worker, a fresh process
/// per sandbox launch.
fn write_guest_runtime_identity(out_dir: &Path) {
const GUEST_INIT_SCRIPT: &str = "scripts/openshell-vm-sandbox-init.sh";
println!("cargo:rerun-if-changed={GUEST_INIT_SCRIPT}");
let manifest_dir =
PathBuf::from(env::var("CARGO_MANIFEST_DIR").expect("CARGO_MANIFEST_DIR not set"));
let mut hasher = Sha256::new();
for path in [
out_dir.join("openshell-sandbox.zst"),
out_dir.join("openshell-vm-init.zst"),
out_dir.join("umoci.zst"),
manifest_dir.join(GUEST_INIT_SCRIPT),
] {
let bytes = fs::read(&path).unwrap_or_else(|e| {
panic!(
"read {} for the guest runtime identity: {e}",
path.display()
)
});
hasher.update(&bytes);
}
let identity = format!("{:x}", hasher.finalize());
let path = out_dir.join("guest-runtime-identity");
fs::write(&path, identity).unwrap_or_else(|e| panic!("write {}: {e}", path.display()));
}

fn embed_runtime_artifacts(out_dir: &Path) {
println!("cargo:rerun-if-env-changed=OPENSHELL_VM_RUNTIME_COMPRESSED_DIR");

let Ok(dir) = env::var("OPENSHELL_VM_RUNTIME_COMPRESSED_DIR") else {
// Lint, check and test builds (the debug profile) never run the embedded
Expand All @@ -35,7 +71,7 @@ fn main() {
println!("cargo:warning=OPENSHELL_VM_RUNTIME_COMPRESSED_DIR not set");
println!("cargo:warning=Stage the compressed runtime artifacts and point it at them");
}
generate_stub_resources(&out_dir);
generate_stub_resources(out_dir);
return;
};
let compressed_dir = PathBuf::from(dir);
Expand Down
Loading