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 v3 11/13] migration: move only_migratable to MigrationState
Date: Mon, 19 Jun 2017 20:49:46 +0800 [thread overview]
Message-ID: <1497876588-947-12-git-send-email-peterx@redhat.com> (raw)
In-Reply-To: <1497876588-947-1-git-send-email-peterx@redhat.com>
One less global variable, and it does only matter with migration.
We keep the old "--only-migratable" option, but also now we support:
-global migration.only-migratable=true
Currently still keep the old interface.
Hmm, now vl.c has no way to access migrate_get_current(). Export a
function for it to setup only_migratable.
Signed-off-by: Peter Xu <peterx@redhat.com>
---
include/migration/misc.h | 2 ++
include/sysemu/sysemu.h | 1 -
migration/migration.c | 8 +++++++-
migration/migration.h | 3 +++
migration/savevm.c | 2 +-
vl.c | 9 +++++++--
6 files changed, 20 insertions(+), 5 deletions(-)
diff --git a/include/migration/misc.h b/include/migration/misc.h
index 65c7070..23e533f 100644
--- a/include/migration/misc.h
+++ b/include/migration/misc.h
@@ -54,4 +54,6 @@ bool migration_has_finished(MigrationState *);
bool migration_has_failed(MigrationState *);
/* ...and after the device transmission */
bool migration_in_postcopy_after_devices(MigrationState *);
+void migration_only_migratable_set(bool only_migratable);
+
#endif
diff --git a/include/sysemu/sysemu.h b/include/sysemu/sysemu.h
index 9841a52..b213696 100644
--- a/include/sysemu/sysemu.h
+++ b/include/sysemu/sysemu.h
@@ -15,7 +15,6 @@
/* vl.c */
extern const char *bios_name;
-extern int only_migratable;
extern const char *qemu_name;
extern QemuUUID qemu_uuid;
extern bool qemu_uuid_set;
diff --git a/migration/migration.c b/migration/migration.c
index 095abd8..9af5c76 100644
--- a/migration/migration.c
+++ b/migration/migration.c
@@ -110,6 +110,11 @@ MigrationState *migrate_get_current(void)
return current_migration;
}
+void migration_only_migratable_set(bool only_migratable)
+{
+ migrate_get_current()->only_migratable = only_migratable;
+}
+
MigrationIncomingState *migration_incoming_get_current(void)
{
static bool once;
@@ -981,7 +986,7 @@ static GSList *migration_blockers;
int migrate_add_blocker(Error *reason, Error **errp)
{
- if (only_migratable) {
+ if (migrate_get_current()->only_migratable) {
error_propagate(errp, error_copy(reason));
error_prepend(errp, "disallowing migration blocker "
"(--only_migratable) for: ");
@@ -1979,6 +1984,7 @@ void migrate_fd_connect(MigrationState *s)
static Property migration_properties[] = {
DEFINE_PROP_BOOL("store-global-state", MigrationState,
store_global_state, true),
+ DEFINE_PROP_BOOL("only-migratable", MigrationState, only_migratable, false),
DEFINE_PROP_END_OF_LIST(),
};
diff --git a/migration/migration.h b/migration/migration.h
index 4b898e9..34377dd 100644
--- a/migration/migration.h
+++ b/migration/migration.h
@@ -139,6 +139,9 @@ struct MigrationState
* during migration.
*/
bool store_global_state;
+
+ /* Whether the VM is only allowing for migratable devices */
+ bool only_migratable;
};
void migrate_set_state(int *state, int old_state, int new_state);
diff --git a/migration/savevm.c b/migration/savevm.c
index f32a82d..d8ea522 100644
--- a/migration/savevm.c
+++ b/migration/savevm.c
@@ -2303,7 +2303,7 @@ void vmstate_register_ram_global(MemoryRegion *mr)
bool vmstate_check_only_migratable(const VMStateDescription *vmsd)
{
/* check needed if --only-migratable is specified */
- if (!only_migratable) {
+ if (!migrate_get_current()->only_migratable) {
return true;
}
diff --git a/vl.c b/vl.c
index a564139..be2a918 100644
--- a/vl.c
+++ b/vl.c
@@ -188,7 +188,6 @@ bool boot_strict;
uint8_t *boot_splash_filedata;
size_t boot_splash_filedata_size;
uint8_t qemu_extra_params_fw[2];
-int only_migratable; /* turn it off unless user states otherwise */
int icount_align_option;
@@ -3916,7 +3915,13 @@ int main(int argc, char **argv, char **envp)
incoming = optarg;
break;
case QEMU_OPTION_only_migratable:
- only_migratable = 1;
+ /*
+ * TODO: we can remove this option one day, and we
+ * should all use:
+ *
+ * "-global migration.only-migratable=true"
+ */
+ migration_only_migratable_set(true);
break;
case QEMU_OPTION_nodefaults:
has_defaults = 0;
--
2.7.4
next prev parent reply other threads:[~2017-06-19 12:51 UTC|newest]
Thread overview: 32+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-06-19 12:49 [Qemu-devel] [PATCH v3 00/13] migration: objectify MigrationState Peter Xu
2017-06-19 12:49 ` [Qemu-devel] [PATCH v3 01/13] machine: export register_compat_prop() Peter Xu
2017-06-19 14:27 ` Laurent Vivier
2017-06-19 12:49 ` [Qemu-devel] [PATCH v3 02/13] qdev: enhance global_prop_list_add() Peter Xu
2017-06-19 15:24 ` Eduardo Habkost
2017-06-19 12:49 ` [Qemu-devel] [PATCH v3 03/13] qdev: remove qdev_prop_register_global() Peter Xu
2017-06-19 12:49 ` [Qemu-devel] [PATCH v3 04/13] accel: introduce AccelState.global_props Peter Xu
2017-06-19 16:17 ` Eduardo Habkost
2017-06-20 13:20 ` Peter Xu
2017-06-20 13:41 ` Eduardo Habkost
2017-06-19 12:49 ` [Qemu-devel] [PATCH v3 05/13] tests: avoid check GlobalProperty.used Peter Xu
2017-06-19 12:49 ` [Qemu-devel] [PATCH v3 06/13] kvm: let kvm use AccelState.global_props Peter Xu
2017-06-19 16:14 ` Eduardo Habkost
2017-06-20 13:55 ` Peter Xu
2017-06-20 14:07 ` Eduardo Habkost
2017-06-21 3:00 ` Peter Xu
2017-06-21 12:09 ` Eduardo Habkost
2017-06-19 12:49 ` [Qemu-devel] [PATCH v3 07/13] tcg: " Peter Xu
2017-06-19 12:49 ` [Qemu-devel] [PATCH v3 08/13] trace: add qdev_global_prop_apply Peter Xu
2017-06-19 12:49 ` [Qemu-devel] [PATCH v3 09/13] migration: let MigrationState be a qdev Peter Xu
2017-06-19 12:49 ` [Qemu-devel] [PATCH v3 10/13] migration: move global_state.optional out Peter Xu
2017-06-19 15:47 ` Juan Quintela
2017-06-19 12:49 ` Peter Xu [this message]
2017-06-19 15:50 ` [Qemu-devel] [PATCH v3 11/13] migration: move only_migratable to MigrationState Juan Quintela
2017-06-21 3:07 ` Peter Xu
2017-06-19 12:49 ` [Qemu-devel] [PATCH v3 12/13] migration: move skip_configuration out Peter Xu
2017-06-19 15:56 ` Juan Quintela
2017-06-21 3:33 ` Peter Xu
2017-06-21 7:28 ` Juan Quintela
2017-06-19 12:49 ` [Qemu-devel] [PATCH v3 13/13] migration: move skip_section_footers Peter Xu
2017-06-19 15:57 ` Juan Quintela
2017-06-19 15:59 ` [Qemu-devel] [PATCH v3 00/13] migration: objectify MigrationState Juan Quintela
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=1497876588-947-12-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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).