Skip to content

Commit 0958129

Browse files
authored
feat(ci): add release-vm-dev pipeline and install-vm.sh installer (#788)
1 parent f92923e commit 0958129

File tree

16 files changed

+744
-603
lines changed

16 files changed

+744
-603
lines changed

.github/workflows/release-vm-dev.yml

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,11 @@ jobs:
6565
name: Download Kernel Runtime
6666
runs-on: build-amd64
6767
timeout-minutes: 10
68+
container:
69+
image: ghcr.io/nvidia/openshell/ci:latest
70+
credentials:
71+
username: ${{ github.actor }}
72+
password: ${{ secrets.GITHUB_TOKEN }}
6873
steps:
6974
- uses: actions/checkout@v4
7075

@@ -150,6 +155,9 @@ jobs:
150155
- name: Install tools
151156
run: mise install
152157

158+
- name: Install zstd
159+
run: apt-get update && apt-get install -y --no-install-recommends zstd && rm -rf /var/lib/apt/lists/*
160+
153161
- name: Build base rootfs tarball
154162
run: |
155163
set -euo pipefail
@@ -223,6 +231,9 @@ jobs:
223231
cache-directories: .cache/sccache
224232
cache-targets: "true"
225233

234+
- name: Install zstd
235+
run: apt-get update && apt-get install -y --no-install-recommends zstd && rm -rf /var/lib/apt/lists/*
236+
226237
- name: Download kernel runtime tarball
227238
uses: actions/download-artifact@v4
228239
with:
@@ -334,6 +345,9 @@ jobs:
334345
- name: Set up Docker Buildx
335346
uses: ./.github/actions/setup-buildx
336347

348+
- name: Install zstd
349+
run: apt-get update && apt-get install -y --no-install-recommends zstd && rm -rf /var/lib/apt/lists/*
350+
337351
- name: Download kernel runtime tarball
338352
uses: actions/download-artifact@v4
339353
with:
@@ -506,10 +520,13 @@ jobs:
506520
| Linux x86_64 | `openshell-vm-x86_64-unknown-linux-gnu.tar.gz` |
507521
| macOS ARM64 | `openshell-vm-aarch64-apple-darwin.tar.gz` |
508522
509-
**macOS users:** The binary must be codesigned with the Hypervisor entitlement:
510-
```bash
511-
codesign --entitlements crates/openshell-vm/entitlements.plist --force -s - ./openshell-vm
523+
### Quick install
524+
512525
```
526+
curl -fsSL https://raw.githubusercontent.com/NVIDIA/OpenShell/main/install-vm.sh | sh
527+
```
528+
529+
Auto-detects your platform, verifies checksums, and codesigns on macOS.
513530
514531
files: |
515532
release-final/openshell-vm-aarch64-unknown-linux-gnu.tar.gz

.github/workflows/release-vm-kernel.yml

Lines changed: 41 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,11 @@ name: Release VM Kernel
55
# "vm-dev" GitHub Release and consumed by release-vm-dev.yml when building the
66
# openshell-vm binary.
77
#
8+
# The Linux kernel is compiled once on aarch64 Linux. The resulting kernel.c
9+
# (a C source file containing the kernel as a byte array) is shared with the
10+
# macOS job, which only needs to compile it into a .dylib — no krunvm, no
11+
# Fedora VM, no kernel rebuild. This cuts macOS CI from ~45 min to ~5 min.
12+
#
813
# This workflow runs on-demand (or when kernel config / pins change). It is
914
# intentionally decoupled from the per-commit VM binary build because the
1015
# kernel rarely changes and takes 15-45 minutes to compile.
@@ -14,6 +19,7 @@ on:
1419

1520
permissions:
1621
contents: write
22+
packages: read
1723

1824
# Serialize with release-vm-dev.yml — both update the vm-dev release.
1925
concurrency:
@@ -26,7 +32,7 @@ defaults:
2632

2733
jobs:
2834
# ---------------------------------------------------------------------------
29-
# Linux ARM64 — native kernel + libkrun build
35+
# Linux ARM64 — native kernel + libkrun build (also exports kernel.c)
3036
# ---------------------------------------------------------------------------
3137
build-runtime-linux-arm64:
3238
name: Build Runtime (Linux ARM64)
@@ -56,13 +62,25 @@ jobs:
5662
--build-dir target/libkrun-build \
5763
--output artifacts/vm-runtime-linux-aarch64.tar.zst
5864
59-
- name: Upload artifact
65+
- name: Upload runtime artifact
6066
uses: actions/upload-artifact@v4
6167
with:
6268
name: vm-runtime-linux-arm64
6369
path: artifacts/vm-runtime-linux-aarch64.tar.zst
6470
retention-days: 5
6571

72+
# Export kernel.c + ABI_VERSION for the macOS job. kernel.c contains
73+
# the aarch64 Linux kernel as a byte array — it is OS-agnostic and can
74+
# be compiled into a .dylib by Apple's cc without rebuilding the kernel.
75+
- name: Upload kernel.c for macOS build
76+
uses: actions/upload-artifact@v4
77+
with:
78+
name: kernel-c-arm64
79+
path: |
80+
target/libkrun-build/kernel.c
81+
target/libkrun-build/ABI_VERSION
82+
retention-days: 1
83+
6684
# ---------------------------------------------------------------------------
6785
# Linux AMD64 — native kernel + libkrun build
6886
# ---------------------------------------------------------------------------
@@ -102,34 +120,35 @@ jobs:
102120
retention-days: 5
103121

104122
# ---------------------------------------------------------------------------
105-
# macOS ARM64 — kernel built via krunvm, libkrun built natively
123+
# macOS ARM64 — uses pre-built kernel.c from Linux ARM64 job
106124
# ---------------------------------------------------------------------------
107125
build-runtime-macos-arm64:
108126
name: Build Runtime (macOS ARM64)
127+
needs: [build-runtime-linux-arm64]
109128
runs-on: macos-latest-xlarge
110-
timeout-minutes: 90
129+
timeout-minutes: 30
130+
env:
131+
RUSTC_WRAPPER: ""
111132
steps:
112133
- uses: actions/checkout@v4
113134

114135
- name: Install dependencies
115136
run: |
116137
set -euo pipefail
117-
brew install rust lld dtc xz
118-
# libkrunfw from Homebrew (used as a fallback/reference by build scripts)
119-
brew install libkrunfw
120-
# krunvm is needed to build the Linux kernel inside a Fedora VM
121-
brew tap slp/krun
122-
brew install krunvm
138+
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y
139+
echo "$HOME/.cargo/bin" >> "$GITHUB_PATH"
140+
brew install lld dtc xz
123141
124-
- name: Build custom libkrunfw (kernel)
125-
run: crates/openshell-vm/runtime/build-custom-libkrunfw.sh
142+
- name: Download pre-built kernel.c
143+
uses: actions/download-artifact@v4
144+
with:
145+
name: kernel-c-arm64
146+
path: target/kernel-artifact
126147

127-
- name: Build portable libkrun
128-
run: tasks/scripts/vm/build-libkrun-macos.sh
148+
- name: Build libkrunfw + libkrun from pre-built kernel
149+
run: tasks/scripts/vm/build-libkrun-macos.sh --kernel-dir target/kernel-artifact
129150

130151
- name: Package runtime tarball
131-
env:
132-
CUSTOM_PROVENANCE_DIR: target/custom-runtime
133152
run: |
134153
tasks/scripts/vm/package-vm-runtime.sh \
135154
--platform darwin-aarch64 \
@@ -235,10 +254,13 @@ jobs:
235254
| Linux x86_64 | `openshell-vm-x86_64-unknown-linux-gnu.tar.gz` |
236255
| macOS ARM64 | `openshell-vm-aarch64-apple-darwin.tar.gz` |
237256
238-
**macOS users:** The binary must be codesigned with the Hypervisor entitlement:
239-
```bash
240-
codesign --entitlements crates/openshell-vm/entitlements.plist --force -s - ./openshell-vm
257+
### Quick install
258+
241259
```
260+
curl -fsSL https://raw.githubusercontent.com/NVIDIA/OpenShell/main/install-vm.sh | sh
261+
```
262+
263+
Auto-detects your platform, verifies checksums, and codesigns on macOS.
242264
243265
files: |
244266
release/vm-runtime-linux-aarch64.tar.zst

architecture/custom-vm-runtime.md

Lines changed: 24 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -116,23 +116,29 @@ and makes it straightforward to correlate VM behavior with a specific runtime ar
116116
```mermaid
117117
graph LR
118118
subgraph Source["crates/openshell-vm/runtime/"]
119-
BUILD["build-custom-libkrunfw.sh\nClones libkrunfw, applies config, builds"]
120119
KCONF["kernel/openshell.kconfig\nKernel config fragment"]
121120
README["README.md\nOperator documentation"]
122121
end
123122
124-
subgraph Output["target/custom-runtime/"]
125-
LIB["libkrunfw.dylib\nCustom library"]
126-
META["provenance.json\nBuild metadata"]
127-
FRAG["openshell.kconfig\nConfig fragment used"]
128-
FULL["kernel.config\nFull kernel .config"]
123+
subgraph Linux["Linux CI (build-libkrun.sh)"]
124+
BUILD_L["Build kernel + libkrunfw.so + libkrun.so"]
125+
KERNELC["kernel.c\nKernel as C byte array"]
129126
end
130127
131-
KCONF --> BUILD
132-
BUILD --> LIB
133-
BUILD --> META
134-
BUILD --> FRAG
135-
BUILD --> FULL
128+
subgraph macOS["macOS CI (build-libkrun-macos.sh)"]
129+
BUILD_M["Compile kernel.c -> libkrunfw.dylib\nBuild libkrun.dylib"]
130+
end
131+
132+
subgraph Output["target/libkrun-build/"]
133+
LIB_SO["libkrunfw.so + libkrun.so\n(Linux)"]
134+
LIB_DY["libkrunfw.dylib + libkrun.dylib\n(macOS)"]
135+
end
136+
137+
KCONF --> BUILD_L
138+
BUILD_L --> LIB_SO
139+
BUILD_L --> KERNELC
140+
KERNELC --> BUILD_M
141+
BUILD_M --> LIB_DY
136142
```
137143

138144
## Kernel Config Fragment
@@ -222,16 +228,18 @@ supported platforms. Runs on-demand or when the kernel config / pinned versions
222228

223229
| Platform | Runner | Build Method |
224230
|----------|--------|-------------|
225-
| Linux ARM64 | `build-arm64` (self-hosted) | Native `build-libkrun.sh` |
231+
| Linux ARM64 | `build-arm64` (self-hosted) | Native `build-libkrun.sh` (also exports kernel.c) |
226232
| Linux x86_64 | `build-amd64` (self-hosted) | Native `build-libkrun.sh` |
227-
| macOS ARM64 | `macos-latest-xlarge` (GitHub-hosted) | `build-custom-libkrunfw.sh` (krunvm) + `build-libkrun-macos.sh` |
233+
| macOS ARM64 | `macos-latest-xlarge` (GitHub-hosted) | `build-libkrun-macos.sh --kernel-dir` (uses pre-built kernel.c from ARM64) |
228234

229235
Artifacts: `vm-runtime-{platform}.tar.zst` containing libkrun, libkrunfw, gvproxy, and
230236
provenance metadata.
231237

232-
The macOS kernel build requires a real macOS ARM64 runner because it uses `krunvm` to
233-
compile the Linux kernel inside a Fedora VM (Hypervisor.framework). The kernel inside
234-
libkrunfw is always Linux regardless of host platform.
238+
The aarch64 Linux kernel is compiled once on the Linux ARM64 runner. The resulting
239+
`kernel.c` (a C source file containing the kernel as a byte array) is passed to the
240+
macOS job, which compiles it into `libkrunfw.dylib` with Apple's `cc`. This eliminates
241+
the need for krunvm/Fedora VM and cuts macOS CI from ~45 min to ~5 min. The kernel
242+
inside libkrunfw is always Linux regardless of host platform.
235243

236244
### VM Binary (`release-vm-dev.yml`)
237245

crates/openshell-vm/pins.env

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
# Pinned dependency versions for openshell-vm builds.
55
#
66
# This file is sourced by build-rootfs.sh and
7-
# build-custom-libkrunfw.sh. It centralises version pins and content-addressed
7+
# build-libkrun.sh. It centralises version pins and content-addressed
88
# digests so that builds are reproducible and auditable.
99
#
1010
# Environment variables override these defaults — CI and local dev workflows

crates/openshell-vm/runtime/README.md

Lines changed: 36 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
> Status: Experimental and work in progress (WIP). VM support is under active development and may change.
44
5-
This directory contains the build infrastructure for a custom `libkrunfw` runtime
5+
This directory contains the kernel config fragment for a custom `libkrunfw` runtime
66
that enables bridge CNI and netfilter support in the OpenShell gateway VM.
77

88
## Why
@@ -21,51 +21,61 @@ that enables these networking and sandboxing features.
2121

2222
```
2323
runtime/
24-
build-custom-libkrunfw.sh # Build script for custom libkrunfw
2524
kernel/
2625
openshell.kconfig # Kernel config fragment (networking + sandboxing)
2726
```
2827

29-
## Building
28+
## Build Pipeline
3029

31-
### Prerequisites
30+
The kernel is compiled on Linux CI runners. macOS reuses the pre-built `kernel.c`
31+
artifact from the Linux ARM64 build — no krunvm or Fedora VM needed.
3232

33-
- Rust toolchain
34-
- make, git, curl
35-
- On macOS: Xcode command line tools and cross-compilation tools for aarch64
33+
```
34+
Linux ARM64: builds aarch64 kernel -> .so + exports kernel.c (parallel)
35+
Linux AMD64: builds x86_64 kernel -> .so (parallel)
36+
macOS ARM64: reuses aarch64 kernel.c -> .dylib (depends on ARM64)
37+
```
38+
39+
### Build Scripts
40+
41+
| Script | Platform | What it does |
42+
|--------|----------|-------------|
43+
| `tasks/scripts/vm/build-libkrun.sh` | Linux | Builds libkrunfw + libkrun from source, exports kernel.c |
44+
| `tasks/scripts/vm/build-libkrun-macos.sh` | macOS | Compiles pre-built kernel.c into .dylib, builds libkrun |
45+
| `tasks/scripts/vm/package-vm-runtime.sh` | Any | Packages runtime tarball (libs + gvproxy + provenance) |
3646

37-
### Quick Build
47+
### Quick Build (Linux)
3848

3949
```bash
40-
# Build custom libkrunfw (clones libkrunfw repo, applies config, builds)
41-
./crates/openshell-vm/runtime/build-custom-libkrunfw.sh
50+
# Build both libkrunfw and libkrun from source
51+
tasks/scripts/vm/build-libkrun.sh
4252

4353
# Or build the full runtime from source via mise:
4454
FROM_SOURCE=1 mise run vm:setup
4555
```
4656

47-
### Output
57+
### Quick Build (macOS)
4858

49-
Build artifacts are placed in `target/custom-runtime/`:
59+
On macOS, you need a pre-built `kernel.c` from a Linux ARM64 build:
5060

51-
```
52-
target/custom-runtime/
53-
libkrunfw.dylib # The custom library
54-
libkrunfw.<version>.dylib # Version-suffixed copy
55-
provenance.json # Build metadata (commit, hash, timestamp)
56-
openshell.kconfig # The config fragment used
57-
kernel.config # Full kernel .config (for debugging)
61+
```bash
62+
# Download pre-built runtime (recommended, ~30s):
63+
mise run vm:setup
64+
65+
# Or if you have kernel.c from a Linux build:
66+
tasks/scripts/vm/build-libkrun-macos.sh --kernel-dir target/libkrun-build
5867
```
5968

60-
### Using the Custom Runtime
69+
### Output
6170

62-
```bash
63-
# Point the bundle script at the custom build and rebuild:
64-
export OPENSHELL_VM_RUNTIME_SOURCE_DIR=target/custom-runtime
65-
mise run vm:build
71+
Build artifacts are placed in `target/libkrun-build/`:
6672

67-
# Then boot the VM as usual:
68-
mise run vm
73+
```
74+
target/libkrun-build/
75+
libkrun.so / libkrun.dylib # The VMM library
76+
libkrunfw.so* / libkrunfw.dylib # Kernel firmware library
77+
kernel.c # Linux kernel as C byte array (Linux only)
78+
ABI_VERSION # ABI version number (Linux only)
6979
```
7080

7181
## Networking

0 commit comments

Comments
 (0)