fix: Do not set the lazy_refcounts option for raw disk images

This commit is contained in:
Luke Yelavich 2024-05-22 08:56:09 +10:00 committed by Martin Wimpress
parent 811b48cc4e
commit 5d1c8dfc4c
1 changed files with 8 additions and 1 deletions

View File

@ -786,6 +786,7 @@ function configure_os_quirks() {
}
function configure_storage() {
local create_options=""
echo " - Disk: ${disk_img} (${disk_size})"
if [ ! -f "${disk_img}" ]; then
# If there is no disk image, create a new image.
@ -796,8 +797,14 @@ function configure_storage() {
exit 1;;
esac
case ${disk_format} in
qcow2) create_options="lazy_refcounts=on,preallocation=${preallocation}";;
raw) create_options="preallocation=${preallocation}";;
*) true;;
esac
# https://blog.programster.org/qcow2-performance
if ! ${QEMU_IMG} create -q -f "${disk_format}" -o lazy_refcounts=on,preallocation="${preallocation}" "${disk_img}" "${disk_size}"; then
if ! ${QEMU_IMG} create -q -f "${disk_format}" -o "${create_options=}" "${disk_img}" "${disk_size}"; then
echo "ERROR! Failed to create ${disk_img} using ${disk_format} format."
exit 1
fi