Blame SOURCES/kvm-Revert-migration-move-only_migratable-to-MigrationSt.patch

7711c0
From 99c200d1a05ef50fedcb6b86387af3b60fe54a0e Mon Sep 17 00:00:00 2001
7711c0
From: Markus Armbruster <armbru@redhat.com>
7711c0
Date: Fri, 17 May 2019 06:51:19 +0200
7711c0
Subject: [PATCH 52/53] Revert "migration: move only_migratable to
7711c0
 MigrationState"
7711c0
MIME-Version: 1.0
7711c0
Content-Type: text/plain; charset=UTF-8
7711c0
Content-Transfer-Encoding: 8bit
7711c0
7711c0
RH-Author: Markus Armbruster <armbru@redhat.com>
7711c0
Message-id: <20190517065120.12028-31-armbru@redhat.com>
7711c0
Patchwork-id: 88007
7711c0
O-Subject: [RHEL-7.7 qemu-kvm-rhev PATCH v3 30/31] Revert "migration: move only_migratable to MigrationState"
7711c0
Bugzilla: 1624009
7711c0
RH-Acked-by: Philippe Mathieu-Daudé <philmd@redhat.com>
7711c0
RH-Acked-by: Thomas Huth <thuth@redhat.com>
7711c0
RH-Acked-by: Miroslav Rezanina <mrezanin@redhat.com>
7711c0
7711c0
This reverts commit 3df663e575f1876d7f3bc684f80e72fca0703d39.
7711c0
This reverts commit b605c47b57b58e61a901a50a0762dccf43d94783.
7711c0
7711c0
Command line option --only-migratable is for disallowing any
7711c0
configuration that can block migration.
7711c0
7711c0
Initially, --only-migratable set global variable @only_migratable.
7711c0
7711c0
Commit 3df663e575 "migration: move only_migratable to MigrationState"
7711c0
replaced it by MigrationState member @only_migratable.  That was a
7711c0
mistake.
7711c0
7711c0
First, it doesn't make sense on the design level.  MigrationState
7711c0
captures the state of an individual migration, but --only-migratable
7711c0
isn't a property of an individual migration, it's a restriction on
7711c0
QEMU configuration.  With fault tolerance, we could have several
7711c0
migrations at once.  --only-migratable would certainly protect all of
7711c0
them.  Storing it in MigrationState feels inappropriate.
7711c0
7711c0
Second, it contributes to a dependency cycle that manifests itself as
7711c0
a bug now.
7711c0
7711c0
Putting @only_migratable into MigrationState means its available only
7711c0
after migration_object_init().
7711c0
7711c0
We can't set it before migration_object_init(), so we delay setting it
7711c0
with a global property (this is fixup commit b605c47b57 "migration:
7711c0
fix handling for --only-migratable").
7711c0
7711c0
We can't get it before migration_object_init(), so anything that uses
7711c0
it can only run afterwards.
7711c0
7711c0
Since migrate_add_blocker() needs to obey --only-migratable, any code
7711c0
adding migration blockers can run only afterwards.  This contributes
7711c0
to the following dependency cycle:
7711c0
7711c0
* configure_blockdev() must run before machine_set_property()
7711c0
  so machine properties can refer to block backends
7711c0
7711c0
* machine_set_property() before configure_accelerator()
7711c0
  so machine properties like kvm-irqchip get applied
7711c0
7711c0
* configure_accelerator() before migration_object_init()
7711c0
  so that Xen's accelerator compat properties get applied.
7711c0
7711c0
* migration_object_init() before configure_blockdev()
7711c0
  so configure_blockdev() can add migration blockers
7711c0
7711c0
The cycle was closed when recent commit cda4aa9a5a0 "Create block
7711c0
backends before setting machine properties" added the first
7711c0
dependency, and satisfied it by violating the last one.  Broke block
7711c0
backends that add migration blockers.
7711c0
7711c0
Moving @only_migratable into MigrationState was a mistake.  Revert it.
7711c0
7711c0
This doesn't quite break the "migration_object_init() before
7711c0
configure_blockdev() dependency, since migrate_add_blocker() still has
7711c0
another dependency on migration_object_init().  To be addressed the
7711c0
next commit.
7711c0
7711c0
Note that the reverted commit made -only-migratable sugar for -global
7711c0
migration.only-migratable=on below the hood.  Documentation has only
7711c0
ever mentioned -only-migratable.  This commit removes the arcane &
7711c0
undocumented alternative to -only-migratable again.  Nobody should be
7711c0
using it.
7711c0
7711c0
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
7711c0
7711c0
Conflicts:
7711c0
	include/migration/misc.h
7711c0
	migration/migration.c
7711c0
	migration/migration.h
7711c0
	vl.c
7711c0
7711c0
Signed-off-by: Markus Armbruster <armbru@redhat.com>
7711c0
Message-Id: <20190401090827.20793-3-armbru@redhat.com>
7711c0
Reviewed-by: Igor Mammedov <imammedo@redhat.com>
7711c0
(cherry picked from commit 811f8652712a4ec2ff73c2c5dca35581a25112a4)
7711c0
[Conflicts in migration/migration.c and vl.c because we lack conflicts
7711c0
there]
7711c0
Signed-off-by: Markus Armbruster <armbru@redhat.com>
7711c0
---
7711c0
 include/sysemu/sysemu.h | 1 +
7711c0
 migration/migration.c   | 5 ++---
7711c0
 migration/migration.h   | 3 ---
7711c0
 migration/savevm.c      | 2 +-
7711c0
 vl.c                    | 9 ++-------
7711c0
 5 files changed, 6 insertions(+), 14 deletions(-)
7711c0
7711c0
diff --git a/include/sysemu/sysemu.h b/include/sysemu/sysemu.h
7711c0
index 5d8634b..2a6f4a5 100644
7711c0
--- a/include/sysemu/sysemu.h
7711c0
+++ b/include/sysemu/sysemu.h
7711c0
@@ -14,6 +14,7 @@
7711c0
 /* vl.c */
7711c0
 
7711c0
 extern const char *bios_name;
7711c0
+extern int only_migratable;
7711c0
 extern const char *qemu_name;
7711c0
 extern QemuUUID qemu_uuid;
7711c0
 extern bool qemu_uuid_set;
7711c0
diff --git a/migration/migration.c b/migration/migration.c
7711c0
index edf1c06..83b8d6a 100644
7711c0
--- a/migration/migration.c
7711c0
+++ b/migration/migration.c
7711c0
@@ -1330,7 +1330,7 @@ static GSList *migration_blockers;
7711c0
 
7711c0
 int migrate_add_blocker(Error *reason, Error **errp)
7711c0
 {
7711c0
-    if (migrate_get_current()->only_migratable) {
7711c0
+    if (only_migratable) {
7711c0
         error_propagate(errp, error_copy(reason));
7711c0
         error_prepend(errp, "disallowing migration blocker "
7711c0
                           "(--only_migratable) for: ");
7711c0
@@ -2498,7 +2498,7 @@ void migration_global_dump(Monitor *mon)
7711c0
     monitor_printf(mon, "store-global-state: %s\n",
7711c0
                    ms->store_global_state ? "on" : "off");
7711c0
     monitor_printf(mon, "only-migratable: %s\n",
7711c0
-                   ms->only_migratable ? "on" : "off");
7711c0
+                   only_migratable ? "on" : "off");
7711c0
     monitor_printf(mon, "send-configuration: %s\n",
7711c0
                    ms->send_configuration ? "on" : "off");
7711c0
     monitor_printf(mon, "send-section-footer: %s\n",
7711c0
@@ -2513,7 +2513,6 @@ void migration_global_dump(Monitor *mon)
7711c0
 static Property migration_properties[] = {
7711c0
     DEFINE_PROP_BOOL("store-global-state", MigrationState,
7711c0
                      store_global_state, true),
7711c0
-    DEFINE_PROP_BOOL("only-migratable", MigrationState, only_migratable, false),
7711c0
     DEFINE_PROP_BOOL("send-configuration", MigrationState,
7711c0
                      send_configuration, true),
7711c0
     DEFINE_PROP_BOOL("send-section-footer", MigrationState,
7711c0
diff --git a/migration/migration.h b/migration/migration.h
7711c0
index a9c5c7f..84bdcb7 100644
7711c0
--- a/migration/migration.h
7711c0
+++ b/migration/migration.h
7711c0
@@ -175,9 +175,6 @@ struct MigrationState
7711c0
      */
7711c0
     bool store_global_state;
7711c0
 
7711c0
-    /* Whether the VM is only allowing for migratable devices */
7711c0
-    bool only_migratable;
7711c0
-
7711c0
     /* Whether we send QEMU_VM_CONFIGURATION during migration */
7711c0
     bool send_configuration;
7711c0
     /* Whether we send section footer during migration */
7711c0
diff --git a/migration/savevm.c b/migration/savevm.c
7711c0
index e5d57fa..6c398d1 100644
7711c0
--- a/migration/savevm.c
7711c0
+++ b/migration/savevm.c
7711c0
@@ -2530,7 +2530,7 @@ void vmstate_register_ram_global(MemoryRegion *mr)
7711c0
 bool vmstate_check_only_migratable(const VMStateDescription *vmsd)
7711c0
 {
7711c0
     /* check needed if --only-migratable is specified */
7711c0
-    if (!migrate_get_current()->only_migratable) {
7711c0
+    if (!only_migratable) {
7711c0
         return true;
7711c0
     }
7711c0
 
7711c0
diff --git a/vl.c b/vl.c
7711c0
index 15e87a4..61247eb 100644
7711c0
--- a/vl.c
7711c0
+++ b/vl.c
7711c0
@@ -192,6 +192,7 @@ bool boot_strict;
7711c0
 uint8_t *boot_splash_filedata;
7711c0
 size_t boot_splash_filedata_size;
7711c0
 uint8_t qemu_extra_params_fw[2];
7711c0
+int only_migratable; /* turn it off unless user states otherwise */
7711c0
 
7711c0
 int icount_align_option;
7711c0
 
7711c0
@@ -3994,13 +3995,7 @@ int main(int argc, char **argv, char **envp)
7711c0
                 incoming = optarg;
7711c0
                 break;
7711c0
             case QEMU_OPTION_only_migratable:
7711c0
-                /*
7711c0
-                 * TODO: we can remove this option one day, and we
7711c0
-                 * should all use:
7711c0
-                 *
7711c0
-                 * "-global migration.only-migratable=true"
7711c0
-                 */
7711c0
-                qemu_global_option("migration.only-migratable=true");
7711c0
+                only_migratable = 1;
7711c0
                 break;
7711c0
             case QEMU_OPTION_nodefaults:
7711c0
                 has_defaults = 0;
7711c0
-- 
7711c0
1.8.3.1
7711c0