From 36ee8ed43a6b35d8a258ce9d25006020575b6502 Mon Sep 17 00:00:00 2001 From: Krzesimir Nowak Date: Tue, 22 Apr 2025 16:38:35 +0200 Subject: [PATCH] build_library/qemu_template.sh: Simplify qemu execution The final part of the script differed only the name of the qemu binary to execute and in network device driver (virtio-net-pci on amd64 vs virtio-net-device on arm64). virtio-net-pci seems to be working also on arm64, so simplify the code to avoid repetition. --- build_library/qemu_template.sh | 27 ++++++++++----------------- 1 file changed, 10 insertions(+), 17 deletions(-) diff --git a/build_library/qemu_template.sh b/build_library/qemu_template.sh index fb8e2141cc..375e743f83 100755 --- a/build_library/qemu_template.sh +++ b/build_library/qemu_template.sh @@ -291,25 +291,18 @@ fi case "${VM_BOARD}" in amd64-usr) - # Default to KVM, fall back on full emulation - qemu-system-x86_64 \ - -name "$VM_NAME" \ - -m ${VM_MEMORY} \ - -netdev user,id=eth0${QEMU_FORWARDED_PORTS:+,}${QEMU_FORWARDED_PORTS},hostfwd=tcp::"${SSH_PORT}"-:22,hostname="${VM_NAME}" \ - -device virtio-net-pci,netdev=eth0 \ - -object rng-random,filename=/dev/urandom,id=rng0 -device virtio-rng-pci,rng=rng0 \ - "$@" - ;; + QEMU_BIN=qemu-system-x86_64 ;; arm64-usr) - qemu-system-aarch64 \ - -name "$VM_NAME" \ - -m ${VM_MEMORY} \ - -netdev user,id=eth0${QEMU_FORWARDED_PORTS:+,}${QEMU_FORWARDED_PORTS},hostfwd=tcp::"${SSH_PORT}"-:22,hostname="${VM_NAME}" \ - -device virtio-net-device,netdev=eth0 \ - -object rng-random,filename=/dev/urandom,id=rng0 -device virtio-rng-pci,rng=rng0 \ - "$@" - ;; + QEMU_BIN=qemu-system-aarch64 ;; *) die "Unsupported arch" ;; esac +"$QEMU_BIN" \ + -name "$VM_NAME" \ + -m ${VM_MEMORY} \ + -netdev user,id=eth0${QEMU_FORWARDED_PORTS:+,}${QEMU_FORWARDED_PORTS},hostfwd=tcp::"${SSH_PORT}"-:22,hostname="${VM_NAME}" \ + -device virtio-net-pci,netdev=eth0 \ + -object rng-random,filename=/dev/urandom,id=rng0 -device virtio-rng-pci,rng=rng0 \ + "$@" + exit $?