Skip to content

Instantly share code, notes, and snippets.

@mjkpolo
Last active January 11, 2023 19:50
Show Gist options
  • Save mjkpolo/ae804c93dcc17cec6419092905abe5f2 to your computer and use it in GitHub Desktop.
Save mjkpolo/ae804c93dcc17cec6419092905abe5f2 to your computer and use it in GitHub Desktop.
starting qemu for building and running
#!/bin/bash -e
NPROC=4
SOURCE=$(dirname -- $( readlink -f -- $0 ))
DISK=ubuntu.qcow2
cp $(dirname $(which qemu-img))/../share/qemu/edk2-aarch64-code.fd $SOURCE
cp $(dirname $(which qemu-img))/../share/qemu/edk2-arm-vars.fd $SOURCE
if [ "$1" == "build" ]
then
qemu-system-aarch64 \
-machine virt,accel=hvf,highmem=on \
-cpu host -m 7G \
-smp $NPROC \
-display cocoa \
-drive "if=pflash,format=raw,file=$SOURCE/edk2-aarch64-code.fd,readonly=on" \
-drive "if=pflash,format=raw,file=$SOURCE/edk2-arm-vars.fd,discard=on" \
-drive "if=virtio,media=disk,id=drive2,file=$SOURCE/$DISK,cache=writethrough,format=qcow2" \
-device e1000,netdev=net0 \
-netdev user,id=net0 \
-netdev user,id=net1 \
-device virtio-net-pci,netdev=net1 \
-device virtio-gpu-pci \
-device virtio-keyboard-pci \
-device virtio-mouse-pci \
-cdrom $SOURCE/$2 \
-boot d
else
tmux new-session -d -s qemu "qemu-system-aarch64 \
-smp $NPROC \
-machine virt,accel=hvf,highmem=on \
-cpu host -m 7G \
-drive 'if=pflash,format=raw,file=$SOURCE/edk2-aarch64-code.fd,readonly=on' \
-drive 'if=pflash,format=raw,file=$SOURCE/edk2-arm-vars.fd,discard=on' \
-drive 'if=virtio,media=disk,id=drive2,file=$SOURCE/$DISK,cache=writethrough,format=qcow2' \
-device e1000,netdev=net0 \
-netdev user,id=net0,hostfwd=tcp::5555-:22,hostfwd=tcp::5902-:5902 \
-nographic"
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment