Skip to content

Linux VM builder refactor #3

Linux VM builder refactor

Linux VM builder refactor #3

Workflow file for this run

name: Build and test
on:
workflow_dispatch:
pull_request:
push:
branches:
- main
tags:
- "*"
jobs:
build-gvltctl:
name: Build gvltctl
# Matches test-vm-builder to avoid errors
runs-on: ubuntu-24.04
steps:
- name: Checkout sources
uses: actions/checkout@v4
- name: Update APT packages
run: |-
sudo apt-get update
- name: Install Buf
uses: bufbuild/buf-setup-action@v1
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
- name: Install Protoc
uses: arduino/setup-protoc@v3
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}
- name: Install Rust
uses: actions-rs/toolchain@v1
with:
toolchain: stable
default: true
- name: Use Rust cache
uses: Swatinem/rust-cache@v2
- name: Build gvltctl
run: |-
cargo build --features vm-builder-v2
cp target/debug/gvltctl .
- name: Upload build artifacts
uses: actions/upload-artifact@v4
with:
name: gvltctl-exe
path: gvltctl
retention-days: 1
if-no-files-found: error
overwrite: true
test-vm-builder:
name: Test VM builder
needs: [build-gvltctl]
# It's important to run on Ubuntu 24, not Ubuntu 22, because
# fuse2fs is required to be >=1.47 and Ubuntu 22 only has 1.46.
runs-on: ubuntu-24.04
steps:
- name: Checkout sources
uses: actions/checkout@v4
- name: Download gvltctl
uses: actions/download-artifact@v4
with:
name: gvltctl-exe
path: tests/vm_builder/simple_vm
github-token: ${{ secrets.GITHUB_TOKEN }}
- name: Update APT packages
run: |-
sudo apt-get update
- name: Install gvltctl runtime dependencies
run: |-
sudo apt-get install -y ca-certificates
# We are using pre-compiled kernel in tests, so we don't need Linux kernel build dependencies.
- name: Install VM builder runtime dependencies
run: |-
sudo apt-get install -y podman e2fsprogs fuse2fs
- name: Install QEMU
run: |-
sudo apt-get install -y qemu-system
- name: Build test VM image
working-directory: tests/vm_builder/simple_vm
env:
RUST_LOG: trace
run: |-
./gvltctl build \
--fuse \
--containerfile Containerfile \
--kernel-file bin/bzImage \
--no-gevulot-runtime
- name: Check disk.img file
working-directory: tests/vm_builder/simple_vm
run: |-
file disk.img
- name: Run test VM
working-directory: tests/vm_builder/simple_vm
run: |-
OUTPUT=$(qemu-system-x86_64 -machine q35 -nographic --hda disk.img)
echo "$OUTPUT"
RES=$(echo "$OUTPUT" | grep "Hello, world!")
if [[ $RES = "" ]]; then
echo "FAILED"
exit 1;
else
echo "OK"
fi