From 83b37ef536b422cc8e1d932a1736f8dc4085eba3 Mon Sep 17 00:00:00 2001 From: "Justin C. Miller" Date: Sun, 10 Feb 2019 10:31:43 -0800 Subject: [PATCH] Give qemu.sh better option handling --- qemu.sh | 29 +++++++++++++++++++---------- 1 file changed, 19 insertions(+), 10 deletions(-) diff --git a/qemu.sh b/qemu.sh index 32a92a6..35dbfc4 100755 --- a/qemu.sh +++ b/qemu.sh @@ -1,19 +1,29 @@ #!/usr/bin/env bash +build="$(dirname $0)/build" debug="" -if [[ $1 = "--debug" ]]; then - debug="-s" - shift -fi +gfx="-nographic" -build=${1:-"$(dirname $0)/build"} +for arg in $@; do + case "${arg}" in + --debug) + debug="-s" + ;; + --gfx) + gfx="" + ;; + *) + build="${arg}" + ;; + esac +done kvm="" -if [[ -f /dev/kvm ]]; then - kvm="--enable-kvm" +if [[ -c /dev/kvm ]]; then + kvm="-enable-kvm" fi -ninja -C $build && \ +ninja -C "${build}" && \ exec qemu-system-x86_64 \ -drive "if=pflash,format=raw,file=${build}/flash.img" \ -drive "format=raw,file=${build}/popcorn.img" \ @@ -24,5 +34,4 @@ exec qemu-system-x86_64 \ -cpu Broadwell \ -M q35 \ -no-reboot \ - -nographic \ - $kvm $debug + $gfx $kvm $debug