Skip to content

feat: Firecracker compute driver — reuse the VM guest model with jailer, OCI images and full sandbox lifecycle #4351

Open

Description

@thukabjj

User Story

I run Horus, an orchestrator that delegates coding-agent jobs to isolated sandboxes on runners I operate. I use OpenShell as the sandbox runtime and policy layer: the gateway, the host supervisor, network policy and credential mediation. On my KVM runner I wanted those sandboxes to be Firecracker microVMs (jailer-confined VMMs, no guest NIC, a small device model), so I built an external compute driver for Firecracker against the existing ComputeDriver protocol. It now runs real agent jobs in production on that runner. I'd like to know which shape the maintainers would accept for Firecracker support, and to offer this work as input.

Problem Statement

OpenShell's VM isolation runs on libkrun (openshell-driver-vm). There is no supported way to run OpenShell sandboxes as Firecracker microVMs. The maintainer prototype in #2934 (RFC 0012, closed 2026-09-30 with no immediate plans to merge) booted a fixed ext4 fixture and listed OCI images, stop, exec, PTY, port forwarding, mediated egress and restart recovery as follow-ups.

An external driver is possible today through the extension ComputeDriver protocol (#1907), but it has to depend on OpenShell internals that are not a published contract: the VM bootstrap rootfs, openshell-vm-sandbox-init.sh, the prepared image-disk layout the guest init expects on /dev/vdc, and the launch-authentication and boundary material formats.

Impact / Why This Matters

  • Deployments that already operate and audit Firecracker must run a second hypervisor stack, or keep a fork, to use OpenShell's VM isolation.
  • An external Firecracker driver works, but any OpenShell version bump can silently break it, because the guest artifacts and init contract it reuses are internal.
  • Current workaround: pin OpenShell to one commit and re-qualify the driver on every bump. That is what we do, and it does not scale.

Proposed Design

We built and run an external driver (Go, extension ComputeDriver protocol, no gateway or protocol changes). Our view is that Firecracker support fits OpenShell best when it reuses the VM driver's guest model instead of inventing a new one. The design decisions below are the ones we would propose:

  1. Same guest model as openshell-driver-vm. Read-only bootstrap root disk (/dev/vda), per-sandbox writable overlay (/dev/vdb), and for non-default images the prepared read-only image disk (/dev/vdc, /image-rootfs) that the existing guest init uses as the overlay lowerdir. Sandboxes therefore behave the same as libkrun ones: same init, same openshell-sandbox, same policy enforcement.
  2. Host supervisor and generations. One host openshell-supervisor per sandbox. Fresh launch authentication per Create and Start, a generation-bound vsock endpoint (UDS bridge to Firecracker's vsock), and stale generations rejected. Snapshots stay driver-internal (no new RPCs, consistent with feat(driver-vm): snapshot/restore (suspend/resume) for idle sandboxes #1551).
  3. No guest NIC. All egress goes through the supervisor and is policy-mediated: allowlisted hosts are reachable, while other hosts and direct IP connects fail with EPERM.
  4. Jailer as the production mode. Each VMM is chrooted and dropped to a dedicated uid. Only the per-sandbox overlay belongs to that uid, and it is hardlinked into the chroot so guest writes survive Stop/Start. Kernel, root and image disks stay root-owned and are shared read-only (reflink or hardlink). The chroot base must share a filesystem with the state directory.
  5. Images. Prepared image disks are recorded in a sha256-verified catalog: hashes are checked at driver start and file identity is rechecked before each boot. Unknown images fail ValidateSandboxCreate before any VM starts. Disks come from the VM driver's own image preparation, or are built directly for rootfs tars too large for its path (see bug: VM driver fails to create rootfs for images with files >2 GiB due to mke2fs -d bug #1762).
  6. Guest kernel. Linux 6.12 from kernel.org, Firecracker's microvm CI config, plus a fragment matching openshell.kconfig: Landlock first in CONFIG_LSM, seccomp filter, pids/memory cgroups, and a serial console. ACPI is off, because Firecracker 1.10's ACPI tables leave virtio IRQs unrouted on 6.12. Every required symbol is asserted at build time.

Questions for maintainers, in order of preference from our side:

We are happy to share the code and test evidence for whichever shape you prefer.

Acceptance Criteria

  • On a KVM host, a Firecracker-backed gateway takes sandboxes through create → Ready → exec.
  • Policy-mediated egress holds: allowlisted hosts are reachable; other hosts and direct IPs are denied.
  • Stop/Start produces a new generation, and stale authentication is rejected.
  • Delete leaves no host leaks (VM, vsock paths, overlays, jailer trees), including over repeated cycles.
  • Non-default OCI images run; unknown images are rejected before any VM starts.
  • Jailer mode is the documented production default, with its host requirements stated.
  • The guest artifacts a Firecracker driver depends on are either versioned upstream or owned by the driver, so a version bump cannot break it silently.

Alternatives Considered

  • libkrun (openshell-driver-vm): works, but it is not the hypervisor these deployments run, and it does not offer the jailer's confinement model.
  • The feat(firecracker): prototype host-supervised isolation #2934 prototype (RFC 0012 backend): the right long-term supervisor model. Today it lacks OCI images, exec, egress and stop/start; those are exactly what this driver adds.
  • Docker, Podman and Kubernetes drivers with a VM-based runtime such as Kata (Docker driver: pick the container runtime (e.g. Kata) and show which one a sandbox got #3868): these give a VM boundary per container, but not OpenShell's own guest init, boundary protocol or image model.
  • Middleware, interceptors and providers: none of these extension points can change the isolation layer, so they do not cover this use case.

Agent Investigation

What we verified on our side, summarized:

  • Conformance on KVM (Firecracker 1.10.1, guest Linux 6.12.109, OpenShell pinned at 71c3cd957abef062eb7f37010056717cd49f2ed3, which includes feat(isolation): implement the RFC 0012 sandbox architecture #2942). All of these pass in one run:
    • capabilities negotiation;
    • create → Ready (~0.5 s);
    • CLI create and exec (~1 s);
    • policy-mediated egress;
    • stop;
    • start with a new generation;
    • delete ×30 with no leaked paths;
    • a non-default prepared image (including a 4.5 GB worker image).
  • Production: real agent jobs run in jailer mode behind our orchestrator: small and >4 MiB workspaces, concurrent sandboxes, and model access only through a policy-allowlisted proxy.
  • Findings that affect any VM-based driver:

Related issues and resources

OpenShell issues and PRs

OpenShell code we built on

Firecracker

Linux

Checklist

  • I've reviewed existing issues and the published docs
  • This is a design proposal, not a "please build this" request

Activity

  1. added
    state:triage-needed
    on Oct 8, 2026
  2. TaylorMutch commented on Oct 22, 2026

    @TaylorMutch
    Contributor

    Thanks for the detailed proposal and test evidence. Could you clarify which parts of the existing public contracts are insufficient for your implementation?

    We document the extension interfaces here:

    These interfaces are intended for external implementations, so I wouldn’t characterize them as internal.

    Your concern appears more specifically about reusing the VM driver’s guest-init script, bootstrap image, and prepared-image disk layout. That is distinct from implementing against the public extension protocols.

    Which specific formats or artifacts would need an additional compatibility commitment for your Firecracker driver? That would help us distinguish gaps in the extension contracts from dependencies introduced by reusing the existing VM guest implementation.

  3. added
    state:needs-info
    and removed
    state:triage-needed
    on Oct 22, 2026
  4. github-actions commented on Nov 19, 2026

    @github-actions

    This issue has had no activity for 28 days and is now marked stale. It may be closed in 14 days if there is no further activity. Comment or remove the state:stale label to keep it open.

  5. added
    state:stale
    on Nov 19, 2026
  6. mr-miles commented on Nov 25, 2026

    @mr-miles
    Contributor

    Proposal: a launcher contract for OpenShell VM backends

    Summary

    OpenShell's VM compute driver (crates/openshell-driver-vm) is mostly a backend-agnostic
    control plane. It handles gRPC, image preparation, overlays, launch authentication, the host
    supervisor and lifecycle extensions, but it also knows the details of the two VMMs it ships:
    libkrun and QEMU. It already starts every VM by running a launcher process
    (launcher_bin --internal-run-vm --vm-…), but the driver still picks the backend, allocates
    its resources and emits its flags.

    This proposal makes the launcher boundary a real, versioned contract built from three layers:

    1. A guest contract. What any guest sees: disks, init, environment, control channel and
      mounts. It is fixed and documented, and nothing about it is sent per launch.
    2. A launch request. A small, intent-only description of one VM.
    3. Backend config. Everything about the VMM itself, read by the launcher and never seen by
      the driver.

    Launchers declare optional features through a capability handshake, which replaces the
    hard-coded VmBackend::{Libkrun, Qemu} negotiation. libkrun and QEMU become launchers like
    any other, and out-of-tree backends such as Firecracker can use the stock driver instead of
    forking it.

    Problem

    Backend detail leaks into the driver

    All references are to upstream at the baseline commit, under
    crates/openshell-driver-vm/.

    1. The driver chooses the backend. src/runtime.rs:23 defines a closed enum:

    pub enum VmBackend { Libkrun, Qemu }

    Backend selection is spread across build_vm_launch_plan, resolve_launch_plan_backend,
    configure_qemu_launch_plan and validate_launch_plan_backend
    (src/driver.rs:3008-3180, about 175 lines), with rules such as:

    if plan.backend != VmBackend::Qemu && is_gpu {
        return Err(Status::failed_precondition("GPU sandbox launch requires the QEMU backend"));
    }
    ...
    if plan.kernel_image.is_some() && plan.backend != VmBackend::Qemu { ... }

    The lifecycle-extension API exposes the same enum (LaunchPlan::require_backend) and a
    single-backend resolver. The comment on that resolver anticipates this proposal
    (src/lifecycle.rs:123-132):

    Returns true when satisfying this feature requires the QEMU backend today. This is the
    simplest possible resolver and is expected to be replaced with a per-backend capability
    table once a third backend exists.

    2. The driver allocates backend resources and chooses the host transport. For QEMU, the
    driver allocates a vsock guest CID (gpu::allocate_vsock_cid) and offsets the control port by
    it, because AF_VSOCK host ports are global on the host (src/driver.rs:2084-2101):

    let transport = if plan.backend == VmBackend::Qemu {
        SandboxTransport::RuntimeInitiatedVsock {
            guest_cid,
            port: VM_CONTROL_PORT.checked_add(guest_cid)...,
        }
    } else {
        SandboxTransport::RuntimeInitiatedUnix { socket_path: control_socket.clone() }
    };

    The guest side is already identical for both: src/isolation/mod.rs:104-111 maps both
    transports to BoundaryListener::RuntimeInitiatedVsock. Only the host side differs, so the
    difference belongs in the launcher.

    3. The driver emits backend-specific flags. These are --vm-backend qemu,
    --vm-gpu-bdf, --vm-vsock-cid, --vm-krun-log-level, and --vm-mount with
    driver-generated virtiofs tags (src/driver.rs:2177-2219). A third backend must accept and
    reject QEMU and libkrun flags it has no use for.

    4. libkrun's hardware limits are driver constants. The limit on shared host directories
    comes from libkrun's interrupt budget (src/driver.rs:5594-5600):

    /// Each share is one virtio device and libkrun has a fixed number of interrupt lines ...
    const VM_MAX_BIND_MOUNTS: usize = if cfg!(target_arch = "aarch64") { 32 } else { 3 };

    5. Guest environment delivery forks per backend. libkrun passes the environment and init
    natively (krun_set_exec, plus KRUN_INIT_PID1, which the guest init has to unset). QEMU
    writes /srv/openshell-env.sh into the overlay (src/runtime.rs:227). The Firecracker plugin
    re-implements the same file (src/envfile.rs) and the same kernel command line
    (src/config.rs:88 against upstream src/runtime.rs:261).

    6. One launcher binary does two jobs. launcher_bin boots VMs and also runs the
    image-preparation worker (--internal-prepare-image). An external launcher has to recognise
    that worker invocation and hand it back to the driver (the plugin's src/delegate.rs).

    7. Host readiness checks are QEMU/libkrun-specific. check_kvm_access
    (src/runtime.rs:792) and check_gpu_privileges (src/driver.rs:5526) run in the driver
    and its launcher path. Firecracker needs different checks (jailer, sub-uids, its own kernel)
    and has to ship its own check command.

    How much of the driver this is

    The backend-specific code at the baseline is about 2.4k of roughly 15k non-test lines:

    Where What Approx. lines
    src/runtime.rs, src/ffi.rs, src/embedded_runtime.rs, src/gpu.rs QEMU and libkrun launch, libkrun bindings, embedded runtime, GPU slots and CIDs 1,480
    src/driver.rs Backend negotiation, GPU assignment, virtiofs validation, transport choice, backend flags 450 in dedicated functions, plus about 60 lines of branches in shared functions
    src/main.rs --internal-run-vm parsing for backend flags, libkrun re-exec 120
    scripts/openshell-vm-sandbox-init.sh NVIDIA setup, KRUN_INIT_PID1 100
    build.rs, Cargo.toml Embedding libkrun, openshell-vfio small

    The remaining ~85% is backend-agnostic.

    Current structure

    flowchart LR
        GW[Gateway] -->|compute driver gRPC| DRV
    
        subgraph DRV[openshell-driver-vm]
            CORE[Control plane<br/>images, overlays, auth,<br/>supervisor, extensions]
            SEL[Backend selection<br/>VmBackend, requires_qemu,<br/>GPU and CID allocation,<br/>virtiofs limits]
            CORE --> SEL
        end
    
        SEL -->|"re-exec self<br/>--internal-run-vm<br/>--vm-backend / --vm-gpu-bdf /<br/>--vm-vsock-cid / --vm-krun-log-level"| RT
    
        subgraph RT[Same binary, launcher mode]
            KRUN[libkrun via FFI]
            QEMU[QEMU process]
        end
    
        FORK[openshell-firecracker<br/>vendored, trimmed fork<br/>of the whole driver] -.->|has to fork to remove<br/>the enum and flags| DRV
    
    Loading

    Why this matters

    • Third backends have to fork. The Firecracker plugin carries a vendored copy of the whole
      driver crate to remove about 1.8k lines of libkrun and QEMU code. Every upstream release
      needs a manual three-way re-sync of a 15k-line driver.rs (driver/update-pin.sh). The
      same will happen to the next backend (Cloud Hypervisor, a confidential-VM VMM, or a
      macOS-specific one).
    • Fixes stay stranded in the fork. Most of the fork's ~5k added lines are backend-agnostic
      features (image ENV/WORKDIR, CPU and memory limits, overlay sizing, image cache cleanup,
      graceful shutdown). They are harder to upstream while the surrounding code has diverged.
    • Backend rules are global switches. "GPU means QEMU" and "external kernel means QEMU"
      are fixed in code. A deployment cannot offer GPU passthrough on a different VMM, or run one
      backend for some sandboxes and another for the rest.
    • The driver holds VMM privileges and dependencies it doesn't need. libkrun is loaded by
      FFI in the same binary, and openshell-vfio and the GPU sysfs inventory are compiled in.
      Operators who never use them still build, ship and audit them.
    • Testing is harder. Backend behaviour is only reachable through the full driver, so there
      is no conformance test a launcher can pass on its own.

    Proposed solution

    Principle

    Each field that crosses the boundary must describe what the guest or the driver depends on,
    not how the VMM provides it. To decide whether a field is common, ask:

    Would two backends need the driver to compute a different value for this field?

    If yes, the field is backend-specific and belongs in the launcher or its own config.

    Components and responsibilities

    flowchart TB
        GW[Gateway] -->|compute driver gRPC| DRV
    
        subgraph DRV[openshell-driver-vm: control plane, no VMM code]
            direction TB
            API[Sandbox API, persistence,<br/>restore, monitoring]
            IMG[Image preparation<br/>rootfs, overlays, cache]
            AUTH[Launch auth and<br/>boundary provisioning]
            EXT[Lifecycle extensions<br/>e.g. GPU allocation]
            CAP[Capability check<br/>plan features vs. launcher caps]
            API --> IMG --> AUTH --> EXT --> CAP
        end
    
        DRV -->|"--describe (at startup)"| L
        L -->|capabilities JSON| DRV
        DRV -->|"launch request (per VM)"| L
        DRV -. spawns .-> SUP[Host supervisor<br/>listens on control socket S]
        WRK[Image-prep worker<br/>own binary, default: driver] 
        DRV -. spawns .-> WRK
    
        subgraph L[Launcher: one per backend]
            direction LR
            LK[libkrun launcher]
            LQ[QEMU launcher]
            LF[Firecracker launcher]
        end
    
        BC[(Backend config<br/>VMM path, kernel, log level,<br/>jailer, CIDs, machine type)] --> L
    
        L -->|boots| VM
    
        subgraph VM[Guest VM]
            INIT[Guest init<br/>+ drop-ins] --> GS[Guest sandbox<br/>supervisor side]
        end
    
        GS -->|"vsock port P"| L
        L -->|"bridged to unix socket S"| SUP
        SUP <-->|gRPC| GW
    
    Loading
    Component Owns Does not own
    Driver Sandbox API and state; image preparation and the disks; writing the env file and mount manifest into the overlay; launch authentication; extension orchestration; matching plan features to launcher capabilities; choosing host paths (disks, console log, control socket S) VMM choice, VMM flags, CIDs, device numbering, kernel files, VMM log levels, host readiness checks
    Lifecycle extension Host policy for optional features, such as which GPU a sandbox gets; guest init drop-ins (for example NVIDIA module loading); declaring required features How a device is attached to the VM
    Launcher Answering --describe; turning a launch request into a running VM that meets the guest contract; delivering guest connections on port P to socket S; console capture; staying alive exactly as long as the VM; VMM confinement; host readiness checks Sandbox policy, images, authentication
    Guest init Implementing the guest contract inside the VM (finding disks, sourcing env, mounting shares, starting the sandbox) Anything that depends on which VMM booted it

    1. Guest contract (common, versioned, not sent per launch)

    This contract already exists implicitly. The Firecracker launcher satisfies it with an
    unmodified guest init, because it reproduces QEMU's layout
    (openshell-firecracker src/config.rs:9-12). This proposal writes it down and gives it a
    version number.

    Item Contract Today
    Bootstrap root /dev/vda, ext4, read-only, mounted as / QEMU and Firecracker; libkrun via krun_add_disk
    Writable overlay /dev/vdb, ext4, read-write Guest init fails without it (openshell-vm-sandbox-init.sh:224)
    Prepared image /dev/vdc, ext4, read-only, optional Mounted at /image-cache if present
    Kernel command line console=ttyS0 panic=-1 rootfstype=ext4 ro init=<init path>; launchers may add their own arguments Duplicated in QEMU's build_kernel_cmdline and Firecracker's boot_args
    Init Runs the init path given in the request as PID 1 libkrun also sets KRUN_INIT_PID1, which guest init has to clear
    Environment /overlay/upper/srv/openshell-env.sh, written by the driver before launch Written by QEMU's launcher and the Firecracker launcher; libkrun passes it natively
    Network No NIC. The only host channel is vsock. QEMU -nic none; Firecracker omits network-interfaces
    Control channel The guest connects to the host (CID 2) on vsock port P P is 5500 for libkrun and Firecracker, 5500 + cid for QEMU
    Shared directories virtiofs shares listed in a manifest of tag⇥target⇥mode lines; only present if the launcher declared mounts Tags are generated by the driver (osfs<N>)
    Console Serial on ttyS0 (or the VMM's equivalent), captured to a host file Per-VMM
    Optional devices PCI devices appear on the guest PCI bus; drop-ins load their drivers QEMU only

    With this change, P becomes a single constant for all backends. The QEMU launcher maps it to
    a unique AF_VSOCK host port internally and bridges it, as the Firecracker launcher already
    does for its uds_path_P socket.

    2. Launch request (common: what this VM needs)

    The request contains intent only. Everything in it can be computed without knowing the
    backend.

    Field Meaning How each backend provides it (launcher's job)
    contract_version The guest contract version the driver expects The launcher rejects versions it doesn't support
    disks.root, disks.overlay, disks.image? Host files that become vda, vdb and vdc QEMU -drive + virtio-blk-pci; Firecracker drives[] in order; libkrun krun_add_disk
    vcpus, mem_mib Machine size Per-VMM flags or config
    init Path the guest runs as PID 1 init= on the cmdline, or krun_set_exec
    console.path, console.max_bytes Where guest output goes, and a size cap Serial to file, or stdout/stderr capture
    control?: { guest_port, host_socket } Guest connections to guest_port arrive on host_socket libkrun port map; Firecracker uds_path_<port> plus bridge; QEMU AF_VSOCK plus bridge. Absent for the image-preparation VM.
    mounts[]: { host_path, tag, read_only } Host directory exported under tag virtiofs (libkrun, QEMU). Rejected unless mounts was declared.
    pci_devices[]: { bdf } Host PCI device visible in the guest vfio-pci on QEMU. Rejected unless pci_passthrough was declared.
    kernel_profile? Named kernel feature set the guest needs Launcher maps the profile to its own kernel. Rejected if unknown.
    backend? Opaque object passed from operator or template config to the launcher The driver never reads or writes it

    The environment is not in the request. The driver writes it into the overlay for every
    backend. tag is generated by the driver only so that it matches the guest manifest; the
    launcher treats it as an opaque string.

    An example request, as a JSON file in the sandbox state directory, passed as
    <launcher> run --request <path>:

    {
      "contract_version": 1,
      "disks": {
        "root": "/var/lib/openshell/vm/images/bootstrap-…/rootfs.ext4",
        "overlay": "/var/lib/openshell/vm/sandboxes/sb-1/overlay.ext4",
        "image": "/var/lib/openshell/vm/images/img-…/rootfs.ext4"
      },
      "vcpus": 2,
      "mem_mib": 2048,
      "init": "/srv/openshell-vm-sandbox-init.sh",
      "console": { "path": "/var/lib/openshell/vm/sandboxes/sb-1/rootfs-console.log", "max_bytes": 8388608 },
      "control": { "guest_port": 5500, "host_socket": "/run/openshell/vm/sb-1/control.sock" },
      "mounts": [],
      "pci_devices": []
    }

    3. Capability handshake

    At startup the driver runs <launcher> describe and caches the result:

    {
      "launcher": "openshell-firecracker-launcher 0.3.0",
      "contract_versions": [1],
      "max_vcpus": 32,
      "max_mem_mib": 65536,
      "features": {
        "mounts": null,
        "pci_passthrough": null,
        "kernel_profiles": ["default"],
        "control_channel": true
      }
    }

    A libkrun launcher would declare "mounts": { "max": 3 } on x86_64, which moves
    VM_MAX_BIND_MOUNTS out of the driver. A QEMU launcher would declare
    "pci_passthrough": {}.

    BackendFeature::requires_qemu() and LaunchPlan::require_backend(VmBackend) are replaced by
    one check: every feature in required_backend_features must be present in the cached
    capabilities. Otherwise the sandbox fails with FailedPrecondition, naming the feature and
    the launcher.

    sequenceDiagram
        autonumber
        participant GW as Gateway
        participant D as Driver
        participant X as Lifecycle extensions
        participant L as Launcher
        participant V as Guest VM
        participant S as Host supervisor
    
        Note over D,L: Driver startup
        D->>L: describe
        L-->>D: contract versions, limits, features
        D->>D: validate extensions' declared features against capabilities
    
        Note over GW,S: CreateSandbox
        GW->>D: CreateSandbox(spec)
        D->>X: configure_launch(plan)
        X-->>D: required features, drop-ins, env
        D->>D: check features against capabilities (fail fast)
        D->>D: prepare disks, write env file, mount manifest, drop-ins, boundary bundle into overlay
        D->>X: before_launch(plan), e.g. allocate GPU BDF
        D->>S: start supervisor listening on unix socket S
        D->>L: run --request request.json
        L->>L: read backend config, translate request to VMM config
        L->>V: boot VMM
        V->>V: guest init applies the guest contract
        V->>L: vsock connect to host port P
        L->>S: bridge connection to socket S
        S-->>GW: sandbox ready
        D->>X: after_launch
    
        Note over D,L: Stop or VM exit
        D->>L: SIGTERM
        L->>V: shut down VMM
        L-->>D: exit status
    
    Loading

    4. Backend config (backend-specific, never passes through the driver)

    The launcher reads these from its own environment or config file. The driver only passes its
    environment through to the launcher unchanged.

    Backend Examples
    All VMM binary path, guest kernel or kernel profile map, VMM log level, readiness checks (<launcher> check)
    libkrun Runtime directory, libkrunfw location, embedded runtime extraction
    QEMU Machine type, PCIe root-port layout, vsock CID range
    Firecracker Jailer and user namespaces, sub-uid ranges, vsock socket directory

    Grey areas

    • GPU. Requesting a GPU and choosing which host device is host policy. That becomes a
      lifecycle extension (today's GpuInventory) that declares pci_passthrough and fills in
      pci_devices. Attaching the device (vfio-pci) is the launcher's job. Loading NVIDIA
      modules in the guest becomes a guest init drop-in instead of GPU_ENABLED in the init
      script. Only a BDF crosses the boundary.
    • Kernel. Upstream lets an extension pass a kernel image path, but libkrun bundles its
      kernel and Firecracker needs one built for its device model, so a path is backend-specific.
      A named kernel_profile that the launcher resolves is the portable form. A launcher that
      supports arbitrary kernels can declare an external_kernel feature for that case.
    • Escape hatch. The opaque backend object allows per-sandbox tuning (for example a
      QEMU CPU model) without adding fields to the contract. The driver forwards it from operator
      or template configuration and must not read or write it. If one key starts being used across
      backends, it is promoted to a typed field in a new contract version.
    • Image-preparation VM. The driver also boots a short-lived VM to unpack images
      (run_image_prep_vm). It uses the same launch request with no control and no image disk.
      This is separate from the image-preparation worker process, which gets its own binary
      setting.

    Migration plan

    Each step is useful on its own and can land independently.

    1. Upstream the fork's backend-agnostic features. CPU and memory limits are in progress
      (feat/vm-honor-resource-limits). The others are image ENV/WORKDIR, graceful shutdown,
      image cache cleanup, image sources, overlay size and files. This removes most of the
      divergence before any interface changes.
    2. Small fixes to the current flags:
      • The driver writes the env file for every backend, so the launchers stop doing it.
      • Add a separate image-preparation worker binary setting, defaulting to the driver itself.
      • Make the control port a single constant for every backend; the QEMU launcher maps it
        internally.
    3. Write down the guest contract as version 1, and add a conformance test that boots any
      launcher against the stock guest init.
    4. Add describe and the capability check, keeping the libkrun and QEMU launchers in
      the driver binary as built-in launchers that answer describe. Replace VmBackend in the
      extension API with feature declarations, keeping the old methods deprecated for one release.
    5. Switch to the launch request file, keeping the --vm-* flags for one release, and
      move the GPU allocation into a lifecycle extension.
    6. Add a control-plane-only build with a cargo feature: no embedded libkrun, no QEMU
      launcher and no openshell-vfio.
    7. The Firecracker plugin drops vendor/. It ships only its launcher and runs the stock
      driver with OPENSHELL_VM_LAUNCHER_BIN.

    Alternatives considered

    • An in-process Rust trait (trait VmRuntime). It gives type safety, but every backend
      must compile against a specific OpenShell revision and runs with the driver's privileges.
      The Firecracker launcher deliberately has no OpenShell dependencies, so it isn't tied to a
      release at compile time. The process boundary also already exists. A trait is still a good
      way to organise the built-in launchers inside upstream.
    • Keep the flags and add --vm-backend firecracker. This adds a third branch to every
      VmBackend match, and the driver keeps owning all three VMMs.
    • A full backend-specific spec. This moves the coupling into a file without removing it.
      The driver would still need to know each VMM's devices.
    • Status quo (fork and re-sync). The cost is paid on every upstream release, and fixes are
      slow to flow in either direction.

    Related work

    RFC 0012 (Isolation Backend Interface)
    defines how the supervisor drives a pluggable isolation backend, and leaves the placement of
    the "sandbox runtime" to each compute driver. This proposal sits one level below: inside the
    VM compute driver, it separates the VMM that hosts the boundary from the driver that
    orchestrates it. The two are compatible. A launcher is the VM driver's sandbox runtime, and
    the guest contract is where RFC 0012's protected channel enters the guest.

    Open questions

    1. Delivery. Should the launch request be a file, stdin, or a gRPC service the launcher
      hosts? A file is the simplest, can be inspected after a failure, and fits restore
      (restore_persisted_sandboxes relaunches from saved state).
    2. Restore. Should a launcher be able to declare that it re-attaches to running VMs
      after a driver restart, instead of relaunching them?
    3. Multiple launchers. Should one driver be able to hold several launchers and choose one
      per sandbox by capability (for example GPU sandboxes on QEMU and everything else on
      Firecracker), or should that stay one driver per backend?
    4. Version skew. Should the guest contract version be tied to the guest init that the
      driver embeds, or negotiated? A launcher could support contract versions N and N-1.
    5. Supervisor start. Some fork features (driver-issued SPIFFE JWT-SVIDs) change how the
      host supervisor is started. Is that a lifecycle-extension hook (supervisor_command), or out
      of scope here?
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    state:needs-infostate:stale

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions