Skip to content

Add microVM backend scaffolding with fail-closed admission#276

Merged
seanwevans merged 1 commit into
mainfrom
claude/microvm-backend-scaffolding
Jul 21, 2026
Merged

Add microVM backend scaffolding with fail-closed admission#276
seanwevans merged 1 commit into
mainfrom
claude/microvm-backend-scaffolding

Conversation

@seanwevans

Copy link
Copy Markdown
Owner

Summary

backend="microvm" previously raised a flat, generic NotImplementedError from the shared backend guard. This replaces it with a dedicated, honest fail-closed path so the strongest boundary PyIsolate targets has real groundwork and diagnostics — without pretending to boot a guest it cannot yet boot.

What's included

New pyisolate/runtime/microvm.py provides the parts that don't need a running hypervisor to be useful or testable:

  • Capability detection (detect_microvm_support) — is a supported VMM (Firecracker, Cloud Hypervisor, QEMU) on PATH, and is /dev/kvm readable+writable? Collects the blocking reasons.
  • Fail-closed admission (require_microvm_support) — raises MicroVMUnavailable (a SandboxError) naming every missing prerequisite. microVM has no weaker mode to degrade to: either a hardware-VM boundary is possible or the request is refused.
  • Machine-config generation (MicroVMConfig) — turns a sandbox's memory limit into the full-VM JSON a Firecracker-style VMM consumes (boot-source / drives / machine-config / vsock), with validation (vcpus ≥ 1, mem ≥ 1 MiB, guest CID ≥ 3).

Supervisor.spawn routes backend="microvm" to _spawn_microvm, which probes the host and either refuses with the diagnostic above, or — when the host is capable — refuses with a precise NotImplementedError noting the guest launcher and vsock transport are still pending. The module-level spawn() guard lets microVM through to this path instead of the generic error.

Explicitly out of scope

Booting a guest and carrying the cell protocol over vsock — that launcher is the next increment and needs KVM, which CI hosts lack. This PR is the detection + config + fail-closed admission layer, mirroring how the process backend landed transport-first (#267) before its confinement layers.

Docs & tests

README and the threat model are updated to describe the probe-and-fail-closed behavior. Two existing tests that asserted the old generic error are updated to the fail-closed contract. New tests/test_microvm.py covers detection, admission, and config generation without needing KVM (host capability is monkeypatched both ways).

Full suite: 491 passed, 6 skipped. pylint 9.57 (gate 8.0); black/isort/flake8/mypy clean.

🤖 Generated with Claude Code


Generated by Claude Code

backend="microvm" previously raised a flat, generic NotImplementedError from the
shared backend guard. Replace it with a dedicated, honest fail-closed path so
the strongest boundary PyIsolate targets has real groundwork and diagnostics.

New pyisolate/runtime/microvm.py provides the parts that do not need a running
hypervisor to be useful or testable:

- capability detection: is a supported VMM (Firecracker, Cloud Hypervisor, QEMU)
  on PATH and is /dev/kvm readable+writable (detect_microvm_support);
- fail-closed admission: require_microvm_support raises MicroVMUnavailable (a
  SandboxError) naming every missing prerequisite;
- machine-config generation: MicroVMConfig turns a sandbox's memory limit into
  the full-VM JSON a Firecracker-style VMM consumes, with validation.

Supervisor.spawn routes backend="microvm" to _spawn_microvm, which probes the
host and either refuses with the diagnostic above, or -- when the host is
capable -- refuses with a precise NotImplementedError noting the guest launcher
and vsock transport are still pending. It never downgrades to a weaker boundary,
matching the threat model. The module-level spawn() guard lets microVM through
to this path instead of the generic error.

Docs (README, threat model) updated. Two existing tests that asserted the old
generic error are updated to the fail-closed contract. New tests/test_microvm.py
covers detection, admission, and config generation without needing KVM.

Full suite: 491 passed, 6 skipped. pylint 9.57; black/isort/flake8/mypy clean.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01PbbJc7Ntj159D9LNGevwC2
@seanwevans
seanwevans merged commit de62d96 into main Jul 21, 2026
18 checks passed
@seanwevans
seanwevans deleted the claude/microvm-backend-scaffolding branch July 21, 2026 17:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants