Skip to content

virtio-linux: package linux microvm image#154

Open
twitchyliquid64 wants to merge 1 commit intomainfrom
tom/linux
Open

virtio-linux: package linux microvm image#154
twitchyliquid64 wants to merge 1 commit intomainfrom
tom/linux

Conversation

@twitchyliquid64
Copy link
Copy Markdown
Contributor

@twitchyliquid64 twitchyliquid64 commented May 6, 2026

Summary by CodeRabbit

  • New Features
    • Added build configuration and scripts to support building a virtio-enabled Linux kernel.
    • Supports x86_64 and aarch64 builds and includes guest/KVM handling.
    • Produces build artifacts (kernel image, config, System.map) in a structured output.
    • Attaches upstream version and source provenance metadata for traceability.

@twitchyliquid64 twitchyliquid64 requested a review from msample May 6, 2026 20:48
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 6, 2026

📝 Walkthrough

Walkthrough

Adds a new virtio-Linux kernel build: a Nickel BuildSpec (packages/virtio-linux/build.ncl) and a Bash build script (packages/virtio-linux/build.sh) that fetch kernel sources, configure many virtio/container/kernel options, build the kernel, and emit artifacts.

Changes

Virtio-Linux Build System

Layer / File(s) Summary
Data Shape / Metadata
packages/virtio-linux/build.ncl
Introduces a BuildSpec: sets version, declares build dependencies (local build.sh, Linux tarball Source from GCS, component modules), lists outputs (vmlinuz, config, system_map), and attaches upstream_version and source_provenance metadata.
Build Implementation
packages/virtio-linux/build.sh
Shell script selects arch-specific targets, initializes defconfig, conditionally applies kvm_guest.config, and enables numerous virtio, container, virtualization, and security kernel options via scripts/config.
Dependency Resolution / Build Steps
packages/virtio-linux/build.sh
Runs make olddefconfig to resolve dependencies, then make -j to build the kernel artifact.
Artifacts / Outputs
packages/virtio-linux/build.sh, packages/virtio-linux/build.ncl
Copies kernel image to vmlinuz, exports config and System.map (script) and declares outputs in the BuildSpec (system_map naming in manifest).

Sequence Diagram

sequenceDiagram
    actor BuildSystem
    participant Script
    participant KernelSource
    participant Artifacts

    BuildSystem->>KernelSource: fetch Linux tarball (GCS)
    KernelSource-->>Script: provide kernel source tree
    BuildSystem->>Script: invoke build.sh (with version arg)
    Script->>Script: select arch, apply defconfig and fragments
    Script->>Script: enable virtio/container/security options
    Script->>Script: run olddefconfig, make -j (build)
    Script->>Artifacts: copy vmlinuz, config, System.map
    Artifacts-->>BuildSystem: outputs available
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Poem

🐰 In tree and tarball, kernels softly stir,
Scripts nibble configs, options purr and whirr,
Virtio wings unfold, small modules take flight,
Artifacts hop out, vmlinuz gleaming bright.

🚥 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 'virtio-linux: package linux microvm image' clearly describes the main change: adding a new virtio-linux package with build configuration and scripts to create a Linux microvm image.
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.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch tom/linux

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

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

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 `@packages/virtio-linux/build.ncl`:
- Around line 53-57: The source_provenance block currently points to the GitHub
mirror (source_provenance with category and owner/repo values); replace it with
the canonical Linux upstream provenance pattern for the kernel (i.e., point
source_provenance to the official kernel.org git repository instead of
"torvalds/linux" on GitHub). Update the source_provenance fields used in the
file so they reference the canonical upstream host and repository identifiers
(the kernel.org canonical git URL/pattern) and remove the GitHub mirror values
so the package metadata correctly identifies the upstream source.

In `@packages/virtio-linux/build.sh`:
- Around line 11-13: The kernel build invokes "make defconfig" and "make
kvm_guest.config" (and the later make calls around the other block) without
specifying ARCH, so on non-x86 runners the wrong architecture may be built;
update all kernel make invocations in build.sh (the places running "make
defconfig", "make kvm_guest.config" and the subsequent make lines around the
113-119 block) to pass ARCH=x86_64 (e.g., "make ARCH=x86_64 defconfig") so the
build and the expected artifact path (arch/x86/boot/bzImage) are produced
reliably.
🪄 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 Plus

Run ID: 0ce47178-b6e3-464d-af09-a48991545aed

📥 Commits

Reviewing files that changed from the base of the PR and between fbad6c8 and b13c75b.

