All of lore.kernel.org
 help / color / mirror / Atom feed
From: Peter Xu <peterx@redhat.com>
To: qemu-devel@nongnu.org
Cc: Eduardo Habkost <ehabkost@redhat.com>,
	Laurent Vivier <lvivier@redhat.com>,
	Eric Blake <eblake@redhat.com>,
	Markus Armbruster <armbru@redhat.com>,
	Juan Quintela <quintela@redhat.com>,
	"Dr . David Alan Gilbert" <dgilbert@redhat.com>,
	peterx@redhat.com
Subject: [Qemu-devel] [PATCH v6 05/10] migration: move global_state.optional out
Date: Tue, 27 Jun 2017 12:10:14 +0800	[thread overview]
Message-ID: <1498536619-14548-6-git-send-email-peterx@redhat.com> (raw)
In-Reply-To: <1498536619-14548-1-git-send-email-peterx@redhat.com>

Put it into MigrationState then we can use the properties to specify
whether to enable storing global state.

Removing global_state_set_optional() since now we can use HW_COMPAT_2_3
for x86/power, and AccelClass.global_props for Xen.

Reviewed-by: Juan Quintela <quintela@redhat.com>
Signed-off-by: Peter Xu <peterx@redhat.com>
---
 hw/i386/pc_piix.c                |  1 -
 hw/ppc/spapr.c                   |  1 -
 hw/xen/xen-common.c              | 11 ++++++++++-
 include/hw/compat.h              |  4 ++++
 include/migration/global_state.h |  1 -
 migration/global_state.c         |  9 ++-------
 migration/migration.c            |  7 +++++++
 migration/migration.h            |  6 ++++++
 8 files changed, 29 insertions(+), 11 deletions(-)

diff --git a/hw/i386/pc_piix.c b/hw/i386/pc_piix.c
index 46a2bc4..3b51297 100644
--- a/hw/i386/pc_piix.c
+++ b/hw/i386/pc_piix.c
@@ -318,7 +318,6 @@ static void pc_compat_2_3(MachineState *machine)
     if (kvm_enabled()) {
         pcms->smm = ON_OFF_AUTO_OFF;
     }
-    global_state_set_optional();
     savevm_skip_configuration();
 }
 
diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c
index ede5167..f07d40a 100644
--- a/hw/ppc/spapr.c
+++ b/hw/ppc/spapr.c
@@ -3581,7 +3581,6 @@ static void spapr_machine_2_3_instance_options(MachineState *machine)
 {
     spapr_machine_2_4_instance_options(machine);
     savevm_skip_section_footers();
-    global_state_set_optional();
     savevm_skip_configuration();
 }
 
diff --git a/hw/xen/xen-common.c b/hw/xen/xen-common.c
index d3fa705..459e6ab 100644
--- a/hw/xen/xen-common.c
+++ b/hw/xen/xen-common.c
@@ -139,19 +139,28 @@ static int xen_init(MachineState *ms)
     }
     qemu_add_vm_change_state_handler(xen_change_state_handler, NULL);
 
-    global_state_set_optional();
     savevm_skip_configuration();
     savevm_skip_section_footers();
 
     return 0;
 }
 
+static GlobalProperty xen_compat_props[] = {
+    {
+        .driver = "migration",
+        .property = "store-global-state",
+        .value = "off",
+    },
+    { /* end of list */ },
+};
+
 static void xen_accel_class_init(ObjectClass *oc, void *data)
 {
     AccelClass *ac = ACCEL_CLASS(oc);
     ac->name = "Xen";
     ac->init_machine = xen_init;
     ac->allowed = &xen_allowed;
+    ac->global_props = xen_compat_props;
 }
 
 #define TYPE_XEN_ACCEL ACCEL_CLASS_NAME("xen")
diff --git a/include/hw/compat.h b/include/hw/compat.h
index 26cd585..a506a74 100644
--- a/include/hw/compat.h
+++ b/include/hw/compat.h
@@ -181,6 +181,10 @@
         .driver   = TYPE_PCI_DEVICE,\
         .property = "x-pcie-lnksta-dllla",\
         .value    = "off",\
+    },{\
+        .driver   = "migration",\
+        .property = "store-global-state",\
+        .value    = "off",\
     },
 
 #define HW_COMPAT_2_2 \
diff --git a/include/migration/global_state.h b/include/migration/global_state.h
index 90faea7..d307de8 100644
--- a/include/migration/global_state.h
+++ b/include/migration/global_state.h
@@ -16,7 +16,6 @@
 #include "sysemu/sysemu.h"
 
 void register_global_state(void);
-void global_state_set_optional(void);
 int global_state_store(void);
 void global_state_store_running(void);
 bool global_state_received(void);
diff --git a/migration/global_state.c b/migration/global_state.c
index f792cf5..dcbbcb2 100644
--- a/migration/global_state.c
+++ b/migration/global_state.c
@@ -15,12 +15,12 @@
 #include "qemu/error-report.h"
 #include "qapi/error.h"
 #include "qapi/util.h"
+#include "migration.h"
 #include "migration/global_state.h"
 #include "migration/vmstate.h"
 #include "trace.h"
 
 typedef struct {
-    bool optional;
     uint32_t size;
     uint8_t runstate[100];
     RunState state;
@@ -57,11 +57,6 @@ RunState global_state_get_runstate(void)
     return global_state.state;
 }
 
