Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 890a544

Browse files
committed
ci: add PVM kernel support to CI and one-click release
- Add CI workflows for building PVM guest vmlinux and host kernel packages - Include optional`vmlinux-pvm`in one-click release bundle - Add`CUBE_PVM_ENABLE`option to install PVM kernel over ordinary guest kernel - Refactor binary build/copy logic in release bundle scrip Signed-off-by: jinlong <[email protected]>
1 parent ec37401 commit 890a544

10 files changed

Lines changed: 417 additions & 55 deletions

File tree

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
name: Build PVM Guest vmlinux
2+
3+
on:
4+
push:
5+
paths:
6+
- 'deploy/pvm/build-pvm-guest-vmlinux.sh'
7+
- 'deploy/pvm/common.sh'
8+
- 'deploy/pvm/configs/pvm_guest'
9+
- '.github/workflows/build-pvm-guest-vmlinux.yml'
10+
workflow_dispatch:
11+
12+
env:
13+
PVM_KERNEL_TAG: 6.6.69-1.cubesandbox
14+
PVM_VMLINUX_CACHE_PATH: kernel-cache/vmlinux-pvm
15+
16+
jobs:
17+
build:
18+
runs-on: ubuntu-latest
19+
permissions:
20+
contents: read
21+
22+
steps:
23+
- name: Checkout
24+
uses: actions/checkout@v4
25+
26+
- name: Compute PVM vmlinux cache metadata
27+
id: pvm_vmlinux_metadata
28+
run: |
29+
source_hash="$(
30+
sha256sum \
31+
deploy/pvm/build-pvm-guest-vmlinux.sh \
32+
deploy/pvm/common.sh \
33+
deploy/pvm/configs/pvm_guest \
34+
| sha256sum \
35+
| awk '{print $1}'
36+
)"
37+
echo "source_hash=${source_hash}" >> "${GITHUB_OUTPUT}"
38+
echo "cache_key=vmlinux-pvm-${PVM_KERNEL_TAG}-${source_hash}-ubuntu-latest" >> "${GITHUB_OUTPUT}"
39+
echo "artifact_name=vmlinux-pvm-${PVM_KERNEL_TAG}-${source_hash}" >> "${GITHUB_OUTPUT}"
40+
41+
- name: Restore cached PVM vmlinux
42+
id: restore_pvm_vmlinux
43+
uses: actions/cache/restore@v4
44+
with:
45+
path: ${{ env.PVM_VMLINUX_CACHE_PATH }}
46+
key: ${{ steps.pvm_vmlinux_metadata.outputs.cache_key }}
47+
48+
- name: Build PVM guest vmlinux
49+
if: steps.restore_pvm_vmlinux.outputs.cache-hit != 'true'
50+
run: |
51+
WORK_DIR="${GITHUB_WORKSPACE}/pvm-guest-build" \
52+
OUTPUT_DIR="${GITHUB_WORKSPACE}/pvm-guest-build/output" \
53+
bash deploy/pvm/build-pvm-guest-vmlinux.sh
54+
install -D -m 0644 \
55+
"${GITHUB_WORKSPACE}/pvm-guest-build/output/vmlinux" \
56+
"${PVM_VMLINUX_CACHE_PATH}"
57+
58+
- name: Verify PVM vmlinux
59+
run: |
60+
test -f "${PVM_VMLINUX_CACHE_PATH}"
61+
file "${PVM_VMLINUX_CACHE_PATH}"
62+
63+
- name: Save PVM vmlinux cache
64+
if: steps.restore_pvm_vmlinux.outputs.cache-hit != 'true'
65+
uses: actions/cache/save@v4
66+
with:
67+
path: ${{ env.PVM_VMLINUX_CACHE_PATH }}
68+
key: ${{ steps.pvm_vmlinux_metadata.outputs.cache_key }}
69+
70+
- name: Stage PVM vmlinux artifact payload
71+
run: |
72+
rm -rf pvm-vmlinux-artifact
73+
install -D -m 0644 "${PVM_VMLINUX_CACHE_PATH}" pvm-vmlinux-artifact/vmlinux-pvm
74+
75+
- name: Upload PVM vmlinux artifact
76+
uses: actions/upload-artifact@v4
77+
with:
78+
name: ${{ steps.pvm_vmlinux_metadata.outputs.artifact_name }}
79+
path: pvm-vmlinux-artifact/vmlinux-pvm
80+
if-no-files-found: error
81+
retention-days: 14

