Blame SOURCES/libvirt-qemu-don-t-try-to-query-QEMU-about-migration-blockers-during-offline-migration.patch

a1c947
From 80ac99d0f947f5e2fe4ff7fe9fb63b6dc6cbc1bb Mon Sep 17 00:00:00 2001
a1c947
Message-Id: <80ac99d0f947f5e2fe4ff7fe9fb63b6dc6cbc1bb@dist-git>
a1c947
From: Laine Stump <laine@redhat.com>
a1c947
Date: Thu, 21 Jul 2022 01:56:11 -0400
a1c947
Subject: [PATCH] qemu: don't try to query QEMU about migration blockers during
a1c947
 offline migration
a1c947
MIME-Version: 1.0
a1c947
Content-Type: text/plain; charset=UTF-8
a1c947
Content-Transfer-Encoding: 8bit
a1c947
a1c947
The new code that queries QEMU about migration blockers was put at the
a1c947
top of qemuMigrationSrcIsAllowed(), but that function can also be
a1c947
called in the case of offline migration (ie when the domain is
a1c947
inactive / QEMU isn't running). This check should have been put inside
a1c947
the "if (!(flags & VIR_MIGRATE_OFFLINE))" conditional, so let's move
a1c947
it there.
a1c947
a1c947
Fixes: 156e99f686690855be4e45d9b8b3194191a8bc31
a1c947
Signed-off-by: Laine Stump <laine@redhat.com>
a1c947
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
a1c947
(cherry picked from commit 2dd5587f1dc8e2cf4e6e0a4e4cf576b8183b33cd)
a1c947
Resolves: https://bugzilla.redhat.com/2092833
a1c947
Signed-off-by: Eugenio PĂ©rez <eperezma@redhat.com>
a1c947
---
a1c947
 src/qemu/qemu_migration.c | 39 +++++++++++++++++++++------------------
a1c947
 1 file changed, 21 insertions(+), 18 deletions(-)
a1c947
a1c947
diff --git a/src/qemu/qemu_migration.c b/src/qemu/qemu_migration.c
a1c947
index 735eb02673..96c4c0f1da 100644
a1c947
--- a/src/qemu/qemu_migration.c
a1c947
+++ b/src/qemu/qemu_migration.c
a1c947
@@ -1458,24 +1458,6 @@ qemuMigrationSrcIsAllowed(virQEMUDriver *driver,
a1c947
     int nsnapshots;
a1c947
     int pauseReason;
a1c947
     size_t i;
a1c947
-    bool blockedReasonsCap = virQEMUCapsGet(priv->qemuCaps,
a1c947
-                                            QEMU_CAPS_MIGRATION_BLOCKED_REASONS);
a1c947
-
a1c947
-    /* Ask qemu if it has a migration blocker */
a1c947
-    if (blockedReasonsCap) {
a1c947
-        g_auto(GStrv) blockers = NULL;
a1c947
-        if (qemuDomainGetMigrationBlockers(driver, vm,
a1c947
-                                           VIR_ASYNC_JOB_MIGRATION_OUT,
a1c947
-                                           &blockers) < 0)
a1c947
-            return false;
a1c947
-
a1c947
-        if (blockers && blockers[0]) {
a1c947
-            g_autofree char *reasons = g_strjoinv("; ", blockers);
a1c947
-            virReportError(VIR_ERR_OPERATION_INVALID,
a1c947
-                           _("cannot migrate domain: %s"), reasons);
a1c947
-            return false;
a1c947
-        }
a1c947
-    }
a1c947
 
a1c947
     /* perform these checks only when migrating to remote hosts */
a1c947
     if (remote) {
a1c947
@@ -1493,6 +1475,27 @@ qemuMigrationSrcIsAllowed(virQEMUDriver *driver,
a1c947
 
a1c947
     /* following checks don't make sense for offline migration */
a1c947
     if (!(flags & VIR_MIGRATE_OFFLINE)) {
a1c947
+        bool blockedReasonsCap = virQEMUCapsGet(priv->qemuCaps,
a1c947
+                                                QEMU_CAPS_MIGRATION_BLOCKED_REASONS);
a1c947
+
a1c947
+        /* Ask qemu if it has a migration blocker */
a1c947
+        if (blockedReasonsCap) {
a1c947
+            g_auto(GStrv) blockers = NULL;
a1c947
+
a1c947
+            if (qemuDomainGetMigrationBlockers(driver, vm,
a1c947
+                                               VIR_ASYNC_JOB_MIGRATION_OUT,
a1c947
+                                               &blockers) < 0) {
a1c947
+                return false;
a1c947
+            }
a1c947
+
a1c947
+            if (blockers && blockers[0]) {
a1c947
+                g_autofree char *reasons = g_strjoinv("; ", blockers);
a1c947
+                virReportError(VIR_ERR_OPERATION_INVALID,
a1c947
+                               _("cannot migrate domain: %s"), reasons);
a1c947
+                return false;
a1c947
+            }
a1c947
+        }
a1c947
+
a1c947
         if (remote) {
a1c947
             /* cancel migration if disk I/O error is emitted while migrating */
a1c947
             if (flags & VIR_MIGRATE_ABORT_ON_ERROR &&
a1c947
-- 
a1c947
2.35.1
a1c947