-void global_state_set_optional(void)
-{
-    global_state.optional = true;
-}
-
 static bool global_state_needed(void *opaque)
 {
     GlobalState *s = opaque;
@@ -69,7 +64,7 @@ static bool global_state_needed(void *opaque)
 
     /* If it is not optional, it is mandatory */
 
-    if (s->optional == false) {
+    if (migrate_get_current()->store_global_state) {
         return true;
     }
 
diff --git a/migration/migration.c b/migration/migration.c
index 2c25927..221b22c 100644
--- a/migration/migration.c
+++ b/migration/migration.c
@@ -1976,11 +1976,18 @@ void migrate_fd_connect(MigrationState *s)
     s->migration_thread_running = true;
 }
 
+static Property migration_properties[] = {
+    DEFINE_PROP_BOOL("store-global-state", MigrationState,
+                     store_global_state, true),
+    DEFINE_PROP_END_OF_LIST(),
+};
+
 static void migration_class_init(ObjectClass *klass, void *data)
 {
     DeviceClass *dc = DEVICE_CLASS(klass);
 
     dc->user_creatable = false;
+    dc->props = migration_properties;
 }
 
 static void migration_instance_init(Object *obj)
diff --git a/migration/migration.h b/migration/migration.h
index 3fca364..4b898e9 100644
--- a/migration/migration.h
+++ b/migration/migration.h
@@ -133,6 +133,12 @@ struct MigrationState
     /* Do we have to clean up -b/-i from old migrate parameters */
     /* This feature is deprecated and will be removed */
     bool must_remove_block_options;
+
+    /*
+     * Global switch on whether we need to store the global state
+     * during migration.
+     */
+    bool store_global_state;
 };
 
 void migrate_set_state(int *state, int old_state, int new_state);
-- 
2.7.4

  parent reply	other threads:[~2017-06-27  4:10 UTC|newest]

Thread overview: 46+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-06-27  4:10 [Qemu-devel] [PATCH v6 00/10] migration: objectify MigrationState Peter Xu
2017-06-27  4:10 ` [Qemu-devel] [PATCH v6 01/10] machine: export register_compat_prop() Peter Xu
2017-06-27 14:55   ` Eduardo Habkost
2017-06-27 15:05     ` Eric Blake
2017-06-28  6:57       ` Peter Xu
2017-06-27  4:10 ` [Qemu-devel] [PATCH v6 02/10] accel: introduce AccelClass.global_props Peter Xu
2017-06-27 14:55   ` Eduardo Habkost
2017-06-27  4:10 ` [Qemu-devel] [PATCH v6 03/10] vl: clean up global property registerations Peter Xu
2017-06-27 14:56   ` Eduardo Habkost
2017-06-27  4:10 ` [Qemu-devel] [PATCH v6 04/10] migration: let MigrationState be a qdev Peter Xu
2017-06-27 14:47   ` Eduardo Habkost
2017-06-28  7:01     ` Peter Xu
2017-06-27 14:59   ` Eduardo Habkost
2017-06-30  2:18   ` Max Reitz
2017-06-30  3:03     ` Peter Xu
2017-06-30  7:11       ` Peter Xu
2017-06-30 12:33         ` Max Reitz
2017-06-30 13:05           ` Eric Blake
2017-06-30 13:57             ` Max Reitz
2017-07-03  1:52               ` Peter Xu
2017-06-27  4:10 ` Peter Xu [this message]
2017-06-28 18:43   ` [Qemu-devel] [PATCH v6 05/10] migration: move global_state.optional out Eduardo Habkost
2017-06-27  4:10 ` [Qemu-devel] [PATCH v6 06/10] migration: move only_migratable to MigrationState Peter Xu
2017-06-27 11:15   ` Eric Blake
2017-06-27 13:36     ` Eduardo Habkost
2017-06-28  6:54       ` Peter Xu
2017-06-28 17:46         ` Eduardo Habkost
2017-06-28 19:13   ` Eduardo Habkost
2017-06-29  2:33     ` Peter Xu
2017-06-27  4:10 ` [Qemu-devel] [PATCH v6 07/10] migration: move skip_configuration out Peter Xu
2017-06-28 18:44   ` Eduardo Habkost
2017-06-27  4:10 ` [Qemu-devel] [PATCH v6 08/10] migration: move skip_section_footers Peter Xu
2017-06-28 18:45   ` Eduardo Habkost
2017-06-27  4:10 ` [Qemu-devel] [PATCH v6 09/10] migration: merge enforce_config_section somewhat Peter Xu
2017-06-28 19:06   ` Eduardo Habkost
2017-06-28 22:42     ` Juan Quintela
2017-06-29  3:00       ` Peter Xu
2017-06-29 19:18         ` Eduardo Habkost
2017-06-30  6:10           ` Peter Xu
2017-06-27  4:10 ` [Qemu-devel] [PATCH v6 10/10] migration: hmp: dump globals Peter Xu
2017-06-28 17:12   ` Eduardo Habkost
2017-06-30  6:22     ` Peter Xu
2017-06-28  7:15 ` [Qemu-devel] [PATCH v6 11/10] migration: add comment for TYPE_MIGRATE Peter Xu
2017-06-28  7:37   ` Juan Quintela
2017-06-28 15:37   ` Eduardo Habkost
2017-06-29  3:08     ` Peter Xu

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1498536619-14548-6-git-send-email-peterx@redhat.com \
    --to=peterx@redhat.com \
    --cc=armbru@redhat.com \
    --cc=dgilbert@redhat.com \
    --cc=eblake@redhat.com \
    --cc=ehabkost@redhat.com \
    --cc=lvivier@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=quintela@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.