Run OpenShell sandboxes as Firecracker microVMs. The gateway is not modified.
This is an external compute driver in the sense of
the driver docs:
a separate service listening on a Unix socket that implements compute_driver.proto,
which the gateway does not start or supervise. The service is OpenShell's VM driver,
vendored in this repository (vendor/openshell) and trimmed to what Firecracker needs;
the launcher (src/) is the program it runs to boot each VM. It is a Firecracker-only
driver: libkrun, QEMU, GPU passthrough and virtiofs bind mounts are not part of it.
It also differs from OpenShell's driver in three behaviors: a sandbox starts the way a
container does, with the image's ENV and in the image's WORKDIR
(Image ENV and WORKDIR); a sandbox can set its vCPUs, memory and disk size
and have files copied in from the host (Per-sandbox CPU, memory, disk size and files);
and, if enabled, the driver issues SPIFFE JWT-SVIDs to its host supervisors itself, without
a SPIRE agent (Supervisor identity).
Status: unit-tested, but the vendored driver has not yet been booted against a real VM. See Verification status.
openshell-gateway ──gRPC over Unix socket──▶ openshell-driver-vm (vendored; external service)
│ for every VM: run the launcher
▼
openshell-firecracker-launcher (this plugin)
│ jailed, rootless
▼
host supervisor ◀──── bridge ◀──── Firecracker ◀──vsock── guest (openshell-sandbox)
- The driver does the control-plane work: images, overlays, Stop/Start generations, launch authentication, the host supervisor, policy. It boots no VMM itself.
- For each VM, and for image preparation, it runs its launcher with
--internal-run-vmand a fixed set of flags (OPENSHELL_VM_LAUNCHER_BINnames it, and is required). This plugin is that launcher; it boots the guest under Firecracker. - The driver's image-preparation worker is not a VM, so the launcher hands it back to the driver binary, found as the launcher's parent process.
- Guest to host traffic goes over vsock. Firecracker connects to a socket the launcher listens on, and the launcher relays to the supervisor. The supervisor's socket never enters the VMM jail.
The guest has no network device.
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) and
trimmed. 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: image ENV and
WORKDIR, OPENSHELL_VM_LAUNCHER_BIN, image sources (Image sources), and the removal of everything Firecracker does not
use. The host supervisor and guest sandbox binaries the driver embeds are built from the same
pinned commit when a release is made. mise run driver:check-pin fails if the revision in
vendor/openshell/Cargo.toml and the one in driver/UPSTREAM.env differ.
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,
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.
Trying an OpenShell change against this driver. To test a supervisor change without
re-vendoring the driver, set OPENSHELL_RUNTIME_COMMIT (and OPENSHELL_RUNTIME_REPO for a
fork) in driver/UPSTREAM.env. The release build then compiles the
embedded host supervisor, guest sandbox and guest init from that revision, while the vendored
driver crate keeps the pin, so driver:check-pin still passes and the gateway must still match
the pin. The package records the revision in openshell-runtime-commit.txt, and install.sh
warns when it installs such a build. The change must stay protocol-compatible with the pin:
base it on the pinned commit. This is for testing only; never tag a release with it set.
Trying another OpenShell version. driver/update-pin.sh moves the
pin to a release tag and edits all three places it lives (driver/UPSTREAM.env, the revs in
vendor/openshell/Cargo.toml, and Cargo.lock), then type-checks the driver against it and
summarises what changed upstream in the driver crate:
driver/update-pin.sh --list # release tags; the current pin is marked
driver/update-pin.sh --check # exit 10 if a newer stable release exists
driver/update-pin.sh # move to the newest stable release
driver/update-pin.sh v0.1.8-pre.1 # or a specific tag, `latest-pre`, `main`, or a commitNothing is committed; git checkout the three files to undo. The vendored driver is a fork
of the revision it was taken from, so a newer one may not build until the fork is re-synced
with upstream's changes (the script prints them). To re-sync, three-way merge each changed
file: base is upstream at the old pin, ours is vendor/openshell, theirs is upstream at the
new one (git merge-file). That is how the fork was moved from 8d0797a to v0.1.7, which
added fields to SupervisorAuthBundle and DriverTracingConfig and fixed guest directory
permissions under a private umask.
The driver declares the plugin's own release version to the gateway (in driver_version and
the extension metadata), and prints it for --version: 0.1.0 for a v0.1.0 tag, and
0.1.0-dev.3+g1a2b3c4d5 three commits after it. driver/version.sh
works it out and mise run driver:build passes it to the build, so a release workflow run
for a tag needs nothing more. A plain cargo build has no such setting and reports the
development version openshell-core computes (such as 0.0.1-dev.1934+g5d25211b2), which
never names a release. The OpenShell revision the driver was built from is in
openshell-commit.txt and in the log line install.sh prints.
OpenShell's driver unpacks an image into a disk and ignored the image's Config.Env and
Config.WorkingDir: every workload started in /sandbox with only the sandbox spec's
environment. This driver reads both from the image configuration (registry images, and
local Docker or Podman images), keeps them beside the cached disk as image-config.json,
and applies them:
- Environment. The image's
ENVfirst, then the sandbox template's, then the sandbox spec's, so the spec always wins. Entries the supervisor reserves (OPENSHELL_*) and malformed ones are dropped. - Working directory. The workload starts in the image's
WORKDIR. The guest init creates it if absent and hands it to the sandbox user, so it is writable as in a container, and it is passed to the supervisor as--workdir, which also makes it writable under the filesystem policy.HOMEfollows it, unless the image setsHOME, and so does the home of thesandboxaccount OpenShell creates (an image's own account keeps its home). - No
WORKDIR. Starts in the driver's default workdir,OPENSHELL_VM_DEFAULT_WORKDIR(default/sandbox), which the guest init creates and hands to the sandbox user like an image's. It applies to any sandbox whose image sets noWORKDIR, rootfs tar uploads included, and never overrides an image's. It must be an absolute path below/and is validated at driver start;/itself is refused, since Landlock would leave it read-only. - Default workdir link. If the image's
WORKDIRis somewhere else, the default becomes a symlink to it at boot (for example/sandbox -> /app), so tools that expect the default path find the workload's files. The link is skipped, with a warning, if the image already has something non-empty at that path, a symlink in its parents, or if one path contains the other. The guest creates no other/sandboxof its own. - Refused
WORKDIR. A relative path, one containing.., or one under/proc,/sys,/devor OpenShell's own directories is ignored with a warning. - Rootfs tar uploads carry no image configuration, so they start in the default workdir.
- The image's
Useris not applied.
Prepared-image caches from before this change are rebuilt once (cache layout v6).
What you need, and the Install step that provides it:
| Need | Step |
|---|---|
| An installed OpenShell gateway from a revision compatible with the driver's (Compatibility); the host-supervisor protocol is required. The older v0.0.x line runs the supervisor inside the guest and needs a guest NIC; this plugin does not support it | 1 |
| Firecracker 1.16.1 or newer (the first release that validates the Linux 6.18 guest kernel the plugin ships) | 2 |
| The launcher, the VM driver and a guest kernel (all pre-built) | 3 |
Linux x86_64 with /dev/kvm readable and writable by the driver's user, unprivileged user namespaces, and e2fsprogs (debugfs, mke2fs) |
4 |
A gateway_jwt signing bundle in the gateway: the driver requires launch authentication, or sandbox creation fails |
5 |
Nothing needs a build toolchain. aarch64 has no pre-built assets.
Seven steps, in order. Steps 1 to 4 are one-off; check (step 6) verifies all of them.
curl -LsSf https://raw.githubusercontent.com/NVIDIA/OpenShell/main/install.sh | sh
openshell-gateway --version # must be 0.1.xThat is OpenShell's own installer (it sets up the CLI and a local gateway; see
its docs). To read it first,
download it with curl -LsSfo, read it, then run it with sh.
The easy way is to let the plugin installer do it in step 3: add --firecracker latest (or
a tag such as --firecracker v1.17.0) to sudo ./install.sh --binaries-only. It downloads
Firecracker's release, verifies its checksum and installs /usr/local/bin/firecracker
(under --prefix). To do it by hand:
Release tarballs from the Firecracker releases
extract to release-<version>-<arch>/:
arch=$(uname -m)
tag=$(curl -fsSL https://api.github.com/repos/firecracker-microvm/firecracker/releases/latest \
| grep -m1 '"tag_name"' | cut -d'"' -f4)
curl -fsSL "https://github.com/firecracker-microvm/firecracker/releases/download/$tag/firecracker-$tag-$arch.tgz" | tar -xz
sudo install -m 0755 "release-$tag-$arch/firecracker-$tag-$arch" /usr/local/bin/firecracker
firecracker --version # 1.16.1 or newerEach tarball has a .sha256.txt beside it on the release page. The launcher finds
firecracker beside itself, on PATH, or in /usr/local/bin, /usr/bin or
/opt/firecracker; set OPENSHELL_VM_FIRECRACKER_BIN only to use another location.
Each plugin release carries pre-built assets and an installer: the launcher, the VM driver
(built from vendor/openshell; openshell-commit.txt names the OpenShell commit it is from),
and a guest kernel built for Firecracker. Download
install.sh from the release (not from the repository: the release copy is stamped with
the repository to download from), read it, then:
curl -fsSLO https://github.com/mr-miles/openshell-firecracker/releases/latest/download/install.sh
chmod +x install.sh
sudo ./install.sh --binaries-only # launcher, driver and kernel, under /usr/local/libexec/openshell-firecracker
./install.sh --config-only # your user's systemd units and env file
./install.sh --dry-run # show what it would do, change nothingIt verifies every download against SHA256SUMS, never overwrites a file you have edited
(it writes <file>.new beside it), and prints the OpenShell commit the driver was built from next to your gateway's version. It needs only bash, curl, tar and sha256sum. It does not
edit gateway.toml; it prints what is left to do. --no-kernel skips the kernel (to use
your own); --launcher-only skips the driver, if you build vendor/openshell yourself;
--no-subuids skips the per-VM uid setup in
Host setup. The assets are built for x86_64 Linux only.
The guest kernel is installed as vmlinux beside the launcher, where the launcher looks for
it; set OPENSHELL_VM_FIRECRACKER_KERNEL only to use another one.
To install a build that is not a release, such as a manual run of the Release workflow,
point --from at a directory holding the assets. That run's launcher, kernel and
driver artifacts lack examples.tar.gz and SHA256SUMS, which only the publish step adds,
so make those too. From a checkout of this repository:
dir=$(mktemp -d)
for z in launcher.zip kernel.zip driver.zip; do unzip -o "$z" -d "$dir"; done
tar -czf "$dir/examples.tar.gz" examples
(cd "$dir" && sha256sum -- * > SHA256SUMS)
sudo ./install.sh --from "$dir" --binaries-only
./install.sh --from "$dir" --config-onlyA SHA256SUMS you make yourself only catches damaged files; it does not show where they came
from.
One-off, per host:
-
KVM. Your user needs read/write access to
/dev/kvm: usually membership of thekvmgroup (sudo usermod -aG kvm "$USER", then log in again). -
e2fsprogs, fordebugfsandmke2fs(sudo apt install e2fsprogs; usually present). -
User namespaces. The VMM jail needs unprivileged user namespaces (
sysctl user.max_user_namespacesabove 0). Ubuntu 23.10 and later also confine them with AppArmor (cat /proc/sys/kernel/apparmor_restrict_unprivileged_usernsprints1), which makes the jail fail withwrite /proc/self/setgroups: Permission denied.sudo ./install.sh --binaries-onlyinstalls a profile that allows them for the launcher only. To do it by hand, create/etc/apparmor.d/openshell-firecracker-launcher:abi <abi/4.0>, include <tunables/global> profile openshell-firecracker-launcher /usr/local/libexec/openshell-firecracker/openshell-firecracker-launcher flags=(unconfined) { userns, include if exists <local/openshell-firecracker-launcher> }and load it with
sudo apparmor_parser -r /etc/apparmor.d/openshell-firecracker-launcher. The alternative,sudo sysctl kernel.apparmor_restrict_unprivileged_userns=0, lifts the restriction for every program on the host. -
Per-VM uids. With the default
OPENSHELL_VM_FIRECRACKER_SUBUIDS=auto, each VMM runs as a subordinate uid if the host allows it, and otherwise as the driver's user with a warning (Per-VM uid).sudo ./install.sh --binaries-onlysets this up for the user who ransudo(or--user NAME), skipping anything already in place:- a 65536-id range for that user in
/etc/subuidand/etc/subgid, after the ranges already allocated; - the
uidmappackage (newuidmap,newgidmap), on apt-based systems; elsewhere it tells you to install it; - a udev rule,
/etc/udev/rules.d/99-openshell-firecracker-kvm.rules, making/dev/kvmread/write for everyone. This lets every local user use KVM. Delete the file to undo it.
Pass
--no-subuidsto skip all of it. Then, or if you installed without the installer, do the same by hand: checkgrep "$USER" /etc/subuid /etc/subgid(add ranges withsudo usermod --add-subuids 200000-265535 --add-subgids 200000-265535 "$USER"), installuidmap, and make/dev/kvmworld read/write. - a 65536-id range for that user in
- Edit
~/.config/openshell/firecracker-driver.env(installed by--config-only):OPENSHELL_GRPC_ENDPOINT,OPENSHELL_VM_TLS_CA,OPENSHELL_VM_DRIVER_STATE_DIR, the image, andUSER. The comments in the file say which are required. - Register the driver in
~/.config/openshell/gateway.tomland make sure the gateway has agateway_jwtsigning bundle (Connect).
With the same environment as the service:
set -a; . ~/.config/openshell/firecracker-driver.env; set +a
/usr/local/libexec/openshell-firecracker/openshell-firecracker-launcher checkIt checks every step above, in groups, and exits nonzero if anything failed:
| Group | Checks |
|---|---|
| OpenShell | the gateway is installed and 0.1.x; the openshell CLI; the VM driver exists and accepts OPENSHELL_VM_LAUNCHER_BIN; that variable points at this launcher |
| Host | Firecracker found (where) and new enough; the guest kernel found and uncompressed; /dev/kvm and the VMM jail (user namespaces, AppArmor); debugfs, mke2fs; sub-uid support |
| Driver environment | gateway endpoint, TLS CA file, state directory, an image, a valid admission JSON |
| Gateway configuration | gateway.toml selects firecracker and gives a socket_path; launch authentication: gateway_jwt in it, or the local signing keys in ~/.local/state/openshell/tls/jwt/ |
Each failure says what to do. The example unit runs it before the driver starts. It does not boot a VM.
systemctl --user daemon-reload
systemctl --user enable --now openshell-driver-firecracker.service
systemctl --user restart openshell-gateway.service # after every driver restart too
openshell gateway info # shows the firecracker driverRestarting or stopping the driver service stops each running VM in order: the supervisor
ends the workload and flushes the guest disk, then the VM exits. Sandboxes show as
Provisioning (a DriverStopping event says why), and the driver relaunches them, with their
disks, when it starts again. Sandboxes that were stopped or had failed stay that way. This
needs the example unit's KillMode=mixed: with the default, systemd kills the VMs together
with the driver.
For another architecture, or to change the plugin or driver. Nothing here is needed to use a release.
-
The launcher (Rust 1.95; see
rust-toolchain.toml):cargo build --release sudo install -D target/release/openshell-firecracker-launcher \ /usr/local/libexec/openshell-firecracker/openshell-firecracker-launcher
-
The driver (
vendor/openshell). Checking it needs only Rust (mise run driver:ci). Building a release driver also stages the runtime it embeds: the host supervisor, guest sandbox and guest init, built from the OpenShell commit indriver/UPSTREAM.envwith that commit's own bundling script, plus umoci. That needsmise,git,zstdandcurl; it installs only Rust, zig and cargo-zigbuild, not OpenShell's full toolchain. It compiles a good part of OpenShell, so expect it to be slow the first time:mise run driver:package tar -xzf dist/openshell-driver-vm-$(uname -m)-linux.tar.gz -C dist sudo install -D dist/openshell-driver-vm \ /usr/local/libexec/openshell-firecracker/openshell-driver-vmUse this driver, not OpenShell's packaged
openshell-driver-vm: that one cannot run the Firecracker launcher. -
The guest kernel, which is the part that needs a C toolchain (
build-essential flex bison bc libelf-dev libssl-dev xz-utils). Firecracker needs an uncompressedvmlinuxwith virtio-mmio, not PCI.kernel/build.shdownloads the newest Linux 6.18 (checked against kernel.org's checksums), starts from Firecracker's own CI config for that series, mergeskernel/openshell-firecracker.kconfigand the vendored driver'sopenshell.kconfig(Landlock, seccomp, cgroups), fails if any option either asks for is missing from the final configuration (a missing one shows up later as a silent hang or a panic at boot), and packages the strippedvmlinux:mise run kernel:package tar -xzf dist/openshell-firecracker-kernel-$(uname -m)-linux.tar.gz -C dist sudo install -m 0644 dist/vmlinux /usr/local/libexec/openshell-firecracker/vmlinuxKERNEL_SERIES,KERNEL_VERSIONandFIRECRACKER_REFchoose another kernel (see the top of the script). The release workflow runs the same script.
-
Pick a driver name that is not a built-in:
firecracker. The stock gateway registersdocker,kubernetes,podmanandvm. -
Run the driver as the gateway's user. The gateway does no authentication of its own. The driver checks the peer, and the gateway's pid is not known in advance, so the driver runs with
--allow-same-uid-peer, as the same UID as the gateway. The packaged gateway is a user service, so this is a user unit. -
Give the socket a dedicated directory. The driver requires the socket's parent directory to be owned by its user and not a symlink, and sets it to
0700. Use$XDG_RUNTIME_DIR/openshell-firecracker/. Do not use/tmp: the packaged unit hasPrivateTmp=true, so the gateway cannot see sockets there. -
Register it in
~/.config/openshell/gateway.toml(examples/gateway.toml):[openshell] version = 2 [openshell.gateway] compute_driver = "firecracker" [openshell.drivers.firecracker] socket_path = "/run/user/1000/openshell-firecracker/driver.sock"
socket_pathis the only key the gateway reads from this table, apart fromallow_driver_configandresource_admission, which it reads for admission. These two must match the driver'sOPENSHELL_DRIVER_ADMISSION_CONFIG_JSON; see Enable driver_config. Putguest_tls_caunder[openshell.gateway]; the gateway rejectsguest_tls_*keys in a driver table. -
Start the driver before the gateway, and restart the gateway whenever the driver restarts. The gateway reads the driver's capabilities at startup and again before every validate, create and start. If the driver's admission acknowledgement changed, those calls fail until the gateway restarts.
-
Verify:
openshell gateway infoshows the active driver and negotiated capabilities.
Example units and environment are in examples/: the driver service, its
environment file, a gateway drop-in that orders the two, and the gateway.toml snippet.
The driver reads its own options (below). The plugin reads these, from the environment the driver inherits:
| Variable | Purpose |
|---|---|
OPENSHELL_VM_LAUNCHER_BIN |
Required, read by the driver: absolute path to openshell-firecracker-launcher. The driver will not start without it |
OPENSHELL_VM_FIRECRACKER_BIN |
Optional. Absolute path to Firecracker. Default: firecracker beside the launcher, on PATH, or in /usr/local/bin, /usr/bin, /opt/firecracker |
OPENSHELL_VM_FIRECRACKER_KERNEL |
Optional. Absolute path to the guest vmlinux. Default: vmlinux beside the launcher, or in /usr/local/libexec/openshell-firecracker, /var/lib/openshell-firecracker |
OPENSHELL_VM_FIRECRACKER_SUBUIDS |
auto (default), required, or off; see Per-VM uid |
OPENSHELL_VM_FIRECRACKER_LEASE_DIR |
Sub-uid lease directory. Defaults to $XDG_RUNTIME_DIR/openshell-firecracker-leases |
OPENSHELL_VM_FIRECRACKER_LOG_LEVEL |
Firecracker's own log level: off, error, warn (default), info, debug or trace. Firecracker's messages go to rootfs-console.log |
OPENSHELL_VM_FIRECRACKER_ZRAM_PERCENT |
Size of each guest's compressed swap (zram) as a percentage of its memory, 0 to 200. Default 50; 0 turns it off. See Guest swap |
OPENSHELL_FIRECRACKER_DRIVER |
Path of the driver, if it cannot be found from the launcher's parent |
The driver's OPENSHELL_VM_DEFAULT_WORKDIR (default /sandbox) sets the working directory for
sandboxes whose image has none (Image ENV and WORKDIR).
The driver's OPENSHELL_VM_SUPERVISOR_IDENTITY* options (optional, off by default) are in
Supervisor identity.
The driver's OPENSHELL_VM_MAX_VCPUS and OPENSHELL_VM_MAX_MEM_MIB limit what a sandbox can request
with --cpu and --memory, and OPENSHELL_VM_MAX_OVERLAY_DISK_MIB, OPENSHELL_VM_FILES_ROOT and
OPENSHELL_VM_FILES_MAX_BYTES what it can request in its driver_config; see
Per-sandbox CPU, memory, disk size and files.
The driver's OPENSHELL_VM_IMAGE_CACHE_MAX_IDLE_HOURS (default 48, 0 to keep everything)
sets when unused image disks are removed; see Image cache cleanup.
The driver's OPENSHELL_VM_LOCAL_IMAGE_SOURCE (default auto) and
OPENSHELL_VM_LOCAL_IMAGE_SOURCE_SOCKET choose where image names without a registry host
come from; see Image sources.
The driver itself needs OPENSHELL_GRPC_ENDPOINT (required), OPENSHELL_VM_TLS_CA for an
https:// endpoint, OPENSHELL_VM_DRIVER_STATE_DIR, at least one of
OPENSHELL_VM_BOOTSTRAP_IMAGE / OPENSHELL_SANDBOX_IMAGE, and
OPENSHELL_DRIVER_ADMISSION_CONFIG_JSON, which must match the gateway's
allow_driver_config and resource_admission for this driver ({} means defaults on
both sides). The gateway passes its proxy settings and gateway name to a driver it
spawns; an externally run driver must set the OPENSHELL_VM_UPSTREAM_PROXY* and
OPENSHELL_GATEWAY_NAME equivalents itself.
A guest has no swap disk. Near its memory limit it can only drop file pages, including
the programs it is running, and it stalls for seconds at a time reading them back. A
long stall can cut the guest's connection to the supervisor and end the sandbox. So each
guest gets compressed swap in its own memory (zram), half its memory by default
(OPENSHELL_VM_FIRECRACKER_ZRAM_PERCENT). Nothing is written to the host's disk.
zram stretches memory; it does not add any. To give VMs more, raise the driver's default,
OPENSHELL_VM_DRIVER_MEM_MIB (2048), or let a sandbox ask for more with
--memory (Per-sandbox CPU, memory, disk size and files).
It needs the guest kernel from this release or later, and mkswap and swapon in the
bootstrap image. Without either, the guest boots without swap. rootfs-console.log
says which happened: openshell-firecracker: zram swap on (1024 MiB), or why it is off.
A sandbox sets its vCPUs and memory with the standard --cpu and --memory options of
openshell sandbox create. It can also set the size of its writable disk, and have files
copied in from the host, through its driver_config. Upstream's VM driver ignores
--cpu and --memory, and has none of the driver_config settings.
openshell sandbox create --cpu 4 --memory 8Gi ...--cpu is the VM's vCPU count. A Firecracker VM has whole vCPUs, so the value must be
a whole number of CPUs (4, or 4000m); 1.5 is refused rather than rounded. Without
it, a VM gets OPENSHELL_VM_DRIVER_VCPUS (2). A request must be between 1 and
OPENSHELL_VM_MAX_VCPUS, which defaults to the default vCPUs: set it, up to Firecracker's
32, to let sandboxes ask for more.
--memory is the VM's memory, as a Kubernetes quantity (8Gi, 8192Mi, 8G),
rounded down to whole MiB. Without it, a VM gets OPENSHELL_VM_DRIVER_MEM_MIB (2048). A
request must be between 256 MiB and OPENSHELL_VM_MAX_MEM_MIB, which defaults to the
default memory: set it to let sandboxes ask for more. Unlike the disk, the memory is real
host RAM once the guest touches it.
Neither needs allow_driver_config: anyone who can create a sandbox can ask for up to
the two maximums. Stop and start keep the requests, and a start fails if one is outside
the limits in force, for instance after a maximum was lowered.
Both settings are off by default, because a sandbox's driver_config is caller input:
anyone who can create a sandbox through the gateway can set it. Two components each keep a
copy of the same admission policy, and both must allow driver_config:
-
The gateway, in the driver's table of
gateway.toml. The gateway refuses a non-emptydriver_configitself unless this is set:[openshell.drivers.firecracker] socket_path = "/run/user/1000/openshell-firecracker/driver.sock" allow_driver_config = true
-
The driver, in
OPENSHELL_DRIVER_ADMISSION_CONFIG_JSONin its environment file. The driver checks the request again, and reports its policy to the gateway:OPENSHELL_DRIVER_ADMISSION_CONFIG_JSON='{"allow_driver_config": true}'Keep the single quotes: systemd's
EnvironmentFile=removes double quotes from an unquoted value, which would break the JSON.
The two must describe the same policy, resource_admission included. The gateway compares
the driver's reported policy with its own when it connects, and refuses to use the driver
if they differ ("compute driver admission policy differs from gateway configuration"). So
change both together: restart the driver first, then the gateway. Leave resource_admission
out of both (the defaults), or set it identically in both.
Then put the settings in a block named after the driver as the gateway knows it
(compute_driver = "firecracker"). The gateway forwards only that block to the driver and
drops the rest:
openshell sandbox create --driver-config-json '{"firecracker": {
"overlay_disk_mib": 16384,
"files": [
{"source": "app/app.toml", "target": "/etc/app/app.toml", "mode": "0640"},
{"source": "seed", "target": "/sandbox/seed"},
{"source": "certs/ca.pem", "target": "/etc/ssl/app-ca.pem", "owner": "root", "refresh": true}
]}}' ...The memory is not a driver_config setting: a mem_mib there is refused, with a pointer
to --memory (CPU and memory).
overlay_disk_mib is the size of the sandbox's writable overlay disk, which holds
everything the workload writes. The default is OPENSHELL_VM_OVERLAY_DISK_MIB (4096). A
request must be between 256 and OPENSHELL_VM_MAX_OVERLAY_DISK_MIB (default 65536). The disk
is a sparse file, so the host spends only what the guest writes. The size is fixed when the
sandbox is created. Stop and start keep it, because they reuse the same request.
files copies files and directories from the host into the guest:
| Field | Meaning |
|---|---|
source |
Required. A path relative to OPENSHELL_VM_FILES_ROOT: a file, or a directory that is copied with everything in it. .. and absolute paths are rejected, and so are symbolic links, both as the source and inside a source directory, so nothing outside the root can be reached |
target |
Required. An absolute guest path. A file replaces what is there; a directory is merged into an existing directory or created. System paths are refused: /proc, /sys, /dev, /run, /tmp, /opt/openshell and the driver's own files |
owner |
sandbox (default), the account the workload runs as, or root |
mode |
Octal permission bits for a file source, such as "0640". Default: the host file's bits. Set-user-ID and set-group-ID bits are refused |
refresh |
false (default): copy on the sandbox's first launch only. true: copy again on every start, replacing the guest's version |
Ownership is fixed up for everything copied in. Missing parent directories of a target are
created, owned by owner with mode 0755. Each copied directory and file is owned by
owner and keeps the host's permission bits (or mode). Directories that already exist,
such as /etc, keep their own owner and mode.
The driver does not start a sandbox whose files cannot be resolved: a missing source, one
outside the root, or more than OPENSHELL_VM_FILES_MAX_BYTES in total (default 256 MiB)
is rejected when the sandbox is created. Without OPENSHELL_VM_FILES_ROOT, requests that
use files are rejected.
How it works: before the VM boots, the driver writes the files that are due into a staging
directory on the overlay disk. A guest init drop-in then creates the parents, copies each
entry into place with its owner and mode, and deletes the staging directory, all before the
workload starts. If a VM fails before its init runs, the next start copies every entry
again. The files are copies, not mounts: changes on the host reach the guest only through
refresh.
The sandbox policy still governs what the workload can access. Add a target outside the workdir to the policy's filesystem paths if the workload needs to read or write it.
The driver decides where an image comes from by its name alone, so each name has exactly one source:
- A name with a registry host always comes from that registry, even if Docker or Podman
has an image with the same name. A host is a first component, before the first
/, that contains a.or a:(a port):192.168.1.239:5000/app:latest,ghcr.io/org/app,localhost:5000/app. Each start asks the registry which digest the tag points to; a disk already prepared for that digest is reused, otherwise the layers are pulled. - A name without one comes only from the local container engine:
app:latest,myuser/app, andlocalhost/app(where Podman keeps images it builds). If the image is not there, the start fails; the driver never falls back to a registry. There is no implicit Docker Hub: writedocker.io/library/ubuntu:24.04, notubuntu:24.04.
Upstream looks every name up in Docker or Podman first and only then asks the registry, so
an outdated local copy of 192.168.1.239:5000/app:latest silently replaces what was pushed.
OPENSHELL_VM_LOCAL_IMAGE_SOURCE |
Socket used when OPENSHELL_VM_LOCAL_IMAGE_SOURCE_SOCKET is unset |
|---|---|
auto (default) |
/var/run/docker.sock, then $XDG_RUNTIME_DIR/podman/podman.sock, then /run/user/<uid>/podman/podman.sock. None answering means no local engine |
docker |
/var/run/docker.sock |
podman |
$XDG_RUNTIME_DIR/podman/podman.sock, then /run/user/<uid>/podman/podman.sock |
off |
None: every image name needs a registry host |
OPENSHELL_VM_LOCAL_IMAGE_SOURCE_SOCKET (a path or unix:// URL) replaces the mode's
sockets; it cannot be combined with off, and tcp:// and ssh:// are refused. The
driver does not read DOCKER_HOST, OPENSHELL_PODMAN_SOCKET or Docker contexts. Rootless
Podman only has its socket while its user unit runs: systemctl --user enable --now podman.socket. The driver logs its mode and sockets when it starts.
The driver keeps the disks it prepares in $OPENSHELL_VM_DRIVER_STATE_DIR/images/: one
bootstrap root disk, plus one disk for each sandbox image. Each folder's name includes the
driver version, so every upgrade, and every rebuild with a new version string, prepares a
new set. Upstream never deletes them. This driver removes them:
- Kept: the image a sandbox uses, for as long as the sandbox exists, running or stopped,
so starting a stopped sandbox does not have to pull and build its image again. Also kept:
the bootstrap disk the driver last used (
images/current-bootstrap). - Removed at once: disks from other driver builds that no sandbox refers to.
- Removed when idle: disks from this build that no sandbox refers to, once
OPENSHELL_VM_IMAGE_CACHE_MAX_IDLE_HOURS(default 48) have passed since their last use. Starting, stopping or deleting a sandbox counts as a use of its image and of the bootstrap disk (last-usedin the folder). A disk without that file counts from when it was built.
Cleanup runs when the driver starts and after each sandbox start, stop or delete. It waits
until no sandbox is provisioning and logs each folder it removes. Set the variable to 0 to
turn cleanup off. A stopped sandbox from an older build keeps its old image until it next
starts. Starting it prepares the image for the current build, and the old disk then counts
as unreferenced.
With OPENSHELL_VM_FIRECRACKER_SUBUIDS at auto or required, each VMM runs as a
subordinate uid of its own. Inside its user namespace, id 0 is the driver's user, which
builds the jail, and id 1 is the leased uid Firecracker then runs as, with no
capabilities. A VMM that escaped the jail would hold a uid that owns nothing on the host.
| Mode | Behavior |
|---|---|
auto (default) |
Use subordinate uids when the host supports them; otherwise warn and run as the driver's user |
required |
Refuse to launch unless the host supports them |
off |
VMM runs as the driver's user |
Host requirements: ranges for the driver's user in /etc/subuid and /etc/subgid; the
setuid newuidmap and newgidmap helpers (package uidmap); /dev/kvm readable and
writable by all users; Firecracker executable and the kernel readable by all users.
Launchers coordinate through flocked lease files, because the driver cannot hand
a launcher an id. The kernel releases a lease when its launcher exits, so a crash cannot
leak an id. The launcher shares only what the VMM needs: the overlay disk and a private
socket directory are group-accessible, the sandbox state directory stays 0700, and the
VMM reaches its files through bind mounts.
The startup check does not exercise a boot, so a host that passes it can still fail on the
first sandbox. If that happens, set off to confirm the cause and read
rootfs-console.log.
Off by default. When it is on, the driver acts as a minimal SPIFFE Workload API for its
host supervisors, so provider token grants (OAuth2 JWT client assertions) work without a
SPIRE agent. The supervisor needs no changes: it already reads
OPENSHELL_PROVIDER_SPIFFE_WORKLOAD_API_SOCKET and calls FetchJWTSVID on it.
For every sandbox launch the driver:
- hard-links the supervisor binary into the sandbox's state directory as
openshell-supervisor(or copies it, if a hard link is impossible: another filesystem, orfs.protected_hardlinkswith a binary owned by someone else), and starts the supervisor from that link; - binds
workload-api.sock(mode0600) beside it and passes its path inOPENSHELL_PROVIDER_SPIFFE_WORKLOAD_API_SOCKET; - answers on that socket only the process it started. Every request is checked through
the connection's
SO_PEERCRED: the peer runs as the driver's uid, has the supervisor's pid and the process start time recorded at spawn (so a recycled pid fails), and its/proc/<pid>/exeis this sandbox's link and has the link's inode. The link shares its inode with the shared binary, so the path is what tells one sandbox's supervisor from another's. A refused request getsPermissionDeniedand the driver logs why.
The supervisor gets the SPIFFE ID spiffe://<trust domain>/openshell/sandbox/<sandbox id>,
in a JWT-SVID signed with ES256. FetchJWTBundles and ValidateJWTSVID work too; the
X.509 calls answer Unimplemented. Requests must carry workload.spiffe.io: true, as the
specification requires. The socket and the link are removed when the supervisor stops.
Relying parties verify the tokens with two HTTP endpoints, served on
OPENSHELL_VM_SUPERVISOR_IDENTITY_JWKS_BIND:
| Path | Content |
|---|---|
/.well-known/openid-configuration |
OIDC discovery document: issuer, jwks_uri |
/.well-known/jwks.json |
The public signing key as a JWKS (kid is its RFC 7638 thumbprint) |
They are plain HTTP and are served at the root. To publish them as an https:// issuer,
put a TLS reverse proxy in front, set OPENSHELL_VM_SUPERVISOR_IDENTITY_ISSUER to the
public URL, and have the proxy strip the issuer's path, if it has one.
The signing key (P-256, PKCS#8) is created on first start as
<state dir>/supervisor-identity/jwt-signing-key.p8, mode 0600. The driver refuses a
key that group or others can read. It does not rotate the key: to rotate, stop the
driver, delete the file and start it again. Tokens signed with the old key stop
verifying once relying parties refetch the JWKS.
| Variable | Default | Purpose |
|---|---|---|
OPENSHELL_VM_SUPERVISOR_IDENTITY |
false |
Turn the feature on |
OPENSHELL_VM_SUPERVISOR_IDENTITY_TRUST_DOMAIN |
openshell.local |
Trust domain of issued IDs ([a-z0-9._-]) |
OPENSHELL_VM_SUPERVISOR_IDENTITY_ISSUER |
http://<jwks bind> |
The iss claim and OIDC issuer: the URL relying parties fetch the JWKS from. Required when the bind address is 0.0.0.0 or :: |
OPENSHELL_VM_SUPERVISOR_IDENTITY_JWKS_BIND |
127.0.0.1:8961 |
Listen address of the HTTP endpoints |
OPENSHELL_VM_SUPERVISOR_IDENTITY_SVID_TTL_SECS |
300 |
JWT-SVID lifetime, 60 to 3600 seconds |
With it off, none of this exists: no HTTP listener, no signing key, no socket or link in the state directory (any a previous launch with it on left behind is removed at the next launch), and no variable in the supervisor's environment.
Limits:
- A UNIX socket path holds at most 107 bytes. The driver refuses to start if
<state dir>/sandboxes/<36-character id>/workload-api.sockis longer, so keepOPENSHELL_VM_DRIVER_STATE_DIRshort (under about 50 bytes); a longer sandbox id fails that sandbox's launch. - The JWKS listener is unauthenticated: it publishes only the public key, but bind it to an address only relying parties can reach.
- This is not SPIRE. There is one trust domain, no federation, no X.509 SVIDs, and the attestation knows only the supervisor processes this driver started.
- No virtiofs bind mounts and no GPU passthrough on Firecracker. A sandbox that asks for
either is rejected at validation, not ignored. To get host files into a guest, use
driver_config.files, which copies them in. [openshell.supervisor.network].additional_ca_bundleand the shared supervisor pool are rejected by the gateway for any external driver.- Rootfs tar uploads need the driver and gateway on the same filesystem and UID.
openshell-gateway config preflightskips host-tool checks for an external driver;openshell-firecracker-launcher checkcovers the Firecracker ones.- The VM driver does not advertise
isolation-backendorsuspend-resume, and does not implementAuthenticateSandbox. - Stop kills the VMM without a guest flush. The overlay uses
Writebackcaching so fsyncs reach the host file, and ext4 stays crash-consistent. - The Firecracker and kernel paths are checked when a VM launches, not pinned by hash.
- aarch64 is untested.
- Each VMM runs rootless in its own user, mount, network, IPC, UTS and PID namespaces, on
a tmpfs root holding only Firecracker, the kernel, the sandbox's disks and VMM config,
the vsock directory and three device nodes. It drops the capability bounding set, sets
no_new_privs, disables core dumps, and keeps Firecracker's own seccomp filter. - The guest environment file sits in the sandbox's own overlay (mode
0600, root-owned). It holds what the driver passes to the guest init. - Firecracker's
jaileris not used. - Anyone who can create a sandbox can ask for vCPUs up to
OPENSHELL_VM_MAX_VCPUSand memory up toOPENSHELL_VM_MAX_MEM_MIB, with or withoutallow_driver_config; keep the memory maximum within what the host can give every sandbox at once. - With
allow_driver_configon, anyone who can create a sandbox can read every file underOPENSHELL_VM_FILES_ROOTby copying it into their sandbox, and can ask for a disk up toOPENSHELL_VM_MAX_OVERLAY_DISK_MIB. Put only what all sandbox users may see in the files root, and keep the maximum within the host's free space: overlays are sparse, so the host disk fills only as guests write, but it can fill.
| Check | Status |
|---|---|
Config builder, argument parsing, check, cargo clippy / rustfmt, CI |
Unit tests pass and CI runs |
| End to end on one real host | openshell sandbox create boots a Firecracker sandbox: the release-built Linux 6.18 guest kernel (with # CONFIG_ACPI is not set), the jail, image preparation, the gateway-to-driver socket and the supervisor connection all worked. Needed fixes along the way are in the git history (/dev/fd links, gateway.toml schema version and socket path) |
| Vendored driver | Not booted. The end-to-end result above was with OpenShell's v0.1.6 driver plus a launcher-override patch, before the driver was vendored. The vendored driver (v0.1.7, with ENV/WORKDIR and the removals) passes its unit tests and builds, but has not run a sandbox. The release packaging (driver:package, driver/stage-runtime.sh) has not been run end to end either: only its source fetch and umoci download were checked |
| Supervisor identity | Unit tests, including one that starts a stand-in supervisor from the hard link and has it fetch, verify and validate a JWT-SVID over the socket with the spiffe client the real supervisor uses, and a driver smoke test of the JWKS endpoints. Not run with a real supervisor or token service |
| Image cache cleanup | Unit tests of the cleanup rules (image_cache_gc.rs), compiled and run on their own. The driver hooks (start, stop, delete, startup) are checked only by the driver's unit tests in CI. Not run against a real state directory |
| Not checked on that host | The sub-uid isolation path (OPENSHELL_VM_FIRECRACKER_SUBUIDS), the AppArmor profile in install.sh, the guest clock, long-running or concurrent sandboxes, image ENV/WORKDIR in a real guest, and OpenShell's conformance suite (tests/suites/conformance in the OpenShell repository), which is what would show parity with other drivers |
| Other hosts | One Ubuntu-style x86_64 host only; no arm64 |
Confirmed from the OpenShell repository, not by running anything: the launcher flag
contract, the RuntimeInitiatedUnix transport, the 0666 supervisor control socket, and the
external-driver registration keys (compute_driver, [openshell.drivers.<name>] socket_path) at v0.1.6 and at the vendored commit.
| Symptom | Cause and fix |
|---|---|
check reports FAIL ... /dev/kvm |
/dev/kvm is not read/write for the user, or KVM is missing (Host setup) |
check reports a user-namespace error |
user.max_user_namespaces is 0 or unprivileged namespaces are disabled |
write /proc/self/setgroups: Permission denied |
AppArmor restricts user namespaces (Ubuntu 23.10 and later). No sudo needed at run time: install the AppArmor profile (Host setup) |
Firecracker ... is too old |
Install Firecracker 1.16.1 or newer (Install) |
Driver exits with OPENSHELL_VM_LAUNCHER_BIN is required |
Set it in the driver's environment file (Configure). Make sure the service runs the vendored driver install.sh installs, not OpenShell's packaged one |
Workload starts in /, or lacks the image's variables |
The image has no WORKDIR/ENV, or its cached disk predates this driver (it is rebuilt once). See Image ENV and WORKDIR |
| Gateway cannot connect to the socket | Socket under /tmp (hidden by PrivateTmp), or the driver runs as a different UID |
| Sandbox create fails after a driver restart | Restart the gateway: the admission acknowledgement changed |
Sandboxes are in error (ProcessExited) after a driver restart |
The unit lacks KillMode=mixed, so systemd killed the VMs before the driver could stop them. Reinstall the unit (./install.sh --config-only, then systemctl --user daemon-reload). Stop and start each affected sandbox to recover it |
| Create fails mentioning launch authentication | The gateway has no gateway_jwt signing bundle |
| Guest hangs or panics at boot | Read rootfs-console.log. The release kernel is built by kernel/build.sh, which fails if a required option is missing; a kernel you supplied needs the same options |
| Handshake fails with a certificate not-yet-valid error | Guest clock; check date in the console log |
Sandbox dies with boundary terminated: boundary lost during wait, or the guest logs Sandbox Protocol connection lost |
The supervisor connection over vsock was cut. The launcher logs every relay of that connection to the driver's stderr (journalctl --user -u openshell-driver-firecracker), with host timestamps: vsock relay N: opened, then one line per direction saying when it ended and why. The direction that ended first, and whether it was a clean close or an error, shows which side dropped it. Set OPENSHELL_VM_FIRECRACKER_LOG_LEVEL=info for more of Firecracker's own messages in rootfs-console.log |
| Launcher says the guest environment file was not written | debugfs missing or the overlay path has spaces or quotes |
The toolchain and tasks are managed with mise, as in OpenShell.
mise install installs the pinned Rust (1.95.0, with rustfmt and clippy) and writes
mise.lock; commit that file. mise tasks lists everything.
mise run rust:format # cargo fmt --all
mise run ci # format check, clippy (deny warnings), tests
mise run package:launcher # release build, packaged into dist/CI runs the same tasks, so a local run and a workflow run do the same thing.
.github/workflows/ci.yml runs rust:format:check, rust:lint and rust:test, and
driver:ci, on every push and pull request, then builds the launcher. The tests need no KVM; the one that
writes into an ext4 image skips itself when e2fsprogs is missing.
The vendored driver is its own cargo workspace (vendor/openshell), so its checks are
separate tasks: driver:ci runs its format check, clippy (deny warnings) and tests, and is
part of ci. driver:package stages the runtime, builds the driver and packages it.
kernel:package builds the guest kernel (kernel/build.sh; it needs a C toolchain).
Releases are built by .github/workflows/release.yml when a v* tag is pushed; it calls package:launcher,
kernel:package, driver:package and package:assets.