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

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