Skip to content

microvm-rootfs: add ip and nsenter to the guest - #298

Merged
norrietaylor merged 2 commits into
mainfrom
add-ip-nsenter-socat-microvm-rootfs
Jun 26, 2026
Merged

microvm-rootfs: add ip and nsenter to the guest#298
norrietaylor merged 2 commits into
mainfrom
add-ip-nsenter-socat-microvm-rootfs

Conversation

@norrietaylor

@norrietaylor norrietaylor commented Jun 26, 2026

Copy link
Copy Markdown
Member

Add iproute2 (ip) and util-linux's nsenter to the microVM guest rootfs runtime closure for network/namespace plumbing.

Change

  • microvm-rootfs/build.ncl: add iproute2 (full) and subsetOf util-linux ["nsenter"] to runtime_deps.
  • util-linux/build.ncl: add a granular nsenter output so consumers can pull just that binary.
  • microvm-rootfs/build.sh: replace the wholesale rm -rf $STAGE/usr/sbin with a name-based removal of the full e2fsprogs sbin set.

Why subsetOf util-linux

nsenter links only glibc — it needs none of util-linux's shared libs or other 113 tools. Depending on the whole package added ~18 MB of unwanted binaries (mount, fdisk, agetty, dmesg, …). subsetOf util-linux ["nsenter"] pulls only the one binary.

Why the build.sh change

iproute2 installs ip (and ss/tc/bridge) to /usr/sbin via SBINDIR. The old wholesale rm -rf $STAGE/usr/sbin existed only to drop e2fsprogs's build-only sbin tools — it would now also delete ip. The replacement removes the full e2fsprogs sbin set by name. (Earlier revisions kept blkid/findfs/fsck/uuidd because util-linux shipped them; now that util-linux is subset to nsenter-only, those e2fsprogs copies must go too.)

Verification

Clean-room build (minimal package), image inspected with debugfs:

  • usr/sbin/ip, usr/bin/nsenter — PRESENT
  • every other util-linux tool (mount, dmesg, lsblk, unshare, fdisk, agetty) — gone
  • all e2fsprogs files (mke2fs, blkid, fsck, uuidd, findfs, e4crypt, …) — gone
  • iproute2 tools retained (ip, ss, tc, bridge, …)
  • no toolchain leak into the closure
  • min check --packages microvm-rootfs util-linux — all checks pass

Size

  • 163 MB — base+git baseline (rebuilt today; the older 108 MB artifact predates git package growth)
  • 169 MB — this PR (+6 MB for ip + nsenter)
  • 189 MB — without the util-linux subset (the subset saves ~20 MB)

🤖 Generated with Claude Code

Summary by CodeRabbit

  • New Features

    • Expanded the microvm root filesystem to include additional networking and namespace tooling.
    • Added a separate nsenter binary package so it can be used on its own.
  • Bug Fixes

    • Made the runtime cleanup step more selective, removing only specific unwanted binaries instead of clearing an entire directory.
    • Improved handling of missing tools during staging so builds are more tolerant of partial toolsets.

@coderabbitai

coderabbitai Bot commented Jun 26, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Warning

Review limit reached

@bryan-minimal, we couldn't start this review because you've reached your PR review rate limit.

More reviews will be available in 57 minutes and 31 seconds. Learn how PR review limits work.

Your organization has used up its prepaid credits, and credit purchases are no longer available. Enable the review add-on in the billing tab to keep reviews running — you're only billed for reviews past your plan's rate limits ($0.25/file).

⌛ How to resolve this issue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based credits.

🚦 How do rate limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please see our Fair Usage Limits Policy for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: f5ec05e6-1a00-4415-9050-c723a61e3bfe

📥 Commits

Reviewing files that changed from the base of the PR and between ae778f7 and 5aa6407.

📒 Files selected for processing (1)
  • packages/opencode/build.sh
📝 Walkthrough

Walkthrough

The microvm-rootfs build now includes iproute2 and util-linux nsenter, and the staging script prunes only specific e2fsprogs binaries from /usr/sbin.

