[libvirt PATCH] storage_util: fix qemu-img sparse allocation

Pavel Hrdina posted 1 patch 3 years, 7 months ago
Test syntax-check failed
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/libvirt tags/patchew/3b168c465fff5bbd495ba8f5d2fadcd794a97ce7.1598361393.git.phrdina@redhat.com
src/storage/storage_util.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
[libvirt PATCH] storage_util: fix qemu-img sparse allocation
Posted by Pavel Hrdina 3 years, 7 months ago
Commit <c9ec7088c7a3f4cd26bb471f1f243931fff6f4f9> introduced a support
to fully allocate qcow2 images when <allocation> matches <capacity> 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 <phrdina@redhat.com>
---
 src/storage/storage_util.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

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,
-- 
2.26.2

Re: [libvirt PATCH] storage_util: fix qemu-img sparse allocation
Posted by Michal Privoznik 3 years, 7 months ago
On 8/25/20 3:16 PM, Pavel Hrdina wrote:
> Commit <c9ec7088c7a3f4cd26bb471f1f243931fff6f4f9> introduced a support
> to fully allocate qcow2 images when <allocation> matches <capacity> 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 <phrdina@redhat.com>
> ---
>   src/storage/storage_util.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)

Ooops.

Reviewed-by: Michal Privoznik <mprivozn@redhat.com>

Michal