qemu: migration: Fix blockdev config with VIR_MIGRATE_PARAM_MIGRATE_DISKS_DETECT_ZEROES

The idea of migration with VIR_MIGRATE_PARAM_MIGRATE_DISKS_DETECT_ZEROES
populated is to sparsify the image. The QEMU NBD client as it was
configured in commit 621f879adf would
signal to the destination to do thick allocation of holes which would
result in a non-sparse image for any backend except a qcow2 image which
I used to test it.

Switch to VIR_DOMAIN_DISK_DETECT_ZEROES_UNMAP and
VIR_DOMAIN_DISK_DISCARD_UNMAP which tells the NBD client (and that in
turn the NBD server) to preserve the sparse blocks it detected from the
image.

Fixes: 621f879adf
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
This commit is contained in:
Peter Krempa 2024-10-11 18:31:28 +02:00
parent 0c653fc9a5
commit 04d6a0ec5d

View File

@ -1092,8 +1092,14 @@ qemuMigrationSrcNBDStorageCopyBlockdevPrepareSource(virDomainDiskDef *disk,
copysrc->protocol = VIR_STORAGE_NET_PROTOCOL_NBD;
copysrc->format = VIR_STORAGE_FILE_RAW;
if (detect_zeroes)
copysrc->detect_zeroes = VIR_DOMAIN_DISK_DETECT_ZEROES_ON;
if (detect_zeroes) {
/* We need to use both VIR_DOMAIN_DISK_DETECT_ZEROES_UNMAP and
* VIR_DOMAIN_DISK_DISCARD_UNMAP as the qemu NBD client otherwise singals
* to the server to fully allocate the zero blocks
*/
copysrc->detect_zeroes = VIR_DOMAIN_DISK_DETECT_ZEROES_UNMAP;
copysrc->discard = VIR_DOMAIN_DISK_DISCARD_UNMAP;
}
copysrc->backingStore = virStorageSourceNew();