[PATCH] qemu: block copy: Propagate 'detect_zeroes' properly into mirror definition

Peter Krempa posted 1 patch 2 years, 2 months ago
Test syntax-check failed
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/libvirt tags/patchew/67c936c61392231ed92518a03d0aefe16b9b6076.1645621980.git.pkrempa@redhat.com
src/qemu/qemu_driver.c | 8 ++++++++
1 file changed, 8 insertions(+)
[PATCH] qemu: block copy: Propagate 'detect_zeroes' properly into mirror definition
Posted by Peter Krempa 2 years, 2 months ago
'qemuDomainPrepareDiskSourceData' propagates 'detect_zeroes' only for
the disk source image, but the mirror destination has the ambition to
replace the disk source when the job is finished, so we need to
propagate the 'detect_zeroes' setting also in that case.

Unfortunately it would become very hairy to either set 'disk->mirror'
sooner or propagate that we want this done into
'qemuDomainPrepareDiskSourceData', so the most straightforward solution
is to do the propagation inside 'qemuDomainBlockCopyCommon'.

Closes: https://gitlab.com/libvirt/libvirt/-/issues/277
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
---
 src/qemu/qemu_driver.c | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index e417d358cd..4fc998cde5 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -14977,6 +14977,14 @@ qemuDomainBlockCopyCommon(virDomainObj *vm,
             if (qemuDomainPrepareStorageSourceBlockdev(disk, n, priv, cfg) < 0)
                 goto endjob;
         }
+
+        /* 'qemuDomainPrepareStorageSourceBlockdev' calls
+         * 'qemuDomainPrepareDiskSourceData' which propagates 'detect_zeroes'
+         * into the topmost virStorage source of the disk chain.
+         * Since 'mirror' has the ambition to replace it we need to propagate
+         * it into the mirror too. We do it directly as otherwise we'd need
+         * to modify all callers of 'qemuDomainPrepareStorageSourceBlockdev' */
+        mirror->detect_zeroes = disk->detect_zeroes;
     }

     /* If reusing an external image that includes a backing file but the user
-- 
2.35.1

Re: [PATCH] qemu: block copy: Propagate 'detect_zeroes' properly into mirror definition
Posted by Ján Tomko 2 years, 2 months ago
On a Wednesday in 2022, Peter Krempa wrote:
>'qemuDomainPrepareDiskSourceData' propagates 'detect_zeroes' only for
>the disk source image, but the mirror destination has the ambition to
>replace the disk source when the job is finished, so we need to
>propagate the 'detect_zeroes' setting also in that case.
>
>Unfortunately it would become very hairy to either set 'disk->mirror'
>sooner or propagate that we want this done into
>'qemuDomainPrepareDiskSourceData', so the most straightforward solution
>is to do the propagation inside 'qemuDomainBlockCopyCommon'.
>
>Closes: https://gitlab.com/libvirt/libvirt/-/issues/277
>Signed-off-by: Peter Krempa <pkrempa@redhat.com>
>---
> src/qemu/qemu_driver.c | 8 ++++++++
> 1 file changed, 8 insertions(+)
>

Reviewed-by: Ján Tomko <jtomko@redhat.com>

Jano