feat(release): ship minvmd to Linux as a static musl binary - #1104
Conversation
📝 WalkthroughWalkthroughThe changes add a cached static-musl ChangesStatic-musl libkrun build
minvmd linkage and release packaging
Estimated code review effort: 4 (Complex) | ~45 minutes Sequence Diagram(s)sequenceDiagram
participant ReleaseWorkflow
participant LibkrunAction
participant BuildScript
participant Cargo
participant MinvmdVerifier
ReleaseWorkflow->>LibkrunAction: request musl target
LibkrunAction->>BuildScript: build pinned libkrun
BuildScript->>Cargo: compile staticlib with musl target
BuildScript-->>LibkrunAction: staged libkrun.a
ReleaseWorkflow->>Cargo: build static minvmd with LIBKRUN_PREFIX
Cargo-->>MinvmdVerifier: minvmd binary
MinvmdVerifier-->>ReleaseWorkflow: static linkage and kvm_run verification
Possibly related issues
Possibly related PRs
Suggested reviewers: Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
3d98212 to
b2920f5
Compare
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
.github/workflows/release.yml (1)
203-222: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winExtract the duplicated static/KVM verification logic into a shared script.
The "Build static minvmd binary" + "Verify minvmd is static and links libkrun" steps are near-identical between the amd64 and arm64 jobs. The repo already has precedent for this exact pattern (
scripts/rewrite-macos-linkage.sh, used in this same file at line 364) — extracting to e.g.scripts/verify-minvmd-static.sh <bin>would remove the duplication and prevent the two jobs' verification logic from silently drifting apart over time.Also applies to: 312-329
🤖 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/release.yml around lines 203 - 222, The static and libkrun verification logic is duplicated between the amd64 and arm64 release jobs. Extract the checks currently in the “Verify minvmd is static and links libkrun” steps into a shared executable script such as scripts/verify-minvmd-static.sh accepting the binary path as its argument, then replace both workflow blocks with calls to that script while preserving the existing failure messages and success output.
🤖 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/release.yml:
- Around line 203-216: Replace the strings-based kvm_run check in the minvmd
verification step with an assertion based on linkage or another
strip-independent libkrun artifact. Apply the same linkage-based validation to
the later copy verification, preserving the existing static-binary check and
failure behavior.
---
Nitpick comments:
In @.github/workflows/release.yml:
- Around line 203-222: The static and libkrun verification logic is duplicated
between the amd64 and arm64 release jobs. Extract the checks currently in the
“Verify minvmd is static and links libkrun” steps into a shared executable
script such as scripts/verify-minvmd-static.sh accepting the binary path as its
argument, then replace both workflow blocks with calls to that script while
preserving the existing failure messages and success output.
🪄 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: 13bad9d6-9590-416d-ba9d-c9f7616bb1a9
📒 Files selected for processing (9)
.github/actions/build-libkrun-static-linux/action.yml.github/workflows/nightly.yml.github/workflows/release.ymlcrates/minvmd/build.rscrates/minvmd/src/krun/raw.rsdocs/internal/release-pipeline.mdscripts/build-libkrun-linux.shscripts/build-libkrun-macos.shscripts/stage-release.sh
b2920f5 to
e4dd42d
Compare
Completes the Linux half of #980. minvmd was the only one of the four binaries not staged for Linux, and the only one that could not be: it was a native-glibc build linking libkrun.so and dlopening libkrunfw.so.5, so shipping it meant ~29 MB of libraries plus RUNPATH machinery, a bin/lib sibling constraint and a glibc floor on users' disks. Built on #1070, which made minvmd linkable against a static libkrun. release.yml: both Linux jobs now build a static libkrun.a from the vendored pin and link minvmd against it as musl, alongside the three binaries that were already musl. arm64 gains a minvmd artifact for the first time — the dynamic build needed a native glibc host per arch and only amd64 had one, a constraint a static build does not have. The libkrun build rides a new build-libkrun-static-linux composite, modelled on setup-libkrun-macos: pin-keyed cache, build-on-miss, and a verify step that re-asserts the API floor and the symbol surface on a cache-restored archive. Both jobs assert the built binary is `statically linked` and actually contains the KVM backend. Neither is implied by a successful build: when build.rs finds no libkrun it emits a stub that compiles and links perfectly well, and would ship as a binary that bails at VM boot. stage-release.sh: Linux gains bin/minvmd plus the guest payload (data/{vmlinuz,rootfs.img,initramfs.cpio}) for both arches. All six guest artifacts were already produced for both arches; only the rows were missing. No lib/ component and no RUNPATH rewrite — that asymmetry with darwin is the entire point. nightly.yml: smoke-linux-kvm no longer materializes a libkrun prefix or sets LD_LIBRARY_PATH, because the shipped binary needs neither. It asserts that instead, so a regression to a dynamic build fails with a clear message rather than a loader error mid-boot. The userns sysctl stays — its justification cited the removed materialize step, but the sandboxed build the e2e drives needs it independently. setup-libkrun-linux is untouched and still used by ci-linux-kvm and nightly-tests, which build against the dynamic upstream package. Verified: workflow and composite YAML parse; shellcheck clean; a dry-run stage against stub artifacts emits all eight new Linux rows with correct dests, and the arm64 guest artifacts dedupe with darwin's as intended. Not verified locally: the builds themselves. x86_64 in particular has never been exercised — the static-musl proof in #1070 is aarch64-only, and this is the lane that settles it. Refs #980, #1065 Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
ci-linux-kvm is the only pre-merge lane that boots a real microVM, and it was booting the wrong binary. It built minvmd against the dynamic upstream libkrun package, shipped that .so in the testbed, and resolved it at runtime via LD_LIBRARY_PATH. Meanwhile Linux now ships a static-musl minvmd. That left the shipped configuration first exercised by nightly's smoke-linux-kvm — after merge. Nothing pre-merge compiled build-libkrun-linux.sh at all, and nothing anywhere had ever BOOTED a statically linked minvmd: release.yml only asserts `file` says static and `strings` finds kvm_run, which proves the archive is well-formed and the backend is linked, not that libkrun still works. That gap matters here more than usual. libkrun.a is produced by merging a whole Rust dependency closure with `ld -r` and then objcopy-localizing everything outside the krun_* API — precisely the kind of transform that links clean and misbehaves at runtime (two libstd copies, TLS, the panic runtime). A symbol check cannot catch that; a boot can. So this lane now builds libkrun statically from the vendored pin, builds minvmd for x86_64-unknown-linux-musl, and boots that. The nextest archive moves to the same target — the harnesses link libkrun too, and a native-gnu archive would test a different binary than the one shipped. Falls out of the change: no libkrun-prefix.tgz in the testbed, no $HOME/.krun unpack, no LIBKRUN_PREFIX or LD_LIBRARY_PATH in the test job. The binary carries its own libkrun. Three assertions rather than assumptions, because a silent regression to a dynamic link would quietly restore the gap this closes: MINVMD_REQUIRE_LIBKRUN=static on both cargo invocations (a build.rs that cannot find libkrun.a is now an error, not a stub), and a `file ... | grep statically linked` check at each end of the artifact handoff. Two path-filter fixes: vendor/libkrun/** was never listed, so a pin or patch bump could not re-run the lane that now builds from it; and the composite entry follows the lane onto build-libkrun-static-linux. The dynamic path keeps its coverage in nightly-tests.yml, which still builds against the upstream package — it remains the dev/`just up-kvm` configuration, just no longer the one CI proves before merge. Refs #980, #1065 Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
c0fed12 to
4004389
Compare
bc6b20e
into
feat/static-musl-libkrun
Completes the Linux half of #980.
minvmdwas the only one of the four binaries not staged for Linux, and the only one that could not be: a native-glibc build linkinglibkrun.soand dlopeninglibkrunfw.so.5. Shipping it as-is meant ~29 MB of libraries plus RUNPATH machinery, abin/libsibling constraint, and a glibc floor on users' disks. #1070 removed the reason; this ships it.release.ymlBoth Linux jobs build a static
libkrun.afrom the vendored pin and linkminvmdagainst it as musl, alongside the three binaries already built that way.arm64 gains a
minvmdartifact for the first time. The dynamic build needed a native glibc host per arch and only amd64 had one — a constraint a static build simply doesn't have. The two Linux arches finally ship the same set of binaries.The libkrun build rides a new
build-libkrun-static-linuxcomposite modelled onsetup-libkrun-macos: pin-keyed cache (commit + script hash + patches hash + target), build-on-miss, and a verify step that re-asserts both the API floor and the symbol surface on a possibly cache-restored archive.Each job asserts the binary is
statically linkedand actually contains the KVM backend. Neither is implied by a successful build — whenbuild.rsfinds no libkrun it emits a stub that compiles and links perfectly well, and would ship as a binary that bails at VM boot. That failure mode is silent without an explicit check, so both are explicit.stage-release.shLinux gains
bin/minvmdplus the guest payload (data/{vmlinuz,rootfs.img,initramfs.cpio}) for both arches. All six guest artifacts were already produced for both arches — only the rows were missing.No
lib/component and no RUNPATH rewrite. That asymmetry with darwin is the entire point:bin/minvmdlib/libkrun.*nightly.ymlsmoke-linux-kvmno longer materializes a libkrun prefix or setsLD_LIBRARY_PATH, because the shipped binary needs neither. It asserts that instead, so a regression to a dynamic build fails with a clear message rather than a confusing loader error mid-boot — the smoke's whole point is running the artifact exactly as a user receives it.The userns sysctl stays. Its comment justified it by the removed
mip materializestep, but the sandboxed build the e2e drives needs userns independently, so only the comment changed.setup-libkrun-linuxis untouched and not orphaned —ci-linux-kvmandnightly-testsstill use it to build against the dynamic upstream package.Verification
shellcheckcleanNot verified locally: the builds themselves. x86_64 in particular has never been exercised — the static-musl proof in #1070 is aarch64-only, and this is the lane that settles it. Worth a
dry_rundispatch of Release before merging.Rebased onto #1063
#1063 (Linux
gvproxy-minrows) landed while this was open and conflicted in the two files it predicted. Resolved additively — Linux now stagesbin/gvproxy-minandbin/minvmd+ the guest payload — and re-verified with a dry-run stage that emits all ten Linux rows. The stale "minvmd is not staged for Linux yet" note is gone from both the component table and the pipeline doc, and macOS keepsbin/gvproxy-min(this branch predated that rename fix).Refs #980, #1065
🤖 Generated with Claude Code
Note
Ship minvmd to Linux as a static musl binary linked against vendored libkrun
minvmdforlinux-amd64andlinux-arm64as statically linked musl binaries usingMINVMD_REQUIRE_LIBKRUN=static, replacing the previous glibc + dynamic libkrun approach.libkrun.afor a given musl target, verifying thekrun_add_disk3symbol is present and no non-krun_*symbols are exported.minvmdartifact is statically linked.minvmdand guest payload artifacts (initramfs.cpio,rootfs.img,vmlinuz) for Linux amd64 and arm64.Changes since #1104 opened
minvmdandlibkrunto static musl compilation [c0fed12]Macroscope summarized 4004389.