docs(arch-minvmd-linux-kvm): Linux host support for minvmd (KVM backend + vsock bridge) - #405
Conversation
…ckend Adds docs/specs/02-spec-minvmd-linux-kvm/architecture.md, the architecture record for extending minvmd from macOS-only to Linux (tracking issue #397). The chosen approach removes the #[cfg(target_os = "macos")] guards from pub mod krun, build.rs, image::kernel_format(), and VmConfig::apply(), adds run_linux() alongside run_macos() in cmd/vmm_child.rs and cmd/boot.rs (with a /dev/kvm capability check in place of the code-signing step), un-gates the three e2e test files, and adds a Linux KVM CI job. No ADR promoted: the decision is feature-local; libkrun's unified C API across both hypervisor backends is already documented in arch-minvmd-host-daemon. All five load-bearing assumptions are settled from repo state and the prior architecture record (arch-minvmd-host-daemon). Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
📝 WalkthroughWalkthroughAdds an architecture specification doc to extend crates/minvmd from macOS-only to a Linux KVM backend: details mechanical code changes (ungating, build/link, run_linux), runtime dispatch, CI/e2e job requirements, rejected alternatives, sourcing, and an assumptions ledger. ChangesLinux KVM Architecture Specification
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Possibly related issues
Possibly related PRs
Suggested labels
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. Comment |
There was a problem hiding this comment.
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/architecture.md`:
- Around line 153-157: The Linux KVM e2e job is currently non-blocking because
it sets continue-on-error: true; update the CI/workflow config for the "Linux
KVM e2e" job (the job that provisions libkrun, sets MINVMD_E2E=1 and runs cargo
test -p minvmd) to remove or set continue-on-error to false so failures fail the
workflow, and then mark that job as required in branch protection / repository
settings before relying on it as acceptance coverage.
- Around line 30-34: The spec wrongly claims Rust surface works on Linux purely
via identical extern "C" bindings; update the spec and implement/gate
Linux-specific Rust paths: remove or add proper cfgs and provide Linux
implementations that mirror the libkrun symbol surface for the items currently
macOS-only—specifically address crates/minvmd/src/lib.rs (pub mod krun),
crates/minvmd/src/image.rs (kernel_format), and crates/minvmd/src/vm.rs
(VmConfig::apply) so they are available for target_os = "linux" (or provide
Linux equivalents) while keeping krun/raw.rs extern "C" bindings consistent with
the Linux libkrun ABI. Ensure the spec text explains that un-gating requires
real Linux wrappers/config handling that match libkrun symbols.
- Around line 37-39: The spec incorrectly claims crates/minvmd/build.rs emits
Linux linker directives and defaults LIBKRUN_PREFIX to /usr, but build.rs
currently returns early on non-macOS so only macOS uses LIBKRUN_PREFIX; either
update docs to state that build.rs only configures linker/rpath on macOS
(mentioning crates/minvmd/build.rs and LIBKRUN_PREFIX) and remove the Linux /usr
default, or implement the Linux path in crates/minvmd/build.rs to emit
cargo:rustc-link-search and -rpath using LIBKRUN_PREFIX (defaulting to /usr) and
add CI checks to exercise the Linux behavior; make the chosen change and keep
the other (doc or code) consistent.
🪄 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: 1f37dae0-a85f-4082-a10b-ca529fdc822b
📒 Files selected for processing (1)
docs/specs/02-spec-minvmd-linux-kvm/architecture.md
| A Linux KVM e2e job on a self-hosted KVM-capable runner (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`. Initially `continue-on-error: | ||
| true`; promoted to required once the runner is stable. |
There was a problem hiding this comment.
🩺 Stability & Availability | 🟠 Major | ⚡ Quick win
Make the Linux KVM e2e job blocking before using it as acceptance coverage.
continue-on-error: true turns the only Linux signal into telemetry, not enforcement. That means regressions in the Linux boot/session path can still merge even though this PR is supposed to close the Linux-host support gap.
Suggested spec tweak
- Initially `continue-on-error: true`; promoted to required once the runner is stable.
+ Linux KVM e2e is required once introduced, so failures block merges.📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| A Linux KVM e2e job on a self-hosted KVM-capable runner (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`. Initially `continue-on-error: | |
| true`; promoted to required once the runner is stable. | |
| A Linux KVM e2e job on a self-hosted KVM-capable runner (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`. Linux KVM e2e is required once introduced, so failures block merges. |
🤖 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/architecture.md` around lines 153 - 157,
The Linux KVM e2e job is currently non-blocking because it sets
continue-on-error: true; update the CI/workflow config for the "Linux KVM e2e"
job (the job that provisions libkrun, sets MINVMD_E2E=1 and runs cargo test -p
minvmd) to remove or set continue-on-error to false so failures fail the
workflow, and then mark that job as required in branch protection / repository
settings before relying on it as acceptance coverage.
This comment has been minimized.
This comment has been minimized.
|
/revise address coderabbit concerns. Validate first |
…ure record
Validated all three findings against the current codebase before applying:
1. Clarify FFI boundary claim: krun/raw.rs and krun/ctx.rs need no code
changes, but pub mod krun, kernel_format(), and VmConfig::apply() are
all currently gated by #[cfg(target_os = "macos")] guards that must
be removed. Rewrote the section to separate the FFI-layer (unchanged)
from the Rust wrapper layer (guards to remove).
2. Fix build.rs description: the current build.rs explicitly returns early
on non-macOS ("On Linux this is a no-op — the crate compiles to a
runtime-bailing stub and never links libkrun"). Updated item 1 to
state that a Linux branch needs to be *added*, not that it already
emits linker flags.
3. Remove continue-on-error: the Linux KVM e2e CI job is now specified
as required (blocking) from the moment it is introduced, so regressions
cannot merge. The previous "promoted to required once stable" language
made the only Linux signal non-enforcing.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
|
Commit pushed:
|
There was a problem hiding this comment.
♻️ Duplicate comments (2)
docs/specs/02-spec-minvmd-linux-kvm/architecture.md (2)
30-38:⚠️ Potential issue | 🟡 Minor | ⚡ Quick winTighten the FFI-boundary wording.
This paragraph still reads as if matching
extern "C"bindings alone make the Linux port work. The spec later depends on Rust-side ungating and build-script changes, so this section should be reworded to avoid overclaiming what is already platform-neutral.🤖 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/architecture.md` around lines 30 - 38, The paragraph overstates portability by implying that matching extern "C" bindings alone enable the Linux port; update the text in architecture.md to clarify that while libkrun exports the same C API and krun/raw.rs and krun/ctx.rs need no API-level changes, additional Rust-side ungating (removing or adjusting #[cfg(target_os = "macos")] on pub mod krun, kernel_format(), and VmConfig::apply()) and build-script changes are required to enable Linux, and rephrase the sentence that currently claims the change is purely mechanical so it accurately lists these required Rust and build-script actions instead of suggesting only the FFI boundary matters.
40-45:⚠️ Potential issue | 🟡 Minor | ⚡ Quick winFrame the
/usrlinker default as proposed behavior.
LIBKRUN_PREFIX=/usris fine as the target Linux setup, but this text currently reads like an already-established repo behavior. Please mark it explicitly as part of the plannedbuild.rsLinux branch so the spec stays aligned with the current codebase.Also applies to: 86-91
🤖 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/architecture.md` around lines 40 - 45, Update the wording to clearly mark "/usr" as the proposed default for the planned Linux branch of build.rs rather than an existing behavior: state that the new Linux branch in build.rs will emit cargo:rustc-link-search and cargo:rustc-link-arg=-Wl,-rpath using LIBKRUN_PREFIX (proposed default LIBKRUN_PREFIX=/usr, matching Fedora's libkrun-devel layout), and make the same clarification for the later paragraph (the other instance referenced). Reference the planned build.rs Linux branch and LIBKRUN_PREFIX by name so readers know this is a proposed change, not current repo behavior.
🤖 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.
Duplicate comments:
In `@docs/specs/02-spec-minvmd-linux-kvm/architecture.md`:
- Around line 30-38: The paragraph overstates portability by implying that
matching extern "C" bindings alone enable the Linux port; update the text in
architecture.md to clarify that while libkrun exports the same C API and
krun/raw.rs and krun/ctx.rs need no API-level changes, additional Rust-side
ungating (removing or adjusting #[cfg(target_os = "macos")] on pub mod krun,
kernel_format(), and VmConfig::apply()) and build-script changes are required to
enable Linux, and rephrase the sentence that currently claims the change is
purely mechanical so it accurately lists these required Rust and build-script
actions instead of suggesting only the FFI boundary matters.
- Around line 40-45: Update the wording to clearly mark "/usr" as the proposed
default for the planned Linux branch of build.rs rather than an existing
behavior: state that the new Linux branch in build.rs will emit
cargo:rustc-link-search and cargo:rustc-link-arg=-Wl,-rpath using LIBKRUN_PREFIX
(proposed default LIBKRUN_PREFIX=/usr, matching Fedora's libkrun-devel layout),
and make the same clarification for the later paragraph (the other instance
referenced). Reference the planned build.rs Linux branch and LIBKRUN_PREFIX by
name so readers know this is a proposed change, not current repo behavior.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 66a1cb02-d310-4794-8a13-59757436b516
📒 Files selected for processing (1)
docs/specs/02-spec-minvmd-linux-kvm/architecture.md
This comment has been minimized.
This comment has been minimized.
|
/revise Verify each finding against current code. Fix only still-valid issues, skip the Duplicate comments:
|
…lanned default - Rephrase 'mechanical change' paragraph: krun/raw.rs and krun/ctx.rs need no API-level changes, but enabling Linux still requires removing cfg(target_os = "macos") guards on pub mod krun, kernel_format(), and VmConfig::apply(), plus a Linux build.rs linker branch. - Rephrase build.rs data-and-interface section to future tense (will be added / will emit) and label LIBKRUN_PREFIX=/usr as proposed default. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
|
Commit pushed:
|
There was a problem hiding this comment.
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
docs/specs/02-spec-minvmd-linux-kvm/architecture.md (1)
59-62:⚠️ Potential issue | 🟡 Minor | ⚡ Quick winBroaden the
/dev/kvmpreflight error handling.
ENOENTandEACCESare not the only failure modes here; on Linux, policy or container denials can surface asEPERMor other open errors. The spec should say “fail fast on any/dev/kvmopen error” and reserve errno-specific messaging for the common cases, otherwise the startup path may fall through to a vaguer libkrun failure.🤖 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/architecture.md` around lines 59 - 62, Update the `/dev/kvm` preflight open logic (in the check implemented in cmd/vmm_child.rs or cmd/boot.rs) so that any error returned from opening `/dev/kvm` causes an immediate failure instead of falling through; preserve errno-specific messages for ENOENT and EACCES, but for all other errors (e.g., EPERM or other open failures) return a clear, generic "failed to open /dev/kvm" error that includes the errno/text to aid debugging. Ensure the code path that previously continued to libkrun on non-ENOENT/EACCES now returns the new error, and keep the error messages descriptive and include the original error string.
🤖 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.
Outside diff comments:
In `@docs/specs/02-spec-minvmd-linux-kvm/architecture.md`:
- Around line 59-62: Update the `/dev/kvm` preflight open logic (in the check
implemented in cmd/vmm_child.rs or cmd/boot.rs) so that any error returned from
opening `/dev/kvm` causes an immediate failure instead of falling through;
preserve errno-specific messages for ENOENT and EACCES, but for all other errors
(e.g., EPERM or other open failures) return a clear, generic "failed to open
/dev/kvm" error that includes the errno/text to aid debugging. Ensure the code
path that previously continued to libkrun on non-ENOENT/EACCES now returns the
new error, and keep the error messages descriptive and include the original
error string.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: b247df8c-9024-4495-a7e8-41dd1afab06b
📒 Files selected for processing (1)
docs/specs/02-spec-minvmd-linux-kvm/architecture.md
sdd-validate · Architecture boundary · PR #405Boundary resolved: Architecture — adds Gate set applied: Architecture gates (4 gates) Results
Overall: Architecture boundary passed clean. No findings. No
|
Adds the architecture record for extending
minvmdfrom macOS-only to Linux, tracking issue #397.Chosen approach
Remove the
#[cfg(target_os = "macos")]guards that gatepub mod krun,build.rslink directives,image::kernel_format(), andVmConfig::apply(). Addrun_linux()alongsiderun_macos()incmd/vmm_child.rsandcmd/boot.rs(same libkrun call sequence; no code-signing step on Linux;/dev/kvmcapability check instead). Un-gate the three e2e test files and add a Linux KVM CI job.No ADR promoted. The libkrun API unification across both hypervisor backends is feature-local and already grounded in
arch-minvmd-host-daemon.Why this is mechanical
libkrun exports the same C API on macOS (Hypervisor.framework) and Linux (KVM). The
extern "C"block inkrun/raw.rsis already platform-agnostic. Extending to Linux is primarily removing guards and extendingbuild.rs.Files changed
docs/specs/02-spec-minvmd-linux-kvm/architecture.md— new architecture recordNext step
Merging this PR advances #397 to phase B (Unit decomposition), where
sdd-triageposts the proposed plan as a comment on the tracking issue.Closes #401
Summary by CodeRabbit