From 393929342b7daed4c202f643835ddd39e57e14a2 Mon Sep 17 00:00:00 2001 From: Stephen Bates Date: Thu, 21 Nov 2024 17:44:02 -0700 Subject: [PATCH] qemu/riscv64: Add riscv64 to the architectures supported Add support for riscv64 to the gen-vm and run-vm scripts. Note this means a couple of packages need to be installed (qemu-system-misc and u-boot-qemu). Add this to our smoke-test GitHub workflow. --- .github/workflows/smoke-test.yml | 22 ++++++++++++++++++++-- qemu/gen-vm | 8 ++++++-- qemu/run-vm | 6 +++++- 3 files changed, 31 insertions(+), 5 deletions(-) diff --git a/.github/workflows/smoke-test.yml b/.github/workflows/smoke-test.yml index 06a363a..02e4234 100644 --- a/.github/workflows/smoke-test.yml +++ b/.github/workflows/smoke-test.yml @@ -3,8 +3,6 @@ name: smoke-tests on: pull_request: branches: [ main ] - paths: - - './qemu/gen-vm' jobs: @@ -46,3 +44,23 @@ jobs: USERNAME: ubuntu PASS: password ARCH: arm64 + + ubuntu-latest-riscv64: + name: ubuntu-latest-riscv64 + runs-on: ubuntu-latest + steps: + - name: Check out code using action/checkout + uses: actions/checkout@v4.1.1 + - name: Install a couple of packages via the apt package manager + run: sudo apt update && sudo apt install -y qemu-system-misc u-boot-qemu cloud-image-utils + - name: Generate an ssh key-pair for this test + run: ssh-keygen -t rsa -q -f "$HOME/.ssh/id_rsa" -N "" + - name: Run a riscv64 qemu-based ./gen-vm smoke-test + run: ./gen-vm + working-directory: qemu + env: + VM_NAME: qemu-minimal-smoke-test-riscv64 + KVM: none + USERNAME: ubuntu + PASS: password + ARCH: riscv64 diff --git a/qemu/gen-vm b/qemu/gen-vm index 006257e..1d873fc 100755 --- a/qemu/gen-vm +++ b/qemu/gen-vm @@ -5,7 +5,7 @@ # (C) Stephen Bates # # A simple script generate a Ubuntu Noble VM using bare QEMU (i.e. not -# libvirt) and cloud-init. +# libvirt) and cloud-init.. # # Jammy (or Later) # ---------------- @@ -135,6 +135,9 @@ if [ ${ARCH} == "amd64" ]; then elif [ ${ARCH} == "arm64" ]; then QARCH="aarch64" QARCH_ARGS="-machine virt,gic-version=max${KVM} -cpu max -bios /usr/share/qemu-efi-aarch64/QEMU_EFI.fd" +elif [ ${ARCH} == "riscv64" ]; then + QARCH="riscv64" + QARCH_ARGS="-machine virt,${KVM} -kernel /usr/lib/u-boot/qemu-riscv64_smode/uboot.elf" else echo "Error: No ARCH mapping exists for ${ARCH}! Exiting."; exit -1 fi @@ -146,7 +149,8 @@ qemu-system-${QARCH} \ -nographic \ -drive if=virtio,format=qcow2,file=${IMAGES}/${VM_NAME}-backing.qcow2 \ -drive if=virtio,format=qcow2,file=${IMAGES}/${VM_NAME}-seed.qcow2 \ - -nic user,id=user0,model=virtio-net-pci + -netdev user,id=net0 \ + -device virtio-net-pci,netdev=net0 qemu-img create -F qcow2 -b ${IMAGES}/${VM_NAME}-backing.qcow2 -f qcow2 \ ${IMAGES}/${VM_NAME}.qcow2 diff --git a/qemu/run-vm b/qemu/run-vm index 7634fde..fb55afa 100755 --- a/qemu/run-vm +++ b/qemu/run-vm @@ -40,6 +40,9 @@ if [ ${ARCH} == "amd64" ]; then elif [ ${ARCH} == "arm64" ]; then QARCH="aarch64" QARCH_ARGS="-machine virt,gic-version=max${KVM} -cpu max -bios /usr/share/qemu-efi-aarch64/QEMU_EFI.fd" +elif [ ${ARCH} == "riscv64" ]; then + QARCH="riscv64" + QARCH_ARGS="-machine virt,${KVM} -kernel /usr/lib/u-boot/qemu-riscv64_smode/uboot.elf" else echo "Error: No ARCH mapping exists for ${ARCH}! Exiting."; exit -1 fi @@ -51,4 +54,5 @@ qemu-system-${QARCH} \ ${FILESYSTEM_ARGS} \ -nographic \ -drive if=virtio,format=qcow2,file=${IMAGES}/${VM_NAME}.qcow2 \ - -nic user,id=user0,model=virtio-net-pci,hostfwd=tcp::${SSH_PORT}-:22 + -netdev user,id=net0,hostfwd=tcp::${SSH_PORT}-:22 \ + -device virtio-net-pci,netdev=net0