supermachine-kernel
Pre-built Linux kernel image and in-VM init-oci shim for the
supermachine microVM
runtime.
This is a data crate. No public functions worth calling on
their own; depend on it alongside supermachine so the runtime
finds its kernel + init shim.
Quick start
[]
= "=0.2"
= "=0.2"
Pin both to the same version with = — the snapshot format is
keyed to the kernel build, and a partial cargo update would
invalidate previously baked snapshots.
// Stage the bundled assets into a writable scratch dir, then
// point supermachine at them.
let scratch = temp_dir.join;
create_dir_all?;
extract_kernel_to?;
extract_init_oci_to?;
let assets = from_dir;
let vm = start?;
For .app-bundle distribution, do the extraction in a build.rs
so the bundle is self-contained — no first-run download.
What this ships
| Asset | Size | Purpose |
|---|---|---|
KERNEL_BYTES |
~29 MiB | aarch64 Linux Image with the AF_TSI patch series. Loaded into guest RAM at VM start. |
INIT_OCI_BYTES |
~1.6 MiB | Statically-linked aarch64-musl PID 1. Mounts overlayfs, /proc, /dev; exec's the OCI image entrypoint. Only needed for fresh bakes; snapshot restore doesn't use it. |
The bytes ship inside the published .crate as xz-compressed
payloads (kernel.xz ≈ 7 MiB, init-oci.xz ≈ 330 KiB). cargo's
outer gzip on the tarball adds essentially nothing on already-xz
data, so the final .crate is ~7.3 MiB — comfortably under
crates.io's 10 MiB cap. No network, no separate install step:
cargo add supermachine-kernel and build.rs decompresses the
payloads into OUT_DIR at first build.
build.rs resolves the assets in this order:
SUPERMACHINE_KERNEL_PATH/SUPERMACHINE_INIT_OCI_PATHenv vars — point at uncompressed files. Use this for a custom kernel build.- The bundled
kernel.xz/init-oci.xznext toCargo.toml. Decompressed viaxz -d(universally available on macOS 11+ and every mainstream Linux distro). This is the default path.
Decompression runs once at first cargo build (~50–100 ms);
subsequent builds use cargo's incremental cache. If xz is
missing on the build host: brew install xz,
apt install xz-utils, or dnf install xz.
API
- [
KERNEL_BYTES] / [KERNEL_LEN] - [
INIT_OCI_BYTES] / [INIT_OCI_LEN] - [
extract_kernel_to] / [extract_kernel_to_with_parents] - [
extract_init_oci_to] / [extract_init_oci_to_with_parents]
See the rustdoc for usage notes.
License
This crate is a combined work under three licenses (see the
NOTICE file shipped in this crate for full attribution + the
GPL §3(b) source-availability offer):
- Apache-2.0 — our build glue (
build.rs,src/lib.rs). SeeLICENSE-APACHE. - GPL-2.0-only — the bundled Linux kernel image
(
kernel.xz). SeeLICENSE-GPL-2.0. Source available on request per GPL-2.0 §3(b) — seeNOTICEfor the written offer (emaildomas@supercorp.aiwith the crate version received). - MIT — musl libc statically linked into the bundled
init-ocibinary (init-oci.xz). SeeLICENSE-MIT.
SPDX expression: Apache-2.0 AND GPL-2.0-only AND MIT.
Redistributing this crate requires satisfying each license on its respective component. Most redistributors are fine: the kernel runs as guest data, not as linked host code.