From 062476aaaa849ff0951db92e3bcfd32d35e58420 Mon Sep 17 00:00:00 2001 From: Ralph Ronnquist Date: Thu, 19 Sep 2024 21:51:42 +1000 Subject: [PATCH] Reworked to handle architectures with specific qemu setups. --- vm.sh | 80 ++++++++++++++++++++++++++++++++++++++--------------------- 1 file changed, 52 insertions(+), 28 deletions(-) diff --git a/vm.sh b/vm.sh index 59e937b..c75ff8a 100755 --- a/vm.sh +++ b/vm.sh @@ -24,41 +24,65 @@ fi case "$ARCH" in arm64) QEMU=qemu-system-aarch64 - CPU=cortex-a53 - NET=virtio-net-device + ARGS=( + -M virt -cpu cortex-a53 -m 4G -nographic -serial stdio + -kernel arm64/vmlinuz -initrd arm64/initrd.gz + -append "console=ttyAMA0 root=/dev/vda1 roottype=ext4$APPEND" + -chardev socket,id=QEMU,server=on,wait=off,path=QEMU-arm64 + -mon chardev=QEMU,mode=readline + -device virtio-blk-device,drive=hd + -drive if=none,id=hd,file=$IMG,format=raw + -device virtio-net-device,netdev=unet + -netdev vde,sock=/run/vde.ctl,id=unet + ) ;; armhf) QEMU=qemu-system-arm - CPU=cortex-a15 - #USB="-device qemu-xhci -device usb-host" - NET=virtio-net-device + ARGS=( + -M virt -cpu cortex-a15 -m 4G -nographic -serial stdio + -kernel armhf/vmlinuz -initrd armhf/initrd.gz + -append "console=ttyAMA0 root=/dev/vda1 roottype=ext4$APPEND" + -chardev socket,id=QEMU,server=on,wait=off,path=QEMU-armhf + -mon chardev=QEMU,mode=readline + -device virtio-blk-device,drive=hd + -drive if=none,id=hd,file=$IMG,format=raw + -device virtio-net-device,netdev=unet + -netdev vde,sock=/run/vde.ctl,id=unet + ) + ;; + amd64) + QEMU=qemu-system-x86_64 + ARGS=( + -M pc,accel=kvm -cpu qemu64 -m 4G -nographic -serial stdio + -kernel amd64/vmlinuz -initrd amd64/initrd.gz + -append "console=ttyS0 root=/dev/vda1 roottype=ext4$APPEND" + -chardev socket,id=QEMU,server=on,wait=off,path=QEMU-amd64 + -mon chardev=QEMU,mode=readline + -device virtio-blk-pci,drive=hd + -drive if=none,id=hd,file=$IMG,format=raw + -device virtio-net-pci,netdev=unet + -netdev vde,sock=/run/vde.ctl,id=unet + ) + ;; + i386) + QEMU=qemu-system-i386 + ARGS=( + -M pc,accel=kvm -cpu qemu32 -m 4G -nographic -serial stdio + -kernel i386/vmlinuz -initrd i386/initrd.gz + -append "console=ttyS0 root=/dev/vda1 roottype=ext4$APPEND" + -chardev socket,id=QEMU,server=on,wait=off,path=QEMU-i386 + -mon chardev=QEMU,mode=readline + -device virtio-blk-pci,drive=hd + -drive if=none,id=hd,file=$IMG,format=raw + -device virtio-net-pci,netdev=unet + -netdev vde,sock=/run/vde.ctl,id=unet + ) ;; *) - echo "unknown $1" >&2 + echo "unknown \$1=$1" >&2 exit 1 ;; esac -ARGS=( - -M virt -cpu $CPU -m 4G - # boot setup - -kernel $ARCH/vmlinuz - $INITRD - -append "console=ttyAMA0 root=/dev/vda1 roottype=ext4$APPEND" - -serial stdio - # qemu monitor interface - -chardev socket,id=QEMU-$ARCH,server=on,wait=off,path=QEMU - -mon chardev=QEMU-$ARCH,mode=readline - # graphics setup - -nographic - # harddrive setup - -device virtio-blk-device,drive=hd - -drive if=none,id=hd,file=$IMG,format=raw - # USB setup - $USB - # network setup - -device $NET,netdev=unet - -netdev vde,sock=/run/vde.ctl,id=unet -) - +echo $QEMU "${ARGS[@]}" | sed 's/ -/\n -/g' >&2 exec $QEMU "${ARGS[@]}" -- 2.39.2