From 5d497ed2a0a1184e3187fd2e6b95e922d47f3e7c Mon Sep 17 00:00:00 2001 From: gmt4 <791491+gmt4@users.noreply.github.com> Date: Wed, 21 Feb 2024 10:53:05 +0100 Subject: [PATCH] quickemu: Support $disk_format var for $disk_img This adds disk_format=${disk_format:-qcow2} variable that defaults to qcow2 format, so the vm.conf files can use $disk_format to specify the format of the $disk_img when this is different from the default qcow2. --- quickemu | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/quickemu b/quickemu index 2478f7b..1ebe4f8 100755 --- a/quickemu +++ b/quickemu @@ -1164,7 +1164,7 @@ function vm_boot() { else # shellcheck disable=SC2054,SC2206 args+=(-device virtio-blk-pci,drive=SystemDisk - -drive id=SystemDisk,if=none,format=qcow2,file="${disk_img}" ${STATUS_QUO}) + -drive id=SystemDisk,if=none,format=${disk_format:-qcow2},file="${disk_img}" ${STATUS_QUO}) fi # https://wiki.qemu.org/Documentation/9psetup @@ -1494,6 +1494,7 @@ function monitor_send_cmd { boot="efi" cpu_cores="" disk_img="" +disk_format="" disk_size="" display="" extra_args="" @@ -1784,6 +1785,11 @@ if [ -n "${VM}" ] && [ -e "${VM}" ]; then disk_size="${disk}" fi + # Set the default disk_format if not provided by user + if [ -z "${disk_format}" ]; then + disk_format=$(${QEMU_IMG} info "${disk_img}" | grep 'file format' | cut -d ':' -f 2 | tr -cd '[:graph:]') + fi + if [ -n "${display}" ]; then OUTPUT="${display}" fi