]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
qemu: migration: Create qcow2 v3 images for VIR_MIGRATE_NON_SHARED_DISK
authorPeter Krempa <pkrempa@redhat.com>
Wed, 17 Feb 2021 13:45:49 +0000 (14:45 +0100)
committerPeter Krempa <pkrempa@redhat.com>
Sat, 20 Feb 2021 12:21:15 +0000 (13:21 +0100)
Use the new format when pre-creating the image for the user. Users
wishing to use the legacy format can always provide their own images or
use shared storage.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
src/qemu/qemu_migration.c

index e8e35c1c7cfdf7de92c2d553d59fbd19a494b7ac..94b9b34ca044cfaa03b23df125b9891d25d7bc0b 100644 (file)
@@ -180,6 +180,7 @@ qemuMigrationDstPrecreateDisk(virConnectPtr *conn,
     char *volStr = NULL;
     g_auto(virBuffer) buf = VIR_BUFFER_INITIALIZER;
     const char *format = NULL;
+    const char *compat = NULL;
     unsigned int flags = 0;
 
     VIR_DEBUG("Precreate disk type=%s", virStorageTypeToString(disk->src->type));
@@ -212,8 +213,11 @@ qemuMigrationDstPrecreateDisk(virConnectPtr *conn,
         if (!(pool = virStoragePoolLookupByTargetPath(*conn, basePath)))
             goto cleanup;
         format = virStorageFileFormatTypeToString(disk->src->format);
-        if (disk->src->format == VIR_STORAGE_FILE_QCOW2)
+        if (disk->src->format == VIR_STORAGE_FILE_QCOW2) {
             flags |= VIR_STORAGE_VOL_CREATE_PREALLOC_METADATA;
+            /* format qcow2v3 image */
+            compat = "1.1";
+        }
         break;
 
     case VIR_STORAGE_TYPE_VOLUME:
@@ -261,6 +265,8 @@ qemuMigrationDstPrecreateDisk(virConnectPtr *conn,
     virBufferAddLit(&buf, "<target>\n");
     virBufferAdjustIndent(&buf, 2);
     virBufferAsprintf(&buf, "<format type='%s'/>\n", format);
+    if (compat)
+        virBufferAsprintf(&buf, "<compat>%s</compat>\n", compat);
     virBufferAdjustIndent(&buf, -2);
     virBufferAddLit(&buf, "</target>\n");
     virBufferAdjustIndent(&buf, -2);