render / rpms / libvirt

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