Skip to content

Commit 00f93f0

Browse files
authored
Merge pull request #895 from stlankes/kvm
add KVM tests with uhyve, qemu and firecracker
2 parents 5f1ccd6 + 9d3c858 commit 00f93f0

File tree

2 files changed

+93
-0
lines changed

2 files changed

+93
-0
lines changed

.github/workflows/ci.yml

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -351,3 +351,83 @@ jobs:
351351
sleep 5
352352
curl http://127.0.0.1:9975/help
353353
sleep 1
354+
355+
run-x86_64-kvm:
356+
name: Run Hermit for Rust (x86_64 + kvm)
357+
runs-on: [self-hosted]
358+
steps:
359+
- name: Install QEMU, NASM
360+
run: |
361+
sudo apt-get update
362+
sudo apt-get install qemu-system-x86 nasm
363+
- name: Checkout hermit-rs
364+
uses: actions/checkout@v4
365+
with:
366+
repository: hermitcore/hermit-rs
367+
submodules: true
368+
- name: Remove hermit-kernel submodule
369+
run: git rm -r kernel
370+
- name: Checkout hermit-kernel
371+
uses: actions/checkout@v4
372+
with:
373+
path: kernel
374+
- uses: mkroening/rust-toolchain-toml@main
375+
- uses: Swatinem/rust-cache@v2
376+
- name: Build dev profile
377+
run: cargo build -Zbuild-std=std,panic_abort --package rusty_demo --target x86_64-unknown-hermit
378+
- name: Download loader (x86_64)
379+
uses: dsaltares/fetch-gh-release-asset@1.1.1
380+
with:
381+
repo: hermitcore/rusty-loader
382+
file: rusty-loader-x86_64
383+
- name: Install uhyve
384+
run: cargo +stable install --locked uhyve
385+
- name: Check KVM availability
386+
shell: bash
387+
run: |
388+
lscpu
389+
kvm-ok
390+
- name: Test debug version (Uhyve)
391+
run: uhyve --verbose -c 1 target/x86_64-unknown-hermit/debug/rusty_demo
392+
env:
393+
RUST_LOG: debug
394+
- name: Test debug profile (Qemu)
395+
run: |
396+
qemu-system-x86_64 -display none -smp 1 -m 128M -serial stdio \
397+
-enable-kvm -cpu qemu64,apic,fsgsbase,rdtscp,xsave,xsaveopt,fxsr,rdrand \
398+
-kernel rusty-loader-x86_64 \
399+
-initrd target/x86_64-unknown-hermit/debug/rusty_demo
400+
- name: Build release profile
401+
run: cargo build -Zbuild-std=std,panic_abort --target x86_64-unknown-hermit --package rusty_demo --release
402+
- name: Test release version (Uhyve)
403+
run: uhyve --verbose -c 1 target/x86_64-unknown-hermit/release/rusty_demo
404+
env:
405+
RUST_LOG: debug
406+
- name: Test release profile (Qemu)
407+
run: |
408+
qemu-system-x86_64 -display none -smp 1 -m 128M -serial stdio \
409+
-enable-kvm -cpu qemu64,apic,fsgsbase,rdtscp,xsave,xsaveopt,fxsr,rdrand \
410+
-kernel rusty-loader-x86_64 \
411+
-initrd target/x86_64-unknown-hermit/release/rusty_demo
412+
- name: Download loader (x86_64-fc)
413+
uses: dsaltares/fetch-gh-release-asset@1.1.1
414+
with:
415+
repo: hermitcore/rusty-loader
416+
file: rusty-loader-x86_64-fc
417+
- name: Download firecracker
418+
uses: dsaltares/fetch-gh-release-asset@1.1.1
419+
with:
420+
repo: firecracker-microvm/firecracker
421+
version: tags/v1.4.1
422+
file: firecracker-v1.4.1-x86_64.tgz
423+
target: 'firecracker-x86_64.tgz'
424+
- name: Install firecracker
425+
run: |
426+
tar xzvf firecracker-x86_64.tgz --one-top-level=fc --strip-components 1
427+
- name: Build minimal profile (debug)
428+
run: cargo build -Zbuild-std=std,panic_abort --target x86_64-unknown-hermit --no-default-features --package hello_world
429+
- name: Test debug profile (Firecracker)
430+
run: |
431+
./fc/firecracker-v1.4.1-x86_64 --no-api --config-file ./kernel/fc-config.json &
432+
sleep 1
433+
kill -KILL $(pidof firecracker-v1.4.1-x86_64)

fc-config.json

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
{
2+
"boot-source": {
3+
"kernel_image_path": "./rusty-loader-x86_64-fc",
4+
"initrd_path": "target/x86_64-unknown-hermit/debug/hello_world",
5+
"boot_args": ""
6+
},
7+
"drives": [],
8+
"machine-config": {
9+
"vcpu_count": 1,
10+
"mem_size_mib": 256,
11+
"smt": false
12+
}
13+
}

0 commit comments

Comments
 (0)