.github/workflows/release-one-click.yml

Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,79 @@ env:
1919
VMLINUX_CACHE_PATH: kernel-cache/vmlinux
2020
VMLINUX_RELEASE_PATH: deploy/one-click/assets/kernel-artifacts/vmlinux
2121
KERNEL_TAG: 6.6.119-49.6
22+
PVM_KERNEL_TAG: 6.6.69-1.cubesandbox
23+
PVM_VMLINUX_CACHE_PATH: kernel-cache/vmlinux-pvm
24+
PVM_VMLINUX_RELEASE_PATH: deploy/one-click/assets/kernel-artifacts/vmlinux-pvm
2225

2326
jobs:
27+
build_pvm_guest_vmlinux:
28+
name: Build PVM guest vmlinux for release
29+
runs-on: ubuntu-latest
30+
31+
steps:
32+
- name: Checkout
33+
uses: actions/checkout@v4
34+
35+
- name: Compute PVM vmlinux cache metadata
36+
id: pvm_vmlinux_metadata
37+
run: |
38+
source_hash="$(
39+
sha256sum \
40+
deploy/pvm/build-pvm-guest-vmlinux.sh \
41+
deploy/pvm/common.sh \
42+
deploy/pvm/configs/pvm_guest \
43+
| sha256sum \
44+
| awk '{print $1}'
45+
)"
46+
echo "source_hash=${source_hash}" >> "${GITHUB_OUTPUT}"
47+
echo "cache_key=vmlinux-pvm-${PVM_KERNEL_TAG}-${source_hash}-ubuntu-latest" >> "${GITHUB_OUTPUT}"
48+
echo "artifact_name=vmlinux-pvm-${PVM_KERNEL_TAG}-${source_hash}" >> "${GITHUB_OUTPUT}"
49+
50+
- name: Restore cached PVM vmlinux
51+
id: restore_pvm_vmlinux
52+
uses: actions/cache/restore@v4
53+
with:
54+
path: ${{ env.PVM_VMLINUX_CACHE_PATH }}
55+
key: ${{ steps.pvm_vmlinux_metadata.outputs.cache_key }}
56+
57+
- name: Build PVM guest vmlinux
58+
if: steps.restore_pvm_vmlinux.outputs.cache-hit != 'true'
59+
run: |
60+
WORK_DIR="${GITHUB_WORKSPACE}/pvm-guest-build" \
61+
OUTPUT_DIR="${GITHUB_WORKSPACE}/pvm-guest-build/output" \
62+
bash deploy/pvm/build-pvm-guest-vmlinux.sh
63+
install -D -m 0644 \
64+
"${GITHUB_WORKSPACE}/pvm-guest-build/output/vmlinux" \
65+
"${PVM_VMLINUX_CACHE_PATH}"
66+
67+
- name: Verify PVM vmlinux
68+
run: |
69+
test -f "${PVM_VMLINUX_CACHE_PATH}"
70+
file "${PVM_VMLINUX_CACHE_PATH}"
71+
72+
- name: Save PVM vmlinux cache
73+
if: steps.restore_pvm_vmlinux.outputs.cache-hit != 'true'
74+
uses: actions/cache/save@v4
75+
with:
76+
path: ${{ env.PVM_VMLINUX_CACHE_PATH }}
77+
key: ${{ steps.pvm_vmlinux_metadata.outputs.cache_key }}
78+
79+
- name: Stage PVM vmlinux artifact payload
80+
run: |
81+
rm -rf pvm-vmlinux-artifact
82+
install -D -m 0644 "${PVM_VMLINUX_CACHE_PATH}" pvm-vmlinux-artifact/vmlinux-pvm
83+
84+
- name: Upload PVM vmlinux artifact
85+
uses: actions/upload-artifact@v4
86+
with:
87+
name: ${{ steps.pvm_vmlinux_metadata.outputs.artifact_name }}
88+
path: pvm-vmlinux-artifact/vmlinux-pvm
89+
if-no-files-found: error
90+
retention-days: 14
91+
2492
release:
2593
runs-on: ubuntu-latest
94+
needs: build_pvm_guest_vmlinux
2695

