]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
qemu: don't try to query QEMU about migration blockers during offline migration
authorLaine Stump <laine@redhat.com>
Thu, 21 Jul 2022 05:56:11 +0000 (01:56 -0400)
committerLaine Stump <laine@redhat.com>
Thu, 21 Jul 2022 15:12:44 +0000 (11:12 -0400)
The new code that queries QEMU about migration blockers was put at the
top of qemuMigrationSrcIsAllowed(), but that function can also be
called in the case of offline migration (ie when the domain is
inactive / QEMU isn't running). This check should have been put inside
the "if (!(flags & VIR_MIGRATE_OFFLINE))" conditional, so let's move
it there.

Fixes: 156e99f686690855be4e45d9b8b3194191a8bc31
Signed-off-by: Laine Stump <laine@redhat.com>
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
src/qemu/qemu_migration.c

index d83db3a824407de1291162096eeea3da99c069b9..b470c69816e4e5a771de65ed14120da1446b4bad 100644 (file)
@@ -1458,24 +1458,6 @@ qemuMigrationSrcIsAllowed(virQEMUDriver *driver,
     int nsnapshots;
     int pauseReason;
     size_t i;
-    bool blockedReasonsCap = virQEMUCapsGet(priv->qemuCaps,
-                                            QEMU_CAPS_MIGRATION_BLOCKED_REASONS);
-
-    /* Ask qemu if it has a migration blocker */
-    if (blockedReasonsCap) {
-        g_auto(GStrv) blockers = NULL;
-        if (qemuDomainGetMigrationBlockers(driver, vm,
-                                           VIR_ASYNC_JOB_MIGRATION_OUT,
-                                           &blockers) < 0)
-            return false;
-
-        if (blockers && blockers[0]) {
-            g_autofree char *reasons = g_strjoinv("; ", blockers);
-            virReportError(VIR_ERR_OPERATION_INVALID,
-                           _("cannot migrate domain: %s"), reasons);
-            return false;
-        }
-    }
 
     /* perform these checks only when migrating to remote hosts */
     if (remote) {
@@ -1493,6 +1475,27 @@ qemuMigrationSrcIsAllowed(virQEMUDriver *driver,
 
     /* following checks don't make sense for offline migration */
     if (!(flags & VIR_MIGRATE_OFFLINE)) {
+        bool blockedReasonsCap = virQEMUCapsGet(priv->qemuCaps,
+                                                QEMU_CAPS_MIGRATION_BLOCKED_REASONS);
+
+        /* Ask qemu if it has a migration blocker */
+        if (blockedReasonsCap) {
+            g_auto(GStrv) blockers = NULL;
+
+            if (qemuDomainGetMigrationBlockers(driver, vm,
+                                               VIR_ASYNC_JOB_MIGRATION_OUT,
+                                               &blockers) < 0) {
+                return false;
+            }
+
+            if (blockers && blockers[0]) {
+                g_autofree char *reasons = g_strjoinv("; ", blockers);
+                virReportError(VIR_ERR_OPERATION_INVALID,
+                               _("cannot migrate domain: %s"), reasons);
+                return false;
+            }
+        }
+
         if (remote) {
             /* cancel migration if disk I/O error is emitted while migrating */
             if (flags & VIR_MIGRATE_ABORT_ON_ERROR &&