032100
From 2a05454cd2d6ba283c128158f44d84d65832ebf7 Mon Sep 17 00:00:00 2001
032100
Message-Id: <2a05454cd2d6ba283c128158f44d84d65832ebf7@dist-git>
032100
From: Jiri Denemark <jdenemar@redhat.com>
032100
Date: Thu, 21 Jul 2022 16:49:09 +0200
032100
Subject: [PATCH] qemu_migration_params: Refactor qemuMigrationParamsReset
032100
032100
Because qemuMigrationParamsReset used to call qemuMigrationParamsApply
032100
for resetting migration capabilities and parameters, it did not work
032100
well since commit v5.1.0-83-ga1dec315c9 which only allowed capabilities
032100
to be set from an async job. However, when reconnecting to running
032100
domains after daemon restart we do not have an async job. Thus the
032100
capabilities were not properly reset in case the daemon was restarted
032100
during an ongoing migration. We need to avoid calling
032100
qemuMigrationParamsApply to make sure both parameters and capabilities
032100
can be reset by a normal job.
032100
032100
https://bugzilla.redhat.com/show_bug.cgi?id=2107892
032100
032100
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
032100
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
032100
(cherry picked from commit c47f1abb81194461377a0c608a7ecd87f9ce9146)
032100
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
032100
---
032100
 src/qemu/qemu_migration_params.c | 14 +++++++++-----
032100
 1 file changed, 9 insertions(+), 5 deletions(-)
032100
032100
diff --git a/src/qemu/qemu_migration_params.c b/src/qemu/qemu_migration_params.c
032100
index 7b9e5453f6..4a824ff5e1 100644
032100
--- a/src/qemu/qemu_migration_params.c
032100
+++ b/src/qemu/qemu_migration_params.c
032100
@@ -1290,6 +1290,7 @@ qemuMigrationParamsReset(virQEMUDriver *driver,
032100
                          unsigned long apiFlags)
032100
 {
032100
     virErrorPtr err;
032100
+    g_autoptr(virBitmap) clearCaps = NULL;
032100
 
032100
     virErrorPreserveLast(&err;;
032100
 
032100
@@ -1299,13 +1300,16 @@ qemuMigrationParamsReset(virQEMUDriver *driver,
032100
     if (!virDomainObjIsActive(vm) || !origParams)
032100
         goto cleanup;
032100
 
032100
-    /* Do not pass apiFlags to qemuMigrationParamsApply here to make sure all
032100
-     * parameters and capabilities are reset. */
032100
-    if (qemuMigrationParamsApply(driver, vm, asyncJob, origParams, 0) < 0)
032100
+    if (qemuDomainObjEnterMonitorAsync(driver, vm, asyncJob) < 0)
032100
         goto cleanup;
032100
 
032100
-    qemuMigrationParamsResetTLS(driver, vm, asyncJob, origParams, apiFlags);
032100
-    /* We don't reset 'block-bitmap-mapping' as it can't be unset */
032100
+    clearCaps = virBitmapNew(0);
032100
+
032100
+    if (qemuMigrationParamsApplyCaps(vm, clearCaps) == 0 &&
032100
+        qemuMigrationParamsApplyValues(vm, origParams, false) == 0)
032100
+        qemuMigrationParamsResetTLS(driver, vm, asyncJob, origParams, apiFlags);
032100
+
032100
+    qemuDomainObjExitMonitor(vm);
032100
 
032100
  cleanup:
032100
     virErrorRestore(&err;;
032100
-- 
032100
2.35.1
032100