Blame SOURCES/kvm-migration-Make-migration-blocker-work-for-snapshots-.patch

77609c
From 0a9b55b44c5c548ff6f3da7335acf2138ecb4376 Mon Sep 17 00:00:00 2001
77609c
From: Peter Xu <peterx@redhat.com>
77609c
Date: Wed, 22 Sep 2021 12:20:07 -0400
77609c
Subject: [PATCH 1/6] migration: Make migration blocker work for snapshots too
77609c
MIME-Version: 1.0
77609c
Content-Type: text/plain; charset=UTF-8
77609c
Content-Transfer-Encoding: 8bit
77609c
77609c
RH-Author: Peter Xu <peterx@redhat.com>
77609c
RH-MergeRequest: 51: dump-guest-memory: Add blocker for migration
77609c
RH-Commit: [1/3] 241888d12c7197dd4ee1e1ba6e3115f70901636e (peterx/qemu-kvm)
77609c
RH-Bugzilla: 1996609
77609c
RH-Acked-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
77609c
RH-Acked-by: quintela1 <quintela@redhat.com>
77609c
RH-Acked-by: Laszlo Ersek <lersek@redhat.com>
77609c
77609c
save_snapshot() checks migration blocker, which looks sane.  At the meantime we
77609c
should also teach the blocker add helper to fail if during a snapshot, just
77609c
like for migrations.
77609c
77609c
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
77609c
Signed-off-by: Peter Xu <peterx@redhat.com>
77609c
Reviewed-by: Juan Quintela <quintela@redhat.com>
77609c
Signed-off-by: Juan Quintela <quintela@redhat.com>
77609c
(cherry picked from commit 4c170330aae4a4ed75c3a8638b7d4c5d9f365244)
77609c
Signed-off-by: Peter Xu <peterx@redhat.com>
77609c
---
77609c
 migration/migration.c | 15 ++++++++-------
77609c
 1 file changed, 8 insertions(+), 7 deletions(-)
77609c
77609c
diff --git a/migration/migration.c b/migration/migration.c
77609c
index 041b8451a6..f476e2101e 100644
77609c
--- a/migration/migration.c
77609c
+++ b/migration/migration.c
77609c
@@ -2062,15 +2062,16 @@ int migrate_add_blocker(Error *reason, Error **errp)
77609c
         return -EACCES;
77609c
     }
77609c
 
77609c
-    if (migration_is_idle()) {
77609c
-        migration_blockers = g_slist_prepend(migration_blockers, reason);
77609c
-        return 0;
77609c
+    /* Snapshots are similar to migrations, so check RUN_STATE_SAVE_VM too. */
77609c
+    if (runstate_check(RUN_STATE_SAVE_VM) || !migration_is_idle()) {
77609c
+        error_propagate_prepend(errp, error_copy(reason),
77609c
+                                "disallowing migration blocker "
77609c
+                                "(migration/snapshot in progress) for: ");
77609c
+        return -EBUSY;
77609c
     }
77609c
 
77609c
-    error_propagate_prepend(errp, error_copy(reason),
77609c
-                            "disallowing migration blocker "
77609c
-                            "(migration in progress) for: ");
77609c
-    return -EBUSY;
77609c
+    migration_blockers = g_slist_prepend(migration_blockers, reason);
77609c
+    return 0;
77609c
 }
77609c
 
77609c
 void migrate_del_blocker(Error *reason)
77609c
-- 
77609c
2.27.0
77609c