]> xenbits.xensource.com Git - libvirt.git/commitdiff
qemuMigrationDstPrepareStorage: Move block device specific logic
authorPeter Krempa <pkrempa@redhat.com>
Fri, 16 Feb 2024 15:31:45 +0000 (16:31 +0100)
committerPeter Krempa <pkrempa@redhat.com>
Wed, 21 Feb 2024 13:15:48 +0000 (14:15 +0100)
Now that we have a switch statement, the code adding the 'slice' for
block devices of non-equal sizes can be moved to appropriate location.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
src/qemu/qemu_migration.c

index 32569ecbb4ad911336945872b0544a20c67672e8..2ac10ab5ff1fb01d0f9c8ac5413c06c956dad578 100644 (file)
@@ -452,8 +452,27 @@ qemuMigrationDstPrepareStorage(virDomainObj *vm,
             continue;
 
         switch (virStorageSourceGetActualType(disk->src)) {
-        case VIR_STORAGE_TYPE_FILE:
         case VIR_STORAGE_TYPE_BLOCK:
+            /* In case the destination of the storage migration is a block
+             * device it might be possible that for various reasons the size
+             * will not be identical. Since qemu refuses to do a blockdev-mirror
+             * into an image which doesn't have the exact same size we need to
+             * install a slice on top of the top image */
+            if (disk->src->format == VIR_STORAGE_FILE_RAW &&
+                disk->src->sliceStorage == NULL) {
+                qemuDomainObjPrivate *priv = vm->privateData;
+                g_autoptr(virQEMUDriverConfig) cfg = virQEMUDriverGetConfig(priv->driver);
+                qemuDomainDiskPrivate *diskPriv = QEMU_DOMAIN_DISK_PRIVATE(disk);
+
+                if (qemuDomainStorageUpdatePhysical(cfg, vm, disk->src) == 0 &&
+                    disk->src->physical > nbd->disks[i].capacity) {
+                    disk->src->sliceStorage = g_new0(virStorageSourceSlice, 1);
+                    disk->src->sliceStorage->size = nbd->disks[i].capacity;
+                    diskPriv->migrationslice = true;
+                }
+            }
+            G_GNUC_FALLTHROUGH;
+        case VIR_STORAGE_TYPE_FILE:
         case VIR_STORAGE_TYPE_DIR:
             diskSrcPath = virDomainDiskGetSource(disk);
             break;
@@ -478,26 +497,6 @@ qemuMigrationDstPrepareStorage(virDomainObj *vm,
         }
 
         if (diskSrcPath) {
-            /* In case the destination of the storage migration is a block
-             * device it might be possible that for various reasons the size
-             * will not be identical. Since qemu refuses to do a blockdev-mirror
-             * into an image which doesn't have the exact same size we need to
-             * install a slice on top of the top image */
-            if (virStorageSourceIsBlockLocal(disk->src) &&
-                disk->src->format == VIR_STORAGE_FILE_RAW &&
-                disk->src->sliceStorage == NULL) {
-                qemuDomainObjPrivate *priv = vm->privateData;
-                g_autoptr(virQEMUDriverConfig) cfg = virQEMUDriverGetConfig(priv->driver);
-                qemuDomainDiskPrivate *diskPriv = QEMU_DOMAIN_DISK_PRIVATE(disk);
-
-                if (qemuDomainStorageUpdatePhysical(cfg, vm, disk->src) == 0 &&
-                    disk->src->physical > nbd->disks[i].capacity) {
-                    disk->src->sliceStorage = g_new0(virStorageSourceSlice, 1);
-                    disk->src->sliceStorage->size = nbd->disks[i].capacity;
-                    diskPriv->migrationslice = true;
-                }
-            }
-
             /* don't pre-create existing disks */
             if (virFileExists(diskSrcPath)) {
                 VIR_DEBUG("Skipping pre-create of existing source for disk '%s'", disk->dst);