From e8b1b7cb3e43f71e605cee7f68f7f19990cee149 Mon Sep 17 00:00:00 2001 From: infokiller Date: Mon, 1 Aug 2022 11:22:12 +0300 Subject: [PATCH] Add support for spice-app (#510) * Add spice-app as display option * Rework how we set the default OUTPUT variable display is never set and display_param_check is already checked when parsing options * enable overriding the gl param 3d acceleration is not stable on some setups (looking at you, nvidia) Co-authored-by: Matej --- quickemu | 46 ++++++++++++++++++++++++++++------------------ 1 file changed, 28 insertions(+), 18 deletions(-) diff --git a/quickemu b/quickemu index 17f739e..56576a4 100755 --- a/quickemu +++ b/quickemu @@ -221,7 +221,6 @@ function vm_boot() { local HOST_CPU_SMT="" local HOST_CPU_SOCKETS="" local HOST_CPU_VENDOR="" - local GL="on" local GUEST_TWEAKS="" local KERNEL_NAME="Unknown" local KERNEL_NODE="" @@ -734,24 +733,32 @@ function vm_boot() { DISPLAY_RENDER="${OUTPUT},grab-on-hover=on,zoom-to-fit=off" # GL is not working with GTK and virtio-vga if [ "${DISPLAY_DEVICE}" == "virtio-vga" ]; then - GL="off" + gl="off" fi ;; none|spice) DISPLAY_RENDER="none";; + # spice-app has a bug where using spice-app,gl=off seems to enable gl, but + # if the gl param is omitted it works fine. + spice-app) + DISPLAY_RENDER="${OUTPUT}" + if [[ "${gl}" == "on" ]]; then + DISPLAY_RENDER+=",gl=on" + fi + ;; *) - DISPLAY_RENDER="${OUTPUT},gl=${GL}";; + DISPLAY_RENDER="${OUTPUT},gl=${gl}";; esac - if [ "${GL}" == "on" ] && [[ "${DISPLAY_DEVICE}" == *"virtio"* ]]; then + if [ "${gl}" == "on" ] && [[ "${DISPLAY_DEVICE}" == *"virtio"* ]]; then if [ "${QEMU_VER_SHORT}" -ge 61 ]; then DISPLAY_DEVICE="${DISPLAY_DEVICE}-gl" else DISPLAY_DEVICE="${DISPLAY_DEVICE},virgl=on" fi - echo ", GL (${GL}), VirGL (on)" + echo ", GL (${gl}), VirGL (on)" else - echo ", GL (${GL}), VirGL (off)" + echo ", GL (${gl}), VirGL (off)" fi # Build the video configuration @@ -1243,7 +1250,7 @@ function usage() { echo " --braille : Enable braille support. Requires SDL." echo " --delete-disk : Delete the disk image and EFI variables" echo " --delete-vm : Delete the entire VM and it's configuration" - echo " --display : Select display backend. 'sdl' (default), 'gtk', 'none', or 'spice'" + echo " --display : Select display backend. 'sdl' (default), 'gtk', 'none', 'spice' or 'spice-app'" echo " --fullscreen : Starts VM in full screen mode (Ctl+Alt+f to exit)" echo " --ignore-msrs-always : Configure KVM to always ignore unhandled machine-specific registers" echo " --screen : Use specified screen to determine the window size." @@ -1274,8 +1281,7 @@ function usage() { } function display_param_check() { - # @ASK: accept "spice-app" as output ? - if [ "${OUTPUT}" != "gtk" ] && [ "${OUTPUT}" != "none" ] && [ "${OUTPUT}" != "sdl" ] && [ "${OUTPUT}" != "spice" ]; then + if [ "${OUTPUT}" != "gtk" ] && [ "${OUTPUT}" != "none" ] && [ "${OUTPUT}" != "sdl" ] && [ "${OUTPUT}" != "spice" ] && [ "${OUTPUT}" != "spice-app" ]; then echo "ERROR! Requested output '${OUTPUT}' is not recognised." exit 1 fi @@ -1612,16 +1618,14 @@ if [ -n "${VM}" ] && [ -e "${VM}" ]; then disk_size="${disk}" fi + # Set the default OUTPUT if not provided by user if [ -z "${OUTPUT}" ]; then - # Braille support requires SDL. Override OUTPUT if braille was requested. - if [ -n "${BRAILLE}" ]; then - OUTPUT="sdl" - elif [ -z "${display}" ]; then - OUTPUT="sdl" - else - OUTPUT="${display}" - display_param_check - fi + OUTPUT="sdl" + fi + + # Braille support requires SDL. Override OUTPUT if braille was requested. + if [ -n "${BRAILLE}" ]; then + OUTPUT="sdl" fi if [ -z "${VIEWER}" ]; then @@ -1629,6 +1633,12 @@ if [ -n "${VM}" ] && [ -e "${VM}" ]; then fi viewer_param_check + # Set the default 3d acceleration. Will be overridden to "off" if + # DISPLAY_DEVICE is determined to be virtio-vga since it doesn't work there. + if [ -z "${gl}" ]; then + gl="on" + fi + if [ -z "${PUBLIC}" ]; then PUBLIC="${public_dir}" fi