📒 Files selected for processing (2)
  • packages/virtio-linux/build.ncl
  • packages/virtio-linux/build.sh

Comment on lines +53 to +57
source_provenance = {
category = 'GithubRepo,
owner = "torvalds",
repo = "linux",
},
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

Point source_provenance at canonical Linux upstream.

torvalds/linux on GitHub is a mirror, so this metadata does not describe the canonical upstream source for Linux. Please switch source_provenance to the repository’s canonical Linux provenance pattern instead of the GitHub mirror.

As per coding guidelines "Only use source_provenance to point to canonical upstream sources, not mirrors or unofficial copies".

🤖 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 `@packages/virtio-linux/build.ncl` around lines 53 - 57, The source_provenance
block currently points to the GitHub mirror (source_provenance with category and
owner/repo values); replace it with the canonical Linux upstream provenance
pattern for the kernel (i.e., point source_provenance to the official kernel.org
git repository instead of "torvalds/linux" on GitHub). Update the
source_provenance fields used in the file so they reference the canonical
upstream host and repository identifiers (the kernel.org canonical git
URL/pattern) and remove the GitHub mirror values so the package metadata
correctly identifies the upstream source.

Comment on lines +11 to +13
make defconfig
make kvm_guest.config

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major | ⚡ Quick win

Pin ARCH=x86_64 for the kernel build.

The script claims an x86_64 target and later copies arch/x86/boot/bzImage, but every make invocation still uses the builder’s default ARCH. On a non-x86 runner this can select the wrong defconfig or fail before the copy step.

Suggested fix
 JOBS=$(nproc)
+export ARCH=x86_64
+BZIMAGE_PATH=arch/x86/boot/bzImage
 
 # Start from a sensible x86_64 defconfig, then layer the upstream KVM-guest
 # fragment which already turns on the common virtio + paravirt bits used
 # by qemu / cloud-hypervisor / firecracker style microVMs.
 make defconfig
 make kvm_guest.config
@@
 make -j"$JOBS" bzImage
@@
 OUT=$OUTPUT_DIR/usr/share/virtio-linux
 mkdir -p "$OUT"
-cp arch/x86/boot/bzImage "$OUT/bzImage"
+cp "$BZIMAGE_PATH" "$OUT/bzImage"
 cp .config "$OUT/config"
 cp System.map "$OUT/System.map"

Also applies to: 113-119

🤖 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 `@packages/virtio-linux/build.sh` around lines 11 - 13, The kernel build
invokes "make defconfig" and "make kvm_guest.config" (and the later make calls
around the other block) without specifying ARCH, so on non-x86 runners the wrong
architecture may be built; update all kernel make invocations in build.sh (the
places running "make defconfig", "make kvm_guest.config" and the subsequent make
lines around the 113-119 block) to pass ARCH=x86_64 (e.g., "make ARCH=x86_64
defconfig") so the build and the expected artifact path (arch/x86/boot/bzImage)
are produced reliably.

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

♻️ Duplicate comments (1)
packages/virtio-linux/build.ncl (1)

53-57: ⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

Use canonical Linux upstream in source_provenance (still unresolved).

At Line 53-57, source_provenance still points to torvalds/linux on GitHub, which is a mirror rather than the canonical upstream. Please switch this metadata to the project’s canonical Linux upstream provenance form.

As per coding guidelines "Only use source_provenance to point to canonical upstream sources, not mirrors or unofficial copies".

🤖 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 `@packages/virtio-linux/build.ncl` around lines 53 - 57, The source_provenance
block currently points to a GitHub mirror (source_provenance with
category/owner/repo) and must be changed to the canonical Linux upstream
provenance; update the source_provenance entry (the category and owner/repo
values) to reference the official kernel upstream (the canonical kernel.org/git
repository/provenance form) instead of "torvalds/linux" so the metadata points
to the authoritative source.
🤖 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 `@packages/virtio-linux/build.ncl`:
- Around line 53-57: The source_provenance block currently points to a GitHub
mirror (source_provenance with category/owner/repo) and must be changed to the
canonical Linux upstream provenance; update the source_provenance entry (the
category and owner/repo values) to reference the official kernel upstream (the
canonical kernel.org/git repository/provenance form) instead of "torvalds/linux"
so the metadata points to the authoritative source.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: d80158ac-85f7-41d7-afd8-0af69bf12c44

📥 Commits

Reviewing files that changed from the base of the PR and between b13c75b and b642fd2.

📒 Files selected for processing (2)
  • packages/virtio-linux/build.ncl
  • packages/virtio-linux/build.sh

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.

2 participants