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.
This commit is contained in:
gmt4 2024-02-21 10:53:05 +01:00 committed by Martin Wimpress
parent 41fe0093c8
commit 5d497ed2a0
1 changed files with 7 additions and 1 deletions

View File

@ -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