2796
steps:
2897
- name: Checkout
@@ -134,6 +203,35 @@ jobs:
134203
test -f "${VMLINUX_RELEASE_PATH}"
135204
file "${VMLINUX_RELEASE_PATH}"
136205
206+
- name: Compute PVM vmlinux cache metadata
207+
id: pvm_vmlinux_metadata
208+
run: |
209+
source_hash="$(
210+
sha256sum \
211+
deploy/pvm/build-pvm-guest-vmlinux.sh \
212+
deploy/pvm/common.sh \
213+
deploy/pvm/configs/pvm_guest \
214+
| sha256sum \
215+
| awk '{print $1}'
216+
)"
217+
echo "source_hash=${source_hash}" >> "${GITHUB_OUTPUT}"
218+
echo "cache_key=vmlinux-pvm-${PVM_KERNEL_TAG}-${source_hash}-ubuntu-latest" >> "${GITHUB_OUTPUT}"
219+
echo "artifact_name=vmlinux-pvm-${PVM_KERNEL_TAG}-${source_hash}" >> "${GITHUB_OUTPUT}"
220+
221+
- name: Download PVM vmlinux artifact
222+
uses: actions/download-artifact@v4
223+
with:
224+
name: ${{ steps.pvm_vmlinux_metadata.outputs.artifact_name }}
225+
path: downloaded-pvm-vmlinux
226+
227+
- name: Stage PVM vmlinux
228+
run: |
229+
install -D -m 0644 \
230+
downloaded-pvm-vmlinux/vmlinux-pvm \
231+
"${PVM_VMLINUX_RELEASE_PATH}"
232+
test -f "${PVM_VMLINUX_RELEASE_PATH}"
233+
file "${PVM_VMLINUX_RELEASE_PATH}"
234+
137235
- name: Log in to GitHub Container Registry
138236
uses: docker/login-action@v3
139237
with:
Lines changed: 107 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,107 @@
1+
name: Release PVM Host Kernel Packages
2+
3+
on:
4+
push:
5+
tags:
6+
- '*'
7+
workflow_dispatch:
8+
9+
concurrency:
10+
group: release-pvm-host-kernel-${{ github.ref }}
11+
cancel-in-progress: false
12+
13+
permissions:
14+
contents: write
15+
16+
jobs:
17+
build:
18+
name: Build PVM host kernel (${{ matrix.package_type }})
19+
runs-on: ubuntu-latest
20+
strategy:
21+
fail-fast: false
22+
matrix:
23+
include:
24+
- package_type: deb
25+
build_mode: native
26+
- package_type: rpm
27+
build_mode: container
28+
container_image: fedora:latest
29+
30+
steps:
31+
- name: Checkout
32+
uses: actions/checkout@v4
33+
34+
- name: Build DEB package
35+
if: matrix.build_mode == 'native'
36+
run: |
37+
WORK_DIR="${GITHUB_WORKSPACE}/pvm-host-build" \
38+
OUTPUT_DIR="${GITHUB_WORKSPACE}/pvm-host-build/output" \
39+
bash deploy/pvm/build-pvm-host-kernel-pkg.sh
40+
41+
- name: Build RPM package
42+
if: matrix.build_mode == 'container'
43+
run: |
44+
docker run --rm \
45+
-v "${GITHUB_WORKSPACE}:/workspace" \
46+
-w /workspace \
47+
"${{ matrix.container_image }}" \
48+
bash -lc 'WORK_DIR=/workspace/pvm-host-build OUTPUT_DIR=/workspace/pvm-host-build/output bash deploy/pvm/build-pvm-host-kernel-pkg.sh'
49+
50+
- name: Verify package artifacts
51+
run: |
52+
shopt -s nullglob
53+
packages=(pvm-host-build/output/*.${{ matrix.package_type }})
54+
if [[ "${#packages[@]}" -eq 0 ]]; then
55+
echo "No ${{ matrix.package_type }} packages were produced" >&2
56+
exit 1
57+
fi
58+
ls -lh "${packages[@]}"
59+
60+
- name: Upload package artifact
61+
uses: actions/upload-artifact@v4
62+
with:
63+
name: pvm-host-kernel-${{ matrix.package_type }}-${{ github.ref_name }}
64+
path: pvm-host-build/output/*.${{ matrix.package_type }}
65+
if-no-files-found: error
66+
retention-days: 14
67+
68+
publish:
69+
name: Upload PVM host packages to GitHub Release
70+
needs: build
71+
runs-on: ubuntu-latest
72+
73+
steps:
74+
- name: Download package artifacts
75+
uses: actions/download-artifact@v4
76+
with:
77+
path: pvm-host-release-assets
78+
pattern: pvm-host-kernel-*-${{ github.ref_name }}
79+
merge-multiple: true
80+
81+
- name: Verify release assets
82+
run: |
83+
shopt -s nullglob
84+
assets=(pvm-host-release-assets/*.{deb,rpm})
85+
if [[ "${#assets[@]}" -eq 0 ]]; then
86+
echo "No PVM host kernel packages were downloaded" >&2
87+
exit 1
88+
fi
89+
ls -lh "${assets[@]}"
90+
91+
- name: Ensure GitHub Release exists
92+
env:
93+
GH_TOKEN: ${{ github.token }}
94+
run: |
95+
if ! gh release view "${GITHUB_REF_NAME}" >/dev/null 2>&1; then
96+
gh release create "${GITHUB_REF_NAME}" \
97+
--title "${GITHUB_REF_NAME}" \
98+
--notes "Automated PVM host kernel packages."
99+
fi
100+
101+
- name: Upload PVM host packages to Release
102+
env:
103+
GH_TOKEN: ${{ github.token }}
104+
run: |
105+
shopt -s nullglob
106+
assets=(pvm-host-release-assets/*.{deb,rpm})
107+
gh release upload "${GITHUB_REF_NAME}" "${assets[@]}" --clobber

deploy/one-click/README.md

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,16 +22,20 @@ This directory is used to build and deliver the single-machine one-click release
2222

2323
## Build Inputs
2424

25-
The only fixed file that needs to be prepared is the guest kernel `vmlinux`:
25+
The required fixed kernel artifact is the ordinary guest kernel `vmlinux`. A PVM guest kernel can also be packaged as `vmlinux-pvm`:
2626

2727
- `vmlinux`
28+
- `vmlinux-pvm` (optional)
2829

29-
By default it is placed under `assets/kernel-artifacts/`, but can be overridden via an environment variable:
30+
By default they are placed under `assets/kernel-artifacts/`, but can be overridden via environment variables:
3031

3132
```bash
3233
export ONE_CLICK_CUBE_KERNEL_VMLINUX=/abs/path/to/vmlinux
34+
export ONE_CLICK_CUBE_KERNEL_PVM_VMLINUX=/abs/path/to/vmlinux-pvm
3335
```
3436

37+
The installed runtime still uses `cube-kernel-scf/vmlinux`. By default that file is the ordinary guest kernel. If the target machine sets `CUBE_PVM_ENABLE=1` during installation, the installer copies the packaged `vmlinux-pvm` over `cube-kernel-scf/vmlinux`.
38+
3539
The guest image no longer depends on a local zip file. Instead, it is generated locally from `deploy/guest-image/Dockerfile` during the one-click release package build. Common override parameters:
3640

3741
```bash
@@ -313,7 +317,7 @@ Conditional commands:
313317

314318
## Known Limitations
315319

316-
- If `vmlinux` is missing from `assets/kernel-artifacts/`, `build-vm-assets.sh` and `build-release-bundle.sh` will fail immediately. The `cube-kernel-scf.zip` in the release package is generated automatically during the packaging phase.
320+
- If `vmlinux` is missing from `assets/kernel-artifacts/`, `build-vm-assets.sh` and `build-release-bundle.sh` will fail immediately. `vmlinux-pvm` is optional at build time, but installation with `CUBE_PVM_ENABLE=1` requires it to be present in the package. The `cube-kernel-scf.zip` in the release package is generated automatically during the packaging phase.
317321
- If the `deploy/guest-image/Dockerfile` build fails, or the build machine's `mkfs.ext4` does not support the `-d` flag, guest image generation will fail immediately.
318322
- `cube-snapshot/spec.json` is not a mandatory artifact in the current first release of one-click. If absent, the related plugin degrades to a warning rather than blocking the basic startup.
319323
- If the target machine has neither `systemd-resolved` / `resolvectl` nor a restartable `NetworkManager`, one-click will currently report an error, as a third host DNS solution for such environments has not yet been integrated.

deploy/one-click/README_zh.md

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,16 +22,20 @@
2222

2323
## 构建输入
2424

25-
需要准备的固定文件只有 guest kernel `vmlinux`
25+
必须准备的固定 kernel 制品是普通 guest kernel `vmlinux`,也可以额外打包 PVM guest kernel `vmlinux-pvm`
2626

2727
- `vmlinux`
28+
- `vmlinux-pvm`(可选)
2829

2930
默认放在 `assets/kernel-artifacts/`,也可以通过环境变量覆盖:
3031

3132
```bash
3233
export ONE_CLICK_CUBE_KERNEL_VMLINUX=/abs/path/to/vmlinux
34+
export ONE_CLICK_CUBE_KERNEL_PVM_VMLINUX=/abs/path/to/vmlinux-pvm
3335
```
3436

37+
运行时仍然使用 `cube-kernel-scf/vmlinux`。默认情况下该文件是普通 guest kernel;如果目标机安装时设置 `CUBE_PVM_ENABLE=1`,安装脚本会把包内的 `vmlinux-pvm` 覆盖安装为 `cube-kernel-scf/vmlinux`
38+
3539
guest image 不再依赖本地 zip,而是在构建 one-click 发布包时基于 `deploy/guest-image/Dockerfile` 本地生成。常用覆盖参数如下:
3640

3741
```bash
@@ -313,7 +317,7 @@ export E2B_API_KEY=dummy
313317

314318
## 已知限制
315319

316-
- 如果 `assets/kernel-artifacts/` 下缺少 `vmlinux``build-vm-assets.sh``build-release-bundle.sh` 会立即失败;发布包里的 `cube-kernel-scf.zip` 会在打包阶段自动生成。
320+
- 如果 `assets/kernel-artifacts/` 下缺少 `vmlinux``build-vm-assets.sh``build-release-bundle.sh` 会立即失败;`vmlinux-pvm` 在构建时是可选制品,但安装时若设置 `CUBE_PVM_ENABLE=1`,发布包内必须包含它;发布包里的 `cube-kernel-scf.zip` 会在打包阶段自动生成。
317321
- 如果 `deploy/guest-image/Dockerfile` 构建失败,或构建机的 `mkfs.ext4` 不支持 `-d`,guest image 生成会立即失败。
318322
- `cube-snapshot/spec.json` 在当前 one-click 首版中不是强制产物;缺失时相关插件会退化为告警,而不是阻塞基础启动。
319323
- 如果目标机既没有 `systemd-resolved` / `resolvectl`,也没有可重启的 `NetworkManager`,当前 one-click 仍会报错,因为这类环境下暂未接入第三套宿主机 DNS 方案。
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
请把固定 kernel 制品放到本目录,默认文件名如下:
22

33
- `vmlinux`
4+
- `vmlinux-pvm`(可选,PVM guest kernel)
45

56
guest image 会在构建 one-click 发布包时,基于 `deploy/guest-image/Dockerfile` 在本地动态构建,不再依赖预制 zip。
67

78
如需覆盖 kernel 默认路径,可以通过环境变量指定:
89

910
- `ONE_CLICK_CUBE_KERNEL_VMLINUX`
11+
- `ONE_CLICK_CUBE_KERNEL_PVM_VMLINUX`

0 commit comments

Comments
 (0)