thebeanogamer / rpms / qemu-kvm

Forked from rpms/qemu-kvm 5 months ago
Clone
77609c
From 58d47d795b91beb1f87929fb07d9f1b4af79cb14 Mon Sep 17 00:00:00 2001
77609c
From: Peter Xu <peterx@redhat.com>
77609c
Date: Wed, 22 Sep 2021 12:20:08 -0400
77609c
Subject: [PATCH 2/6] migration: Add migrate_add_blocker_internal()
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: [2/3] 44cf3879ee66cc9974dd3d8a5f9a0d4f762b7c01 (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
An internal version that removes -only-migratable implications.  It can be used
77609c
for temporary migration blockers like dump-guest-memory.
77609c
77609c
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
77609c
Reviewed-by: Juan Quintela <quintela@redhat.com>
77609c
Signed-off-by: Peter Xu <peterx@redhat.com>
77609c
Signed-off-by: Juan Quintela <quintela@redhat.com>
77609c
(cherry picked from commit 60fd680193119e7e4d50eccff7b55a0aadc934ab)
77609c
Signed-off-by: Peter Xu <peterx@redhat.com>
77609c
---
77609c
 include/migration/blocker.h | 16 ++++++++++++++++
77609c
 migration/migration.c       | 21 +++++++++++++--------
77609c
 2 files changed, 29 insertions(+), 8 deletions(-)
77609c
77609c
diff --git a/include/migration/blocker.h b/include/migration/blocker.h
77609c
index acd27018e9..9cebe2ba06 100644
77609c
--- a/include/migration/blocker.h
77609c
+++ b/include/migration/blocker.h
77609c
@@ -25,6 +25,22 @@
77609c
  */
77609c
 int migrate_add_blocker(Error *reason, Error **errp);
77609c
 
77609c
+/**
77609c
+ * @migrate_add_blocker_internal - prevent migration from proceeding without
77609c
+ *                                 only-migrate implications
77609c
+ *
77609c
+ * @reason - an error to be returned whenever migration is attempted
77609c
+ *
77609c
+ * @errp - [out] The reason (if any) we cannot block migration right now.
77609c
+ *
77609c
+ * @returns - 0 on success, -EBUSY on failure, with errp set.
77609c
+ *
77609c
+ * Some of the migration blockers can be temporary (e.g., for a few seconds),
77609c
+ * so it shouldn't need to conflict with "-only-migratable".  For those cases,
77609c
+ * we can call this function rather than @migrate_add_blocker().
77609c
+ */
77609c
+int migrate_add_blocker_internal(Error *reason, Error **errp);
77609c
+
77609c
 /**
77609c
  * @migrate_del_blocker - remove a blocking error from migration
77609c
  *
77609c
diff --git a/migration/migration.c b/migration/migration.c
77609c
index f476e2101e..2aaf2fd449 100644
77609c
--- a/migration/migration.c
77609c
+++ b/migration/migration.c
77609c
@@ -2053,15 +2053,8 @@ void migrate_init(MigrationState *s)
77609c
     s->threshold_size = 0;
77609c
 }
77609c
 
77609c
-int migrate_add_blocker(Error *reason, Error **errp)
77609c
+int migrate_add_blocker_internal(Error *reason, Error **errp)
77609c
 {
77609c
-    if (only_migratable) {
77609c
-        error_propagate_prepend(errp, error_copy(reason),
77609c
-                                "disallowing migration blocker "
77609c
-                                "(--only-migratable) for: ");
77609c
-        return -EACCES;
77609c
-    }
77609c
-
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
@@ -2074,6 +2067,18 @@ int migrate_add_blocker(Error *reason, Error **errp)
77609c
     return 0;
77609c
 }
77609c
 
77609c
+int migrate_add_blocker(Error *reason, Error **errp)
77609c
+{
77609c
+    if (only_migratable) {
77609c
+        error_propagate_prepend(errp, error_copy(reason),
77609c
+                                "disallowing migration blocker "
77609c
+                                "(--only-migratable) for: ");
77609c
+        return -EACCES;
77609c
+    }
77609c
+
77609c
+    return migrate_add_blocker_internal(reason, errp);
77609c
+}
77609c
+
77609c
 void migrate_del_blocker(Error *reason)
77609c
 {
77609c
     migration_blockers = g_slist_remove(migration_blockers, reason);
77609c
-- 
77609c
2.27.0
77609c