Skip to content

docs(spec-minvmd-linux-kvm): Linux host support for minvmd (KVM backend + vsock bridge) - #399

Merged
norrietaylor merged 1 commit into
mainfrom
spec/minvmd-linux-kvm-98d0ee6b5d90ad81
Jun 12, 2026
Merged

docs(spec-minvmd-linux-kvm): Linux host support for minvmd (KVM backend + vsock bridge)#399
norrietaylor merged 1 commit into
mainfrom
spec/minvmd-linux-kvm-98d0ee6b5d90ad81

Conversation

@gominimal-aw-bot

@gominimal-aw-bot gominimal-aw-bot Bot commented Jun 12, 2026

Copy link
Copy Markdown
Contributor

Spec for #397: extending minvmd from macOS-only to Linux hosts via libkrun's KVM backend.

Demoable Units

Unit 1 — Un-gate libkrun from macOS: build.rs emits Linux link directives; the krun module, image::kernel_format(), and VmConfig::apply() are un-gated from macOS. No new FFI code — the libkrun API is identical on both platforms.

Unit 2 — VMM child on Linux: cmd/vmm_child.rs and cmd/boot.rs add Linux paths (identical to macOS paths; no code-signing required). A /dev/kvm capability check is added. minvmd boot --foreground on Linux boots a microVM via KVM and receives the READY marker from the guest.

Unit 3 — Linux e2e + latency benchmark: The existing macOS-only e2e tests (boot_e2e, minimald_session_e2e, bridge_e2e) are un-gated. A Linux KVM CI job is added. Warm-boot latency on Linux/KVM is measured and reported against the ~75 ms macOS baseline.

Open questions resolved

Next step

Merging this spec PR advances tracking issue #397 from the spec phase into triage. Please review and merge the spec PR to advance the tracking issue from the spec phase into triage.

