feat(minvmd): extend libkrun support to Linux/KVM - #414
Conversation
Un-gate the real (libkrun-linking) implementation so minvmd builds and runs on Linux over the KVM backend, not just macOS over Hypervisor.framework. The build script now detects libkrun (always linked on macOS; on Linux when present via LIBKRUN_PREFIX or a scan of the usual lib dirs) and emits a `minvmd_libkrun` cfg. That single cfg replaces every `target_os = "macos"` gate across the krun module, image/vm helpers, the boot/run/__krun-vmm subcommands, and the three e2e tests. Stock Linux CI has no libkrun, so it still builds the no-op stub and stays green; a Linux host with libkrun builds the real daemon with a plain `cargo build -p minvmd`. The Linux boot path mirrors macOS: libkrun abstracts HVF vs KVM, so the supervisor fork-execs the same `__krun-vmm` child, waits for the same READY marker, and serves the same UDS↔vsock bridge. The platform-specific supervisor functions are renamed to neutral names (run_supervisor / run_boot / run_vmm) since they now cover both OSes. Add an opt-in, non-gating `minvmd-linux-kvm-e2e` CI job on a self-hosted `[self-hosted, linux, kvm]` runner: it materializes the guest kernel + rootfs + initramfs natively, builds minvmd against the runner's libkrun, runs the boot / session / bridge e2e tests, and reports boot-to-READY latency. Gated on RUN_LINUX_KVM_CI == 'true' and absent from ci-success so an unavailable runner never blocks PRs. Closes: #411 Closes: #410 Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughReplaces Changesminvmd Linux/KVM Support via minvmd_libkrun cfg
Sequence Diagram(s)sequenceDiagram
participant CLI as minvmd CLI
participant Dispatch as cfg(minvmd_libkrun) dispatch
participant Hypervisor as ensure_hypervisor_accessible
participant KVM as /dev/kvm
participant Impl as run_boot / run_supervisor / run_vmm
CLI->>Dispatch: invoke boot / run / __krun-vmm
alt minvmd_libkrun enabled
Dispatch->>Impl: call real implementation
Impl->>Hypervisor: preflight check
Hypervisor->>KVM: open /dev/kvm read-only (Linux only)
KVM-->>Hypervisor: Ok or ENOENT / EACCES
Hypervisor-->>Impl: Ok or kvm_access_error
Impl-->>CLI: boot / supervisor result
else minvmd_libkrun disabled
Dispatch-->>CLI: Err("requires libkrun …")
end
Estimated code review effort🎯 4 (Complex) | ⏱️ ~60 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. ✨ Finishing Touches📝 Generate docstrings
Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
.github/workflows/ci.yml (1)
261-263: ⚡ Quick winAvoid one-off checkout hardening in a single step.
persist-credentials: falseis introduced only here; keep this policy consistent repo-wide (either adopt it everywhere or omit it in this one job).Based on learnings, this repository prefers not introducing
persist-credentials: falseon only oneactions/checkoutusage; apply consistently across workflows if adopted.🤖 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 @.github/workflows/ci.yml around lines 261 - 263, Remove the persist-credentials: false configuration from the actions/checkout@v6 step in this workflow. This parameter is only used in this single location across the repository, and the repo prefers consistent policies applied either everywhere or nowhere. Since this is an isolated one-off usage, remove this line to maintain consistency with the rest of the codebase.Source: Learnings
🤖 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 @.github/workflows/ci.yml:
- Around line 285-293: The libkrun preflight check in the "Verify libkrun is
available" step only searches fixed system directories and ignores the
LIBKRUN_PREFIX environment variable. Modify the check to first verify if
LIBKRUN_PREFIX is set and, if so, look for libkrun.so in that prefix location
(e.g., LIBKRUN_PREFIX/lib/libkrun.so). If LIBKRUN_PREFIX is not set, fall back
to the existing system directory checks. This ensures the preflight check honors
the same environment variable that build.rs uses, preventing false failures when
libkrun is installed at a custom location.
---
Nitpick comments:
In @.github/workflows/ci.yml:
- Around line 261-263: Remove the persist-credentials: false configuration from
the actions/checkout@v6 step in this workflow. This parameter is only used in
this single location across the repository, and the repo prefers consistent
policies applied either everywhere or nowhere. Since this is an isolated one-off
usage, remove this line to maintain consistency with the rest of the codebase.
🪄 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: b2f4804a-c47c-4a23-8168-7d1b8f40e977
📒 Files selected for processing (14)
.github/workflows/ci.ymlcrates/minvmd/build.rscrates/minvmd/src/cmd/boot.rscrates/minvmd/src/cmd/run.rscrates/minvmd/src/cmd/vmm_child.rscrates/minvmd/src/image.rscrates/minvmd/src/krun/ctx.rscrates/minvmd/src/krun/mod.rscrates/minvmd/src/lib.rscrates/minvmd/src/main.rscrates/minvmd/src/vm.rscrates/minvmd/tests/boot_e2e.rscrates/minvmd/tests/bridge_e2e.rscrates/minvmd/tests/minimald_session_e2e.rs
R2.4: before krun_start_enter, verify /dev/kvm is accessible on Linux so `boot`/`run` fail fast with an actionable message instead of an opaque libkrun error. ENOENT maps to "KVM module not loaded / no hardware virtualization"; EACCES maps to "add your user to the `kvm` group". The check runs in run_supervisor (covering --detach from the foreground caller) and in run_boot. No-op on macOS, where Hypervisor.framework availability is verified by krun_create_ctx itself. The error-mapping helper is platform-independent and unit-tested on every libkrun build. Also fix two misattributed (R2.4) comments on READY-marker code (the READY round-trip is R2.1/R2.2; boot_e2e is R3.1) and update the bench-minvmd-boot.sh header to document dual macOS/Linux use (codesigning is a macOS-only prerequisite; Linux/KVM needs none). Refs: #411 Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
There was a problem hiding this comment.
🧹 Nitpick comments (1)
.github/workflows/ci.yml (1)
261-263: ⚡ Quick winKeep checkout credential policy consistent across workflows.
This introduces a one-off
persist-credentials: falsepolicy in a single checkout step. Either remove it here or roll it out consistently as a repo-wide workflow hardening change to avoid policy drift.Based on learnings, this repository prefers avoiding single-step checkout hardening unless applied consistently across all workflow checkout steps.
🤖 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 @.github/workflows/ci.yml around lines 261 - 263, The checkout step using actions/checkout@v6 in the ci.yml workflow file includes a persist-credentials: false configuration that is not applied consistently across other checkout steps in the repository's workflows. Either remove the persist-credentials: false parameter from this checkout step to maintain the existing checkout policy, or apply this configuration consistently across all checkout steps throughout all workflow files as a repository-wide hardening change. Based on the repository's preference for consistency, removing this single-step configuration is the recommended approach.Source: Learnings
🤖 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.
Nitpick comments:
In @.github/workflows/ci.yml:
- Around line 261-263: The checkout step using actions/checkout@v6 in the ci.yml
workflow file includes a persist-credentials: false configuration that is not
applied consistently across other checkout steps in the repository's workflows.
Either remove the persist-credentials: false parameter from this checkout step
to maintain the existing checkout policy, or apply this configuration
consistently across all checkout steps throughout all workflow files as a
repository-wide hardening change. Based on the repository's preference for
consistency, removing this single-step configuration is the recommended
approach.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: dd0e0a4f-8e7c-4862-85ff-11ff3e763959
📒 Files selected for processing (6)
.github/workflows/ci.ymlcrates/minvmd/src/cmd/boot.rscrates/minvmd/src/cmd/mod.rscrates/minvmd/src/cmd/run.rscrates/minvmd/src/cmd/vmm_child.rsscripts/bench-minvmd-boot.sh
✅ Files skipped from review due to trivial changes (1)
- scripts/bench-minvmd-boot.sh
🚧 Files skipped from review as they are similar to previous changes (2)
- crates/minvmd/src/cmd/boot.rs
- crates/minvmd/src/cmd/run.rs
Replace the opt-in self-hosted minvmd-linux-kvm-e2e job (which needed a preprovisioned [self-hosted, linux, kvm] runner with libkrun already installed) with a path-scoped ci-linux-kvm.yml that runs on GitHub-hosted runners across an x86_64 (ubuntu-latest) + aarch64 (ubuntu-24.04-arm) matrix. - Add scripts/build-libkrun.sh: builds libkrunfw v5.5.0 + libkrun v1.19.0 (BLK=1, so krun_add_disk2 is exported) from source into a cacheable prefix; idempotent so a cache hit skips the kernel compile. - Enable /dev/kvm for the runner user via a udev rule, failing fast if the runner has no KVM. - Exercise the run/daemon path (run --detach -> status -> stop) alongside the existing boot/session/bridge e2e tests and the boot latency bench. - Non-gating and path-scoped, mirroring ci-macos.yml. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 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 @.github/workflows/ci-linux-kvm.yml:
- Around line 186-199: The three grep commands checking for JSON state values in
status.json, status.json, and status-after.json (lines looking for
'"state":"running"', '"vmm_pid":[0-9]', and '"state":"stopped"') should be
replaced with structured JSON parsing using jq instead. Replace each grep -q
pattern with corresponding jq expressions that directly query the JSON object
fields (such as checking if .state equals "running" or "stopped" and verifying
.vmm_pid contains a numeric value), which will be format-agnostic and resilient
to JSON whitespace or formatting changes.
In `@scripts/build-libkrun.sh`:
- Around line 35-38: The idempotency check at line 35 only verifies the presence
of the libkrun.so file but does not validate that the installed version matches
the pinned versions (v5.5.0 and v1.19.0). This allows stale or incompatible
installations to bypass the build. Enhance the conditional logic that checks `[
-e "$PREFIX/lib64/libkrun.so" ]` to also verify the version of the installed
libkrun matches the expected pinned version, either by checking a version stamp
file created during the build or by extracting version information from the
binary itself. This ensures reproducibility and prevents skipping when a version
mismatch exists.
🪄 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: 3ee4c8bc-0381-4b76-8385-74b6cd1bb9b9
📒 Files selected for processing (2)
.github/workflows/ci-linux-kvm.ymlscripts/build-libkrun.sh
The first CI (Linux KVM) run failed on both legs: - x86_64: libkrunfw's Makefile forwards $(MAKEFLAGS) verbatim into the kernel's recursive make. Building it via `make -C` enables print-directory mode, which injects a bare `w` token into MAKEFLAGS that the kernel make then treats as a goal (`make w` -> "No rule to make target 'w'"). Build libkrunfw/libkrun with an in-dir `cd` + explicit `-jN` and no exported MAKEFLAGS, the upstream-standard invocation. - aarch64: GitHub-hosted ubuntu-24.04-arm has no /dev/kvm, so the Linux/KVM e2e cannot run there. Drop the matrix and run x86_64-only; aarch64 + libkrun boot stays covered by the macOS lane (Apple Silicon). Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
There was a problem hiding this comment.
🧹 Nitpick comments (1)
.github/workflows/ci-linux-kvm.yml (1)
106-113: ⚡ Quick winInclude the build script in the libkrun cache key to prevent stale reuse.
The cache key only tracks pinned version strings, so changes in
scripts/build-libkrun.shcan incorrectly hit old artifacts and skip the intended rebuild.Suggested diff
- name: Cache libkrun (libkrunfw v5.5.0 + libkrun v1.19.0) # Keyed on the pinned versions: the kernel compile only runs on a cache # miss. Bump the suffix when scripts/build-libkrun.sh changes pins. uses: actions/cache@v5 with: path: ${{ env.KRUN_PREFIX }} - key: x86_64-libkrun-fw5.5.0-krun1.19.0-blk + key: x86_64-libkrun-fw5.5.0-krun1.19.0-${{ hashFiles('scripts/build-libkrun.sh') }}🤖 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 @.github/workflows/ci-linux-kvm.yml around lines 106 - 113, The cache key for the libkrun cache action named "Cache libkrun" only includes pinned version strings and does not reference the build script, so changes to scripts/build-libkrun.sh won't invalidate the cache and will cause stale artifacts to be reused. Update the key field in the cache action to include a hash of the build script using GitHub's hashFiles function (hashFiles('scripts/build-libkrun.sh')) so that any modifications to the script will automatically change the cache key and force a rebuild instead of reusing old cached artifacts.
🤖 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.
Nitpick comments:
In @.github/workflows/ci-linux-kvm.yml:
- Around line 106-113: The cache key for the libkrun cache action named "Cache
libkrun" only includes pinned version strings and does not reference the build
script, so changes to scripts/build-libkrun.sh won't invalidate the cache and
will cause stale artifacts to be reused. Update the key field in the cache
action to include a hash of the build script using GitHub's hashFiles function
(hashFiles('scripts/build-libkrun.sh')) so that any modifications to the script
will automatically change the cache key and force a rebuild instead of reusing
old cached artifacts.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 2fdb6679-b608-49a6-b0f3-5e0dcfb62b3e
📒 Files selected for processing (2)
.github/workflows/ci-linux-kvm.ymlscripts/build-libkrun.sh
🚧 Files skipped from review as they are similar to previous changes (1)
- scripts/build-libkrun.sh
The libkrun build now succeeds, but `fetch-artifact.sh` (cargo build -p minimal) failed compiling remote-proto: protoc failed: google/protobuf/timestamp.proto: File not found. The well-known protos live in libprotobuf-dev, which protobuf-compiler only pulls via recommends. Since the dependency install uses --no-install-recommends (to stay lean for the libkrun toolchain), name libprotobuf-dev explicitly. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
actions/cache's default post-job save is skipped when the job fails, so a failure after the libkrun step forced a ~15 min kernel recompile on every iteration. Split into cache/restore + an explicit cache/save placed right after the build, so the expensive prefix is cached as soon as it exists — before any later step (e2e/bench) can fail. Gated on a cache miss since cache keys are immutable. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
The Linux/KVM boot e2e failed on x86_64 with `krun_start_enter ... Invalid argument (EINVAL)`. The x86_64 `virtio-kernel` artifact is a bzImage: a PE/`MZ` container that embeds the `vmlinux` ELF as a gzip member. minvmd passed `KernelFormat::Elf`, so libkrun handed the PE container straight to its ELF loader, which cannot parse it. Use `KernelFormat::ImageGz` (already in the enum): libkrun scans for the gzip magic (1f 8b 08), inflates the single member to the vmlinux ELF, and ELF-loads it. Verified against the materialized artifact — the gzip member at the first magic match decompresses to a 46 MB x86-64 ELF vmlinux. aarch64 is unaffected (ships an uncompressed Image → Raw). Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
With the ImageGz kernel fix the guest now boots on x86_64 KVM and Boot E2E + Session E2E pass, but Bridge E2E failed: it read back "SSH-2.0-russh_0.6" instead of its echo payload. bridge_e2e targets the Stage-1 guest "vsock stub" — a socat/cat echo on port 2222 — which minimald-as-pid1 replaced with a direct SSH session server. The test is obsolete against the current rootfs. The macOS lane already runs only boot_e2e + minimald_session_e2e; match it. Bridge session coverage comes from Session E2E + the daemon lifecycle step. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Address CodeRabbit review feedback: - build-libkrun.sh: gate the skip-rebuild on a version stamp, not mere presence of libkrun.so. A restored cache (or local prefix reuse) built from different pins is now rebuilt instead of silently accepted, so a pin bump can't yield a stale install. - ci-linux-kvm.yml: assert the daemon state with `jq -e` (preinstalled on GitHub runners) instead of grepping the raw JSON, so the lifecycle check doesn't break on harmless formatting changes. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
The previous cache was saved before build-libkrun.sh wrote its version stamp, so the new stamp-gated idempotency check would treat the restored prefix as stale and rebuild — yet the save step is gated on a cache miss, so the rebuilt (stamped) prefix would never be re-saved. Every run would then rebuild libkrun from scratch. Bump the key (`-blk` → `-blk-stamped`) so the stamped prefix is saved fresh once, after which restore hits and the build skips. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
The daemon lifecycle step failed asserting state=="running" right after
`run --detach`: status showed `{"state":"starting","vmm_pid":null}`.
`run --detach` returns once the host UDS accepts connections, which libkrun
opens early in VM setup — ahead of the supervisor's Starting->Running
transition (set after the guest READY marker). Poll status for up to ~15s
for Running instead of asserting immediately, removing the race.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
The daemon lifecycle step reached Running (the poll fixed the earlier race) and stopped cleanly, but still exited 1: `minvmd status --json` exits 1 when stopped (documented), and `status --json | tee status-after.json` tripped `set -o pipefail` under `set -e`. The bare `status` was already guarded with `if`; the piped `--json` query was not. Capture it with `> status-after.json || true`, then assert state==stopped via jq and re-confirm the non-zero exit separately. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
There was a problem hiding this comment.
Actionable comments posted: 2
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
.github/workflows/ci-linux-kvm.yml (1)
55-57:⚠️ Potential issue | 🟠 Major | ⚡ Quick winAdd the opt-in gate for the Linux/KVM lane.
Line [55] defines a heavy job that currently runs whenever this workflow is triggered. The PR objective says this lane should be opt-in (
RUN_LINUX_KVM_CI == 'true'), but there is no job-levelif:guard, so it will execute by default.Suggested patch
jobs: minvmd-linux-kvm-e2e: + if: ${{ vars.RUN_LINUX_KVM_CI == 'true' }} runs-on: ubuntu-latest # x86_64; KVM-capable timeout-minutes: 60🤖 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 @.github/workflows/ci-linux-kvm.yml around lines 55 - 57, The minvmd-linux-kvm-e2e job currently lacks a conditional guard and will run on every workflow trigger. Add a job-level if condition to the minvmd-linux-kvm-e2e job that checks whether the environment variable RUN_LINUX_KVM_CI equals 'true', ensuring this heavy job only executes when explicitly opted into.
🧹 Nitpick comments (1)
.github/workflows/ci-linux-kvm.yml (1)
59-62: ⚡ Quick winAlign
actions/checkoutcredential setting with repo-wide convention.Line [61] sets
persist-credentials: falsein this workflow only. In this repo, that hardening should be applied consistently across all workflows (or not at all) to avoid policy drift.Based on learnings, “don’t harden individual
actions/checkoutsteps by addingpersist-credentials: falseonly in one workflow/step; if needed, apply it repo-wide.”🤖 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 @.github/workflows/ci-linux-kvm.yml around lines 59 - 62, The `persist-credentials: false` setting in the `actions/checkout@v6` action in this workflow is inconsistently applied compared to the rest of the repository. Review all other GitHub workflow files in the `.github/workflows/` directory to determine the repo-wide convention for this security hardening setting. If other workflows do not include this setting, remove it from the `actions/checkout` step in this file to maintain consistency. If this is a desired security policy, ensure it is applied uniformly across all workflows that use `actions/checkout` to avoid policy drift.Source: Learnings
🤖 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 `@scripts/bench-minvmd-boot.sh`:
- Around line 28-31: The usage documentation or example in the script file does
not reflect the new requirement for MINVMD_INITRAMFS environment variable that
was added in the validation block starting at line 28. Update the usage example
or documentation section at the beginning of the script to include all three
required environment variables: MINVMD_KERNEL_PATH, MINVMD_ROOTFS_PATH, and
MINVMD_INITRAMFS, so users understand all three inputs are mandatory before
running the script.
- Around line 34-35: The script checks only for the `timeout` command, but on
macOS with Homebrew coreutils the GNU coreutils binary is named `gtimeout`
unless the gnubin directory is on PATH. Modify the command check at line 34 to
test for both `timeout` and `gtimeout`, storing the result in a variable. Then
replace the hardcoded `timeout` calls at lines 61 and 71 with this variable
reference so the script uses whichever binary is available on the system.
---
Outside diff comments:
In @.github/workflows/ci-linux-kvm.yml:
- Around line 55-57: The minvmd-linux-kvm-e2e job currently lacks a conditional
guard and will run on every workflow trigger. Add a job-level if condition to
the minvmd-linux-kvm-e2e job that checks whether the environment variable
RUN_LINUX_KVM_CI equals 'true', ensuring this heavy job only executes when
explicitly opted into.
---
Nitpick comments:
In @.github/workflows/ci-linux-kvm.yml:
- Around line 59-62: The `persist-credentials: false` setting in the
`actions/checkout@v6` action in this workflow is inconsistently applied compared
to the rest of the repository. Review all other GitHub workflow files in the
`.github/workflows/` directory to determine the repo-wide convention for this
security hardening setting. If other workflows do not include this setting,
remove it from the `actions/checkout` step in this file to maintain consistency.
If this is a desired security policy, ensure it is applied uniformly across all
workflows that use `actions/checkout` to avoid policy drift.
🪄 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: 62e1e1f2-f3b2-4e41-8408-727e54075675
📒 Files selected for processing (7)
.github/workflows/ci-linux-kvm.ymlcrates/minvmd/src/cmd/boot.rscrates/minvmd/src/image.rscrates/minvmd/src/krun/raw.rscrates/minvmd/tests/minimald_session_e2e.rsscripts/bench-minvmd-boot.shscripts/build-libkrun.sh
✅ Files skipped from review due to trivial changes (2)
- crates/minvmd/src/krun/raw.rs
- crates/minvmd/tests/minimald_session_e2e.rs
🚧 Files skipped from review as they are similar to previous changes (3)
- crates/minvmd/src/image.rs
- crates/minvmd/src/cmd/boot.rs
- scripts/build-libkrun.sh
There was a problem hiding this comment.
Caution
Inline review comments failed to post. This is likely due to GitHub's internal server error or limits when posting large numbers of comments. If you are seeing this consistently it is likely a permissions issue. Please check "Moderation" -> "Code review limits" under your organization settings.
Actionable comments posted: 2
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
.github/workflows/ci-linux-kvm.yml (1)
55-57:⚠️ Potential issue | 🟠 Major | ⚡ Quick winAdd the opt-in gate for the Linux/KVM lane.
Line [55] defines a heavy job that currently runs whenever this workflow is triggered. The PR objective says this lane should be opt-in (
RUN_LINUX_KVM_CI == 'true'), but there is no job-levelif:guard, so it will execute by default.Suggested patch
jobs: minvmd-linux-kvm-e2e: + if: ${{ vars.RUN_LINUX_KVM_CI == 'true' }} runs-on: ubuntu-latest # x86_64; KVM-capable timeout-minutes: 60🤖 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 @.github/workflows/ci-linux-kvm.yml around lines 55 - 57, The minvmd-linux-kvm-e2e job currently lacks a conditional guard and will run on every workflow trigger. Add a job-level if condition to the minvmd-linux-kvm-e2e job that checks whether the environment variable RUN_LINUX_KVM_CI equals 'true', ensuring this heavy job only executes when explicitly opted into.
🧹 Nitpick comments (1)
.github/workflows/ci-linux-kvm.yml (1)
59-62: ⚡ Quick winAlign
actions/checkoutcredential setting with repo-wide convention.Line [61] sets
persist-credentials: falsein this workflow only. In this repo, that hardening should be applied consistently across all workflows (or not at all) to avoid policy drift.Based on learnings, “don’t harden individual
actions/checkoutsteps by addingpersist-credentials: falseonly in one workflow/step; if needed, apply it repo-wide.”🤖 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 @.github/workflows/ci-linux-kvm.yml around lines 59 - 62, The `persist-credentials: false` setting in the `actions/checkout@v6` action in this workflow is inconsistently applied compared to the rest of the repository. Review all other GitHub workflow files in the `.github/workflows/` directory to determine the repo-wide convention for this security hardening setting. If other workflows do not include this setting, remove it from the `actions/checkout` step in this file to maintain consistency. If this is a desired security policy, ensure it is applied uniformly across all workflows that use `actions/checkout` to avoid policy drift.Source: Learnings
🤖 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 `@scripts/bench-minvmd-boot.sh`:
- Around line 28-31: The usage documentation or example in the script file does
not reflect the new requirement for MINVMD_INITRAMFS environment variable that
was added in the validation block starting at line 28. Update the usage example
or documentation section at the beginning of the script to include all three
required environment variables: MINVMD_KERNEL_PATH, MINVMD_ROOTFS_PATH, and
MINVMD_INITRAMFS, so users understand all three inputs are mandatory before
running the script.
- Around line 34-35: The script checks only for the `timeout` command, but on
macOS with Homebrew coreutils the GNU coreutils binary is named `gtimeout`
unless the gnubin directory is on PATH. Modify the command check at line 34 to
test for both `timeout` and `gtimeout`, storing the result in a variable. Then
replace the hardcoded `timeout` calls at lines 61 and 71 with this variable
reference so the script uses whichever binary is available on the system.
---
Outside diff comments:
In @.github/workflows/ci-linux-kvm.yml:
- Around line 55-57: The minvmd-linux-kvm-e2e job currently lacks a conditional
guard and will run on every workflow trigger. Add a job-level if condition to
the minvmd-linux-kvm-e2e job that checks whether the environment variable
RUN_LINUX_KVM_CI equals 'true', ensuring this heavy job only executes when
explicitly opted into.
---
Nitpick comments:
In @.github/workflows/ci-linux-kvm.yml:
- Around line 59-62: The `persist-credentials: false` setting in the
`actions/checkout@v6` action in this workflow is inconsistently applied compared
to the rest of the repository. Review all other GitHub workflow files in the
`.github/workflows/` directory to determine the repo-wide convention for this
security hardening setting. If other workflows do not include this setting,
remove it from the `actions/checkout` step in this file to maintain consistency.
If this is a desired security policy, ensure it is applied uniformly across all
workflows that use `actions/checkout` to avoid policy drift.
🪄 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: 62e1e1f2-f3b2-4e41-8408-727e54075675
📒 Files selected for processing (7)
.github/workflows/ci-linux-kvm.ymlcrates/minvmd/src/cmd/boot.rscrates/minvmd/src/image.rscrates/minvmd/src/krun/raw.rscrates/minvmd/tests/minimald_session_e2e.rsscripts/bench-minvmd-boot.shscripts/build-libkrun.sh
✅ Files skipped from review due to trivial changes (2)
- crates/minvmd/src/krun/raw.rs
- crates/minvmd/tests/minimald_session_e2e.rs
🚧 Files skipped from review as they are similar to previous changes (3)
- crates/minvmd/src/image.rs
- crates/minvmd/src/cmd/boot.rs
- scripts/build-libkrun.sh
🛑 Comments failed to post (2)
scripts/bench-minvmd-boot.sh (2)
28-31:
⚠️ Potential issue | 🟡 Minor | ⚡ Quick winSync usage docs with the new required initramfs input.
Line 28 makes
MINVMD_INITRAMFSmandatory, but the usage example still documents only two env vars, which causes avoidable first-run confusion.Suggested patch
-# MINVMD_KERNEL_PATH=... MINVMD_ROOTFS_PATH=... scripts/bench-minvmd-boot.sh [N] [minvmd-binary] +# MINVMD_KERNEL_PATH=... MINVMD_ROOTFS_PATH=... MINVMD_INITRAMFS=... \ +# scripts/bench-minvmd-boot.sh [N] [minvmd-binary]🤖 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 `@scripts/bench-minvmd-boot.sh` around lines 28 - 31, The usage documentation or example in the script file does not reflect the new requirement for MINVMD_INITRAMFS environment variable that was added in the validation block starting at line 28. Update the usage example or documentation section at the beginning of the script to include all three required environment variables: MINVMD_KERNEL_PATH, MINVMD_ROOTFS_PATH, and MINVMD_INITRAMFS, so users understand all three inputs are mandatory before running the script.
34-35:
⚠️ Potential issue | 🟠 Major🧩 Analysis chain
🏁 Script executed:
#!/bin/bash # Verify timeout command availability shape on target host set -u command -v timeout >/dev/null && echo "timeout found: $(command -v timeout)" || echo "timeout not found" command -v gtimeout >/dev/null && echo "gtimeout found: $(command -v gtimeout)" || echo "gtimeout not found"Repository: gominimal/minimal
Length of output: 98
🏁 Script executed:
cat -n scripts/bench-minvmd-boot.sh | head -80Repository: gominimal/minimal
Length of output: 4439
Add
gtimeoutfallback to maintain macOS portability.Line 34 and calls at lines 61 and 71 assume
timeoutexists. On macOS with Homebrew coreutils, the binary isgtimeoutunlessgnubinis onPATH, causing the script to fail despite GNU coreutils being installed.Suggested patch
-command -v timeout >/dev/null || { echo "timeout required (install GNU coreutils)" >&2; exit 1; } +if command -v timeout >/dev/null; then + TIMEOUT_BIN=timeout +elif command -v gtimeout >/dev/null; then + TIMEOUT_BIN=gtimeout +else + echo "timeout required (install GNU coreutils)" >&2 + exit 1 +fi @@ -if ! timeout "$BOOT_TIMEOUT" "$BIN" boot </dev/null >"$OUT" 2>&1 || ! grep -qx vm-up "$OUT"; then +if ! "$TIMEOUT_BIN" "$BOOT_TIMEOUT" "$BIN" boot </dev/null >"$OUT" 2>&1 || ! grep -qx vm-up "$OUT"; then @@ - if timeout "$BOOT_TIMEOUT" "$BIN" boot </dev/null >"$OUT" 2>/dev/null && grep -qx vm-up "$OUT"; then + if "$TIMEOUT_BIN" "$BOOT_TIMEOUT" "$BIN" boot </dev/null >"$OUT" 2>/dev/null && grep -qx vm-up "$OUT"; thenAlso applies to: lines 61–63, 71–72
🤖 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 `@scripts/bench-minvmd-boot.sh` around lines 34 - 35, The script checks only for the `timeout` command, but on macOS with Homebrew coreutils the GNU coreutils binary is named `gtimeout` unless the gnubin directory is on PATH. Modify the command check at line 34 to test for both `timeout` and `gtimeout`, storing the result in a variable. Then replace the hardcoded `timeout` calls at lines 61 and 71 with this variable reference so the script uses whichever binary is available on the system.
The bench harness checked for and invoked GNU `timeout`, but Homebrew coreutils installs it as `gtimeout` unless the gnubin dir is on PATH, so the documented macOS path failed at the dependency check. Prefer `timeout`, fall back to `gtimeout`. Also sync the usage comment to list MINVMD_INITRAMFS, which the validation block already requires. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
|
Addressing the latest CodeRabbit review (commit `cd246b22`): Fixed in 523bff8:
Deferred to a human (workflow files): the two remaining items both target `.github/workflows/ci-linux-kvm.yml` (opt-in `if: ${{ vars.RUN_LINUX_KVM_CI == 'true' }}` gate on the heavy job, and the `persist-credentials: false` consistency nit). These are CI-policy changes to a protected path that this automated pass is not permitted to edit; leaving them for the PR author to apply. @coderabbitai review |
|
I'll kick off a fresh review now. ✅ Action performedReview finished.
|
Closes #411. Folds #410 (Unit 3).
What
Un-gate minvmd's real (libkrun-linking) implementation so it builds and runs on Linux over the KVM backend, not just macOS over Hypervisor.framework.
How
build.rsdetects libkrun and emits aminvmd_libkruncfg:/opt/homebrew/lib,LIBKRUN_PREFIXoverrides).LIBKRUN_PREFIXor a scan of the usual lib dirs). Otherwise the no-op stub is built.target_os = "macos"gate acrosskrun,image,vm, theboot/run/__krun-vmmsubcommands, and the three e2e tests.__krun-vmmfork-exec, same READY marker, same UDS↔vsock bridge. Supervisor fns renamed to neutralrun_supervisor/run_boot/run_vmm.boot/runprobe/dev/kvm(O_RDONLY) beforekrun_start_enterand fail fast with an actionable message —ENOENT→ "KVM module not loaded / no hardware virtualization",EACCES→ "add your user to thekvmgroup". No-op on macOS (Hypervisor.framework availability is verified bykrun_create_ctx). The error-mapping helper is platform-independent and unit-tested on every libkrun build.minvmd-linux-kvm-e2eCI job on[self-hosted, linux, kvm]: materializes guest kernel + rootfs + initramfs natively, builds minvmd against the runner's libkrun, runs the boot/session/bridge e2e tests, and benches boot latency.Why a detected cfg, not
target_os = "linux"Stock Linux CI (
ubuntu-latest) has no libkrun. Gating ontarget_oswould force-lkrunand break every existing Linux job. Detection keeps stock CI on the stub (green) while a libkrun-provisioned host builds the real daemon with a plaincargo build -p minvmd.CI job is opt-in and non-gating
ci.ymlis not path-scoped, so the job runs only whenRUN_LINUX_KVM_CI == 'true'(set it once a[self-hosted, linux, kvm]runner is provisioned with/dev/kvm+ libkrun). It is deliberately absent fromci-success, so an unavailable runner never blocks PRs.Validation
Local host is macOS — Linux/KVM proof artifacts cannot be produced here and are deferred to the self-hosted runner.
Run locally (macOS, libkrun 1.19.0):
cargo test -p minvmd— 54 passed, 4 ignored (includes the two R2.4 error-mapping tests)cargo clippy -p minvmd --all-targets -- -D warnings— cleancargo fmt -p minvmd -- --check— cleancargo clippy -p minvmd --lib --bins --target x86_64-unknown-linux-gnu -- -D warnings— stub path clean (no libkrun present → stub selected)--cfg minvmd_libkrun+cargo check --target x86_64-unknown-linux-gnu), including the/dev/kvmprobe branchactionlint .github/workflows/ci.yml— no new findings (customkvmself-hosted label note is cosmetic)Deferred to the
minvmd-linux-kvm-e2erunner (proof artifacts):cargo build -p minvmdlinks cleanly on Linux with libkrun.MINVMD_E2E=1 cargo test -p minvmd --test minimald_session_e2e -- --include-ignoredpasses over the UDS↔vsock bridge.Boot-to-READY latency (Linux/KVM)
Pending the self-hosted runner;
scripts/bench-minvmd-boot.shemits the row below. macOS/HVF baseline is ~75 ms.Out of scope
tests/krun_smoke.rsandsrc/bin/krun_smoke_child.rs(not in the issue's file list) stay macOS-only; the Linux job runs the boot/session/bridge e2e instead.🤖 Generated with Claude Code
Summary by CodeRabbit
/dev/kvm) with actionable guidance.