]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
qemu: block copy: Propagate 'detect_zeroes' properly into mirror definition
authorPeter Krempa <pkrempa@redhat.com>
Wed, 23 Feb 2022 13:04:47 +0000 (14:04 +0100)
committerPeter Krempa <pkrempa@redhat.com>
Tue, 1 Mar 2022 12:07:23 +0000 (13:07 +0100)
'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>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
src/qemu/qemu_driver.c

index b74b0375a7d6c43a4c77cda69a0b447087fc2c5c..d4517ba22d861ca7cb7e6da4ffd2ca726b037ebb 100644 (file)
@@ -14976,6 +14976,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