Merging the spec PR will close the spec sub-issue (Closes #398 is added to the PR body by sdd-pr-sanitize).


References: #397

Generated by sdd-spec for issue #397 · sonnet46 5.9M ·

Closes #398

Summary by CodeRabbit

  • Documentation
    • Added specification document for Linux KVM backend support, outlining implementation scope, goals, design considerations, and verification requirements.

Tracks tracking issue #397. Three demoable units:
1. Un-gate libkrun from macOS — build and link on Linux
2. VMM child on Linux — KVM boot, READY marker, UDS↔vsock bridge
3. Linux e2e tests and latency benchmark

Resolves the selection-surface open question by deferring auto-spawn on
Linux to a follow-up under #396; VM isolation on Linux requires explicitly
running `minvmd run --detach`.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@coderabbitai

coderabbitai Bot commented Jun 12, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

Adds a new specification document defining the scope, goals, and three units of work to enable minvmd on Linux with a KVM backend via libkrun, including build un-gating, functional runtime implementation, testing infrastructure, design considerations, and an explicit verification matrix.

Changes

minvmd Linux KVM Specification

Layer / File(s) Summary
Scope, Motivation, and Goals
docs/specs/02-spec-minvmd-linux-kvm/02-spec-minvmd-linux-kvm.md
Document metadata, scope boundaries (excluding networking, deferring session selection), and user story goals for Linux KVM support including build success, boot readiness, vsock↔UDS bridging, e2e coverage, and latency targets.
Unit 1: Build and Linking for Linux
docs/specs/02-spec-minvmd-linux-kvm/02-spec-minvmd-linux-kvm.md
Specifies removing macOS-only conditional gating so minvmd builds and links on Linux, exposing libkrun/krun module unconditionally, and enabling kernel format and VM configuration application on Linux targets.
Unit 2: Functional Runtime Behavior on Linux
docs/specs/02-spec-minvmd-linux-kvm/02-spec-minvmd-linux-kvm.md
Defines Linux code paths for the VMM child and boot logic, removes macOS-only runtime bails, adds /dev/kvm accessibility checks to daemon initialization, and updates daemon messaging to reflect multiplatform support.
Unit 3: Testing and CI Infrastructure
docs/specs/02-spec-minvmd-linux-kvm/02-spec-minvmd-linux-kvm.md
Un-gates existing e2e tests for Linux behind environment flags, defines Linux KVM CI job provisioning (libkrun, kernel, rootfs, initramfs), and specifies warm-boot latency measurement via benchmark script with documentation.
Design Considerations and Verification
docs/specs/02-spec-minvmd-linux-kvm/02-spec-minvmd-linux-kvm.md
Declares non-goals (deferred session selection, auto-spawn), design expectations (libkrun API contract, install paths), technical considerations (kvm check semantics, marker socket behavior, test portability), security isolation notes, and explicit end-to-end verification matrix with required commands and expected outcomes.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related issues

  • Specification directly aligns with implementation work to run minvmd sessions in Linux microVMs with KVM backend and vsock↔UDS bridging.
  • Specification outlines the feature surface and implementation strategy for adding Linux KVM support to minvmd with libkrun integration.
  • Specification details the same feature target—Linux KVM backend for minvmd with boot, bridging, and e2e test expectations.

Suggested labels

needs-human

Suggested reviewers

  • norrietaylor
  • jtnkminimal
  • evanspearman

Poem

🐰 Across the Linux kernel's grassy plain,
minvmd hops with libkrun's reins,
KVM gates now open, specs laid clear,
From macOS walls to everywhere.
Let verification bloom—we've drawn the way! 🌟

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The pull request title directly and specifically summarizes the main change: adding a Linux host support specification for minvmd using KVM backend and vsock bridge, which is precisely what the changeset delivers.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.


Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 3

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@docs/specs/02-spec-minvmd-linux-kvm/02-spec-minvmd-linux-kvm.md`:
- Around line 238-244: The CI spec's Linux KVM job only sets MINVMD_E2E=1 but
does not provide the kernel/rootfs/initramfs inputs the gated tests require;
update the job description to wire the kernel, rootfs and initramfs environment
variables (the same kernel/rootfs/initramfs env names used by the verification
matrix) alongside MINVMD_E2E so the e2e run can materialize kernel + rootfs +
initramfs and execute cargo test -p minvmd -- --include-ignored; ensure the spec
text names the exact env vars (e.g., the kernel/rootfs/initramfs env identifiers
referenced in the matrix) and documents their expected sources/values for the
Linux KVM job.
- Line 388: The table row currently assigns the `minvmd boot --foreground`
smoke-test to R2.3 but R2.3 corresponds to the `cmd/run.rs` item; update the
unit ID to R2.2 so the boot smoke-test correctly maps to the boot work item
(change R2.3 → R2.2 for the row containing `MINVMD_E2E=1` + env vars and `minvmd
boot --foreground`), and confirm any related traceability references referencing
`cmd/run.rs` vs boot are consistent.
- Around line 122-128: Update the R1.1 doc entry to show the rpath linker arg
includes a directory (use `-Wl,-rpath,<dir>`) and mention the Linux default
prefix `/usr` with the `LIBKRUN_PREFIX` override; then modify the build script
(build.rs) so it does not return early on Linux and emits the matching cargo
directive `cargo:rustc-link-arg=-Wl,-rpath,<dir>` (using the resolved prefix
path), ensuring the same rpath behavior as the macOS branch and keeping the
existing environment override logic.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: e620bb83-a64b-427f-b3e5-49b98d4c8382

📥 Commits

Reviewing files that changed from the base of the PR and between 18e89bc and 2b0ed40.

📒 Files selected for processing (1)
  • docs/specs/02-spec-minvmd-linux-kvm/02-spec-minvmd-linux-kvm.md

Comment on lines +122 to +128
- **R1.1**: `build.rs` shall emit `cargo:rustc-link-search=native=` and
`cargo:rustc-link-arg=-Wl,-rpath,` link directives on Linux in addition to
macOS. The Linux default prefix shall be `/usr`, with the same
`LIBKRUN_PREFIX` env-var override as macOS. A comment shall note that on
Linux the typical install locations are `/usr/lib` (Fedora/RHEL: `dnf
install libkrun-devel`) and `/usr/local/lib` (source build); CI shall
install the library at the path used by the runner's provisioning step.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎯 Functional Correctness | 🟠 Major

Fix R1.1 Linux rpath requirement to include a directory and match build.rs

  • In docs/specs/02-spec-minvmd-linux-kvm/02-spec-minvmd-linux-kvm.md (R1.1), cargo:rustc-link-arg=-Wl,-rpath, is syntactically incomplete; the linker arg must include the directory (-Wl,-rpath,<dir>).
  • The current crates/minvmd/build.rs emits the -rpath link-arg only for macOS and returns early on Linux, so the “on Linux … shall emit” requirement is inconsistent with implementation.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@docs/specs/02-spec-minvmd-linux-kvm/02-spec-minvmd-linux-kvm.md` around lines
122 - 128, Update the R1.1 doc entry to show the rpath linker arg includes a
directory (use `-Wl,-rpath,<dir>`) and mention the Linux default prefix `/usr`
with the `LIBKRUN_PREFIX` override; then modify the build script (build.rs) so
it does not return early on Linux and emits the matching cargo directive
`cargo:rustc-link-arg=-Wl,-rpath,<dir>` (using the resolved prefix path),
ensuring the same rpath behavior as the macOS branch and keeping the existing
environment override logic.

Comment on lines +238 to +244
- **R3.4**: The CI configuration shall add a Linux KVM e2e job. The job runs
on a self-hosted Linux runner with `/dev/kvm` access (GCP nested-virt or
equivalent). It provisions libkrun ≥ 1.19.0, materializes the kernel +
rootfs + initramfs from Minimal packages, sets `MINVMD_E2E=1`, and runs
`cargo test -p minvmd -- --include-ignored`. The job is allowed-to-fail
initially (as the macOS e2e job was) and is promoted to required once the
runner is stable.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎯 Functional Correctness | 🟠 Major | ⚡ Quick win

Add the env wiring the Linux KVM job actually needs.

R3.4 says the job sets MINVMD_E2E=1, but the verification matrix still requires the kernel/rootfs/initramfs env vars. As written, the CI job description doesn't wire enough inputs to run the gated suite end-to-end.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@docs/specs/02-spec-minvmd-linux-kvm/02-spec-minvmd-linux-kvm.md` around lines
238 - 244, The CI spec's Linux KVM job only sets MINVMD_E2E=1 but does not
provide the kernel/rootfs/initramfs inputs the gated tests require; update the
job description to wire the kernel, rootfs and initramfs environment variables
(the same kernel/rootfs/initramfs env names used by the verification matrix)
alongside MINVMD_E2E so the e2e run can materialize kernel + rootfs + initramfs
and execute cargo test -p minvmd -- --include-ignored; ensure the spec text
names the exact env vars (e.g., the kernel/rootfs/initramfs env identifiers
referenced in the matrix) and documents their expected sources/values for the
Linux KVM job.

|------|------|---------|-----------------|
| R1.5 | — | `cargo build -p minvmd` (Linux) | Exit 0 |
| R1.5 | — | `cargo test -p minvmd` (Linux, unit tests) | All pass |
| R2.3 | `MINVMD_E2E=1` + env vars | `minvmd boot --foreground` (Linux) | Prints `vm-up` ≤ 10 s |

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

Fix the unit ID on the boot smoke-test row.

This row maps minvmd boot --foreground to R2.3, but R2.3 is the cmd/run.rs item; boot is covered by R2.2. That traceability mismatch will send implementers to the wrong work item.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@docs/specs/02-spec-minvmd-linux-kvm/02-spec-minvmd-linux-kvm.md` at line 388,
The table row currently assigns the `minvmd boot --foreground` smoke-test to
R2.3 but R2.3 corresponds to the `cmd/run.rs` item; update the unit ID to R2.2
so the boot smoke-test correctly maps to the boot work item (change R2.3 → R2.2
for the row containing `MINVMD_E2E=1` + env vars and `minvmd boot
--foreground`), and confirm any related traceability references referencing
`cmd/run.rs` vs boot are consistent.

@gominimal-aw-bot

Copy link
Copy Markdown
Contributor Author

sdd-validate: spec boundary findings

Resolved boundary: Spec — PR adds docs/specs/02-spec-minvmd-linux-kvm/02-spec-minvmd-linux-kvm.md (a *-spec-*.md file under docs/specs/).

Gate set applied: Spec gates (4 gates).


Gate 1 — Acceptance criteria testable ✅ Pass

All functional requirements (R1.1–R1.5, R2.1–R2.5, R3.1–R3.5) are verifiable as pass/fail:

  • Build and link: cargo build -p minvmd exits 0 or it doesn't.
  • Unit tests: cargo test -p minvmd passes or it doesn't.
  • Boot: minvmd boot --foreground prints vm-up within 10 s or it doesn't.
  • E2e: each test command exits 0 or it doesn't.
  • R3.5 latency report: the PR description either contains the latency table or it doesn't.

No vague aspirations found.


Gate 2 — No implementation leakage ⚠️ Warning

Several requirements prescribe specific function names, module paths, and Rust source-level constructs where a behavioral statement would be sufficient:

  • docs/specs/02-spec-minvmd-linux-kvm/02-spec-minvmd-linux-kvm.md:117 — R2.1 prescribes run_linux() and run_macos() as the required function names in cmd/vmm_child.rs.
  • docs/specs/02-spec-minvmd-linux-kvm/02-spec-minvmd-linux-kvm.md:126 — R2.2 prescribes run_linux() mirroring run_macos() in cmd/boot.rs.
  • docs/specs/02-spec-minvmd-linux-kvm/02-spec-minvmd-linux-kvm.md:90 — R1.2 prescribes pub mod krun as the specific Rust module path.
  • docs/specs/02-spec-minvmd-linux-kvm/02-spec-minvmd-linux-kvm.md:77 — R1.1 prescribes cargo:rustc-link-search=native= and cargo:rustc-link-arg=-Wl,-rpath, as the precise build directive strings.

Behavioral alternatives would be: "the daemon shall dispatch to the platform-appropriate VMM entry point on the target OS" rather than naming the functions; "the krun module shall be unconditionally compiled" rather than naming the Rust pub mod path.

This is a Warning. The leakage is significant in aggregate but the change is inherently a guard-removal refactor where the behavioral description partly overlaps with the code structure. No hand-off required.


Gate 3 — Assumptions explicit ✅ Pass

Key assumptions are stated:

No unstated assumptions found above the 80% confidence floor.


Gate 4 — Proof artifacts present and behavioral ✅ Pass

Each demoable unit carries 1–2 proof artifacts. All pass the empty-PR rule (none would pass against a PR that makes no code changes):

  • Unit 1: CLI (cargo build -p minvmd on Linux, exits 0) + Test (cargo test -p minvmd, exits 0). Both require the #[cfg] guards to be removed and libkrun linked.
  • Unit 2: CLI (minvmd boot --foreground, prints vm-up ≤ 10 s) + Test (boot_e2e, exits 0). Both require functional KVM boot.
  • Unit 3: Test (minimald_session_e2e, exits 0) + File (latency table in PR description). The test requires the e2e to run end-to-end on Linux/KVM; the file artifact requires the benchmark to be executed and reported.

Summary

Gate Result
1. Acceptance criteria testable ✅ Pass
2. No implementation leakage ⚠️ Warning
3. Assumptions explicit ✅ Pass
4. Proof artifacts present and behavioral ✅ Pass

No Blockers. The spec boundary passes clean. The implementation-leakage Warning is advisory: if the planner later needs flexibility in naming the Linux dispatch function or the Rust module, the spec's named constraints would need a /revise to relax them first.

Generated by sdd-validate for issue #399 · sonnet46 1.2M ·

@norrietaylor
norrietaylor enabled auto-merge (squash) June 12, 2026 20:49
@norrietaylor
norrietaylor merged commit 1f65e57 into main Jun 12, 2026
30 of 36 checks passed
@norrietaylor
norrietaylor deleted the spec/minvmd-linux-kvm-98d0ee6b5d90ad81 branch June 12, 2026 20: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.

spec: Linux host support for minvmd (KVM backend + vsock bridge)

1 participant