From: Pavel Hrdina Date: Tue, 25 Aug 2020 13:09:53 +0000 (+0200) Subject: storage_util: fix qemu-img sparse allocation X-Git-Tag: v6.7.0-rc1~29 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=81a3042a12c7c06adc8e95264b6143b2eeb4953f;p=thirdparty%2Flibvirt.git storage_util: fix qemu-img sparse allocation Commit introduced a support to fully allocate qcow2 images when matches but it doesn't work as expected. The issue is that info.size_arg is in KB but the info.allocation introduced by the mentioned commit is in B. This results in using "preallocation=falloc," in cases where "preallocation=metadata," should be used. Signed-off-by: Pavel Hrdina Reviewed-by: Michal Privoznik --- diff --git a/src/storage/storage_util.c b/src/storage/storage_util.c index f7c09e3375..fcecedbc3a 100644 --- a/src/storage/storage_util.c +++ b/src/storage/storage_util.c @@ -1044,7 +1044,7 @@ virStorageBackendCreateQemuImgCmdFromVol(virStoragePoolObjPtr pool, .type = NULL, .inputType = NULL, .path = vol->target.path, - .allocation = vol->target.allocation, + .allocation = VIR_DIV_UP(vol->target.allocation, 1024), .encryption = !!vol->target.encryption, .preallocate = !!(flags & VIR_STORAGE_VOL_CREATE_PREALLOC_METADATA), .compat = vol->target.compat,