[PATCH 4/8] qemuMigrationDstPrepareStorage: Move block device specific logic

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxxx>
---
 src/qemu/qemu_migration.c | 41 +++++++++++++++++++--------------------
 1 file changed, 20 insertions(+), 21 deletions(-)

diff --git a/src/qemu/qemu_migration.c b/src/qemu/qemu_migration.c
index 32569ecbb4..2ac10ab5ff 100644
--- a/src/qemu/qemu_migration.c
+++ b/src/qemu/qemu_migration.c
@@ -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);
-- 
2.43.0
_______________________________________________
Devel mailing list -- devel@xxxxxxxxxxxxxxxxx
To unsubscribe send an email to devel-leave@xxxxxxxxxxxxxxxxx




[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]

  Powered by Linux