[RFC PATCH 5/7] qemuMigrationSrcRun: Sanitize setting of cookieFlags and migrate_flags on storage migration

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

 



Base the decision on the main API flags (VIR_MIGRATE_NON_SHARED_DISK,
QEMU_MONITOR_MIGRATE_NON_SHARED_INC) via a boolean 'storageMigration'
rather than juggling everything trhough 'migration_flags'.

After this patch 'migration_flags' is updated to contain the legacy
storage migration flags only when we'll be about to use it rather than
setting it and then resetting it.

Signed-off-by: Peter Krempa <pkrempa@xxxxxxxxxx>
---
 src/qemu/qemu_migration.c | 30 +++++++++++++-----------------
 1 file changed, 13 insertions(+), 17 deletions(-)

diff --git a/src/qemu/qemu_migration.c b/src/qemu/qemu_migration.c
index 99b278e218..9ea008836c 100644
--- a/src/qemu/qemu_migration.c
+++ b/src/qemu/qemu_migration.c
@@ -3995,6 +3995,7 @@ qemuMigrationSrcRun(virQEMUDriver *driver,
     bool abort_on_error = !!(flags & VIR_MIGRATE_ABORT_ON_ERROR);
     bool events = virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_MIGRATION_EVENT);
     bool bwParam = virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_MIGRATION_PARAM_BANDWIDTH);
+    bool storageMigration = flags & (VIR_MIGRATE_NON_SHARED_DISK | QEMU_MONITOR_MIGRATE_NON_SHARED_INC);
     bool cancel = false;
     unsigned int waitFlags;
     g_autoptr(virDomainDef) persistDef = NULL;
@@ -4010,20 +4011,14 @@ qemuMigrationSrcRun(virQEMUDriver *driver,
               spec, spec->destType, spec->fwdType, dconn,
               NULLSTR(graphicsuri), nmigrate_disks, migrate_disks);

-    if (flags & VIR_MIGRATE_NON_SHARED_DISK) {
-        migrate_flags |= QEMU_MONITOR_MIGRATE_NON_SHARED_DISK;
+    if (storageMigration) {
         cookieFlags |= QEMU_MIGRATION_COOKIE_NBD;
-    }

-    if (flags & VIR_MIGRATE_NON_SHARED_INC) {
-        migrate_flags |= QEMU_MONITOR_MIGRATE_NON_SHARED_INC;
-        cookieFlags |= QEMU_MIGRATION_COOKIE_NBD;
+        if (virQEMUCapsGet(priv->qemuCaps,
+                           QEMU_CAPS_MIGRATION_PARAM_BLOCK_BITMAP_MAPPING))
+            cookieFlags |= QEMU_MIGRATION_COOKIE_BLOCK_DIRTY_BITMAPS;
     }

-    if (cookieFlags & QEMU_MIGRATION_COOKIE_NBD &&
-        virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_MIGRATION_PARAM_BLOCK_BITMAP_MAPPING))
-        cookieFlags |= QEMU_MIGRATION_COOKIE_BLOCK_DIRTY_BITMAPS;
-
     if (virLockManagerPluginUsesState(driver->lockManager) &&
         !cookieout) {
         virReportError(VIR_ERR_INTERNAL_ERROR,
@@ -4100,8 +4095,8 @@ qemuMigrationSrcRun(virQEMUDriver *driver,
                                  migParams) < 0)
         goto error;

-    if (migrate_flags & (QEMU_MONITOR_MIGRATE_NON_SHARED_DISK |
-                         QEMU_MONITOR_MIGRATE_NON_SHARED_INC)) {
+
+    if (storageMigration) {
         if (mig->nbd) {
             const char *host = "";

@@ -4130,16 +4125,17 @@ qemuMigrationSrcRun(virQEMUDriver *driver,
                                                nbdURI, flags) < 0) {
                 goto error;
             }
-
-            /* mask out the legacy migration flags if we are using NBD */
-            migrate_flags &= ~(QEMU_MONITOR_MIGRATE_NON_SHARED_DISK |
-                               QEMU_MONITOR_MIGRATE_NON_SHARED_INC);
-
         } else {
             /* Destination doesn't support NBD server.
              * Fall back to previous implementation. */
             VIR_DEBUG("Destination doesn't support NBD server "
                       "Falling back to previous implementation.");
+
+            if (flags & VIR_MIGRATE_NON_SHARED_DISK)
+                migrate_flags |= QEMU_MONITOR_MIGRATE_NON_SHARED_DISK;
+
+            if (flags & VIR_MIGRATE_NON_SHARED_INC)
+                migrate_flags |= QEMU_MONITOR_MIGRATE_NON_SHARED_INC;
         }
     }

-- 
2.30.2




[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