Give qemu.sh better option handling

This commit is contained in:
Justin C. Miller
2019-02-10 10:31:43 -08:00
parent 1965197ccd
commit 83b37ef536

29
qemu.sh
View File

@@ -1,19 +1,29 @@
#!/usr/bin/env bash #!/usr/bin/env bash
build="$(dirname $0)/build"
debug="" debug=""
if [[ $1 = "--debug" ]]; then gfx="-nographic"
debug="-s"
shift
fi
build=${1:-"$(dirname $0)/build"} for arg in $@; do
case "${arg}" in
--debug)
debug="-s"
;;
--gfx)
gfx=""
;;
*)
build="${arg}"
;;
esac
done
kvm="" kvm=""
if [[ -f /dev/kvm ]]; then if [[ -c /dev/kvm ]]; then
kvm="--enable-kvm" kvm="-enable-kvm"
fi fi
ninja -C $build && \ ninja -C "${build}" && \
exec qemu-system-x86_64 \ exec qemu-system-x86_64 \
-drive "if=pflash,format=raw,file=${build}/flash.img" \ -drive "if=pflash,format=raw,file=${build}/flash.img" \
-drive "format=raw,file=${build}/popcorn.img" \ -drive "format=raw,file=${build}/popcorn.img" \
@@ -24,5 +34,4 @@ exec qemu-system-x86_64 \
-cpu Broadwell \ -cpu Broadwell \
-M q35 \ -M q35 \
-no-reboot \ -no-reboot \
-nographic \ $gfx $kvm $debug
$kvm $debug