From 6c9997947eeb93af6d4078bb4996b0619aa1e665 Mon Sep 17 00:00:00 2001 From: Ramkumar Chinchani Date: Thu, 28 Sep 2023 21:49:44 +0000 Subject: [PATCH] ci: add a qemu/arm64 VM to GH workflows Signed-off-by: Ramkumar Chinchani --- .github/workflows/qemu.yaml | 66 +++++++++++++++++++++++++++++++++++++ 1 file changed, 66 insertions(+) create mode 100644 .github/workflows/qemu.yaml diff --git a/.github/workflows/qemu.yaml b/.github/workflows/qemu.yaml new file mode 100644 index 00000000..566f57d3 --- /dev/null +++ b/.github/workflows/qemu.yaml @@ -0,0 +1,66 @@ +name: QEMU environment + +on: + push: + branches: + - main + pull_request: + branches: + - main + release: + types: + - published + +jobs: + setup: + runs-on: ubuntu-22.04 + steps: + - name: Install dependencies + run: | + sudo apt-get update + sudo apt-get install -y qemu-system-arm qemu-efi-aarch64 qemu-utils cloud-image-utils wget + + wget https://cloud-images.ubuntu.com/jammy/current/jammy-server-cloudimg-arm64.img + + qemu-img create -f qcow2 -F qcow2 \ + -b jammy-server-cloudimg-arm64.img \ + jammy-snapshot.qcow2 200G + + cat >"user-data" << EOF + #cloud-config + password: passw0rd + chpasswd: { expire: False } + ssh_pwauth: True + EOF + cloud-localds user-data.img user-data + + cp /usr/share/AAVMF/AAVMF_CODE.fd . + cp /usr/share/AAVMF/AAVMF_VARS.fd . + + randmac=$(openssl rand -hex 6 | sed 's/\(..\)/\1:/g; s/:$//') + + qemu-system-aarch64 \ + -m 2048 \ + -cpu max -smp 4 \ + -machine virt,gic-version=max \ + -nographic \ + -drive if=pflash,format=raw,readonly=on,file=AAVMF_CODE.fd \ + -drive if=pflash,format=raw,file=AAVMF_VARS.fd \ + -drive if=none,file=jammy-server-cloudimg-arm64.img,id=hd0 \ + -drive file=user-data.img,format=raw \ + -device virtio-blk-device,drive=hd0 \ + -netdev type=user,id=net0 \ + -device virtio-net-device,netdev=net0,mac=$randmac \ + -netdev user,id=net0,hostfwd=tcp::22225-:22 + wait: + runs-on: ubuntu-22.04 + steps: + - name: Check with ssh + run: | + while true; do + echo Trying to connect + check=$(ssh -v -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -P 22225 ubuntu@localhost) + if [ $? -eq 0 ]; then + break + fi + done