-
Notifications
You must be signed in to change notification settings - Fork 34
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ci: add a qemu/arm64 VM to GH workflows
Signed-off-by: Ramkumar Chinchani <[email protected]>
- Loading branch information
Showing
1 changed file
with
73 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
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 | ||
- name: Provision VM | ||
run: | | ||
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,hostfwd=tcp::22225-:22 \ | ||
-device virtio-net-device,netdev=net0,mac=$randmac | ||
wait: | ||
runs-on: ubuntu-22.04 | ||
steps: | ||
- name: Install dependencies | ||
run: | | ||
sudo apt-get update | ||
sudo apt-get install -y sshpass | ||
- name: Check ssh connectivity | ||
run: | | ||
set +e | ||
while true; do | ||
echo Trying to connect | ||
sshpass -p passw0rd ssh -v -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -p 22225 ubuntu@localhost whoami | ||
if [ $? -eq 0 ]; then | ||
break | ||
fi | ||
done | ||
exit 0 |