]> xenbits.xensource.com Git - libvirt.git/commitdiff
qemu: migration: Pre-create QCOW2 images for non-shared storage with 0 allocation
authorPeter Krempa <pkrempa@redhat.com>
Mon, 30 Sep 2024 12:16:58 +0000 (14:16 +0200)
committerPeter Krempa <pkrempa@redhat.com>
Tue, 1 Oct 2024 10:57:02 +0000 (12:57 +0200)
Specify that the <allocation> parameter for the newly-created qcow2
image is 0 so that only metadata gets preallocated. Otherwise the
storage driver code instructs qemu to use 'fallocate' preallocation mode
and considers the image fully allocated.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
src/qemu/qemu_migration.c

index 7f905f8584fbd7b555fcc129f267dbbf79fe2226..b686e42e58762a355acae497f6e8c49fa9814a4e 100644 (file)
@@ -361,6 +361,8 @@ qemuMigrationDstPrecreateDisk(virConnectPtr *conn,
     virBufferAddLit(&buf, "<volume>\n");
     virBufferAdjustIndent(&buf, 2);
     virBufferEscapeString(&buf, "<name>%s</name>\n", volName);
+    if (disk->src->format == VIR_STORAGE_FILE_QCOW2)
+        virBufferAddLit(&buf, "<allocation>0</allocation>\n");
     virBufferAsprintf(&buf, "<capacity>%llu</capacity>\n", capacity);
     virBufferAddLit(&buf, "<target>\n");
     virBufferAdjustIndent(&buf, 2);