Changes

microvm-rootfs runtime tools

Layer / File(s) Summary
Build spec runtime deps
packages/microvm-rootfs/build.ncl, packages/util-linux/build.ncl
The build spec imports iproute2 and util-linux, updates the runtime-closure description, adds iproute2 to runtime_deps, and exports usr/bin/nsenter as a separate OutputBin.
Selective staged pruning
packages/microvm-rootfs/build.sh
The staging script removes only selected e2fsprogs tools from $STAGE/usr/sbin with rm -f.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

  • gominimal/pkgs#229: Also changes packages/microvm-rootfs staging behavior around pruning e2fsprogs from the staged tree.

Suggested reviewers

  • twitchyliquid64

Poem

🐰 I hopped through the rootfs with glee,
nsenter and iproute2 now roam free.
I nibbled the prune list, neat and small,
Leaving the needed tools for all.

🚥 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 title clearly matches the main change: adding iproute2 and nsenter to the microvm-rootfs guest runtime.
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.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch add-ip-nsenter-socat-microvm-rootfs

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

@norrietaylor
norrietaylor force-pushed the add-ip-nsenter-socat-microvm-rootfs branch from e11f7fb to b551bee Compare June 26, 2026 07:43
@norrietaylor norrietaylor changed the title microvm-rootfs: add ip, nsenter and socat to the guest microvm-rootfs: add ip and nsenter to the guest Jun 26, 2026
@norrietaylor
norrietaylor added this pull request to the merge queue Jun 26, 2026
@norrietaylor
norrietaylor removed this pull request from the merge queue due to a manual request Jun 26, 2026
Add iproute2 (ip) and util-linux's nsenter to the microVM guest rootfs
runtime closure for network/namespace plumbing.

util-linux is pulled as `subsetOf util-linux ["nsenter"]` so only the
nsenter binary (which links just glibc) lands in the image, not the whole
~18 MB toolset. A granular `nsenter` output is added to the util-linux
package to make that subset possible.

iproute2 installs `ip` (and ss/tc/bridge) to /usr/sbin via SBINDIR, so the
old wholesale `rm -rf $STAGE/usr/sbin` (which only dropped e2fsprogs's
build-only sbin tools) would also delete `ip`. Replace it with a name-based
removal of the full e2fsprogs sbin set. Because util-linux is now subset to
nsenter-only, its blkid/findfs/fsck/uuidd no longer reach the image, so the
e2fsprogs copies of those names must be removed too.

Verified with a clean-room build (minimal package): image carries
usr/sbin/ip and usr/bin/nsenter; every other util-linux tool and all
e2fsprogs files are gone; no toolchain leaks into the closure. Image is
169 MB vs a 163 MB base+git baseline (+6 MB), down from 189 MB before the
subset.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@norrietaylor
norrietaylor force-pushed the add-ip-nsenter-socat-microvm-rootfs branch from b551bee to ae778f7 Compare June 26, 2026 16:40
@norrietaylor
norrietaylor enabled auto-merge June 26, 2026 17:52
…build

Adding nsenter to util-linux bumps its spec_hash, which is in 351/375
package closures, so this PR triggers a near-full rebuild that surfaces
opencode's pre-existing frozen-lockfile breakage: our shipped bun resolves
opencode's committed lockfile differently and rejects it under
--frozen-lockfile ("lockfile had changes, but lockfile is frozen"). The
install already network-fetches deps, so --frozen-lockfile was only pinning
versions; dropping it lets bun float the lockfile and unblocks the rebuild.

Bundled here (rather than a separate PR) so it re-kicks this build. Proper
fix = a vendored, bun-version-matched bun.lock (filed as a pkgs issue).

Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@norrietaylor
norrietaylor added this pull request to the merge queue Jun 26, 2026
Merged via the queue into main with commit 2319397 Jun 26, 2026
5 checks passed
@norrietaylor
norrietaylor deleted the add-ip-nsenter-socat-microvm-rootfs branch June 26, 2026 22:05
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.

3 participants