[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH v2 20/43] migrate_start_postcopy: Command to trigger
From: |
Dr. David Alan Gilbert (git) |
Subject: |
[Qemu-devel] [PATCH v2 20/43] migrate_start_postcopy: Command to trigger transition to postcopy |
Date: |
Mon, 11 Aug 2014 15:29:36 +0100 |
From: "Dr. David Alan Gilbert" <address@hidden>
Once postcopy is enabled (with migrate_set_capability), the migration
will still start on precopy mode. To cause a transition into postcopy
the:
migrate_start_postcopy
command must be issued. Postcopy will start sometime after this
(when it's next checked in the migration loop).
Issuing the command before migration has started will error,
and issuing after it has finished is ignored.
Signed-off-by: Dr. David Alan Gilbert <address@hidden>
---
hmp-commands.hx | 15 +++++++++++++++
hmp.c | 7 +++++++
hmp.h | 1 +
include/migration/migration.h | 3 +++
migration.c | 22 ++++++++++++++++++++++
qapi-schema.json | 8 ++++++++
qmp-commands.hx | 19 +++++++++++++++++++
7 files changed, 75 insertions(+)
diff --git a/hmp-commands.hx b/hmp-commands.hx
index d0943b1..53362b3 100644
--- a/hmp-commands.hx
+++ b/hmp-commands.hx
@@ -987,6 +987,21 @@ Enable/Disable the usage of a capability @var{capability}
for migration.
ETEXI
{
+ .name = "migrate_start_postcopy",
+ .args_type = "",
+ .params = "",
+ .help = "Switch migration to postcopy mode",
+ .mhandler.cmd = hmp_migrate_start_postcopy,
+ },
+
+STEXI
address@hidden migrate_start_postcopy
address@hidden migrate_start_postcopy
+Switch in-progress migration to postcopy mode. Ignored after the end of
+migration (or once already in postcopy).
+ETEXI
+
+ {
.name = "client_migrate_info",
.args_type =
"protocol:s,hostname:s,port:i?,tls-port:i?,cert-subject:s?",
.params = "protocol hostname port tls-port cert-subject",
diff --git a/hmp.c b/hmp.c
index 4d1838e..e4a6189 100644
--- a/hmp.c
+++ b/hmp.c
@@ -1077,6 +1077,13 @@ void hmp_migrate_set_capability(Monitor *mon, const
QDict *qdict)
}
}
+void hmp_migrate_start_postcopy(Monitor *mon, const QDict *qdict)
+{
+ Error *err = NULL;
+ qmp_migrate_start_postcopy(&err);
+ hmp_handle_error(mon, &err);
+}
+
void hmp_set_password(Monitor *mon, const QDict *qdict)
{
const char *protocol = qdict_get_str(qdict, "protocol");
diff --git a/hmp.h b/hmp.h
index 4fd3c4a..4d59e6e 100644
--- a/hmp.h
+++ b/hmp.h
@@ -64,6 +64,7 @@ void hmp_migrate_set_downtime(Monitor *mon, const QDict
*qdict);
void hmp_migrate_set_speed(Monitor *mon, const QDict *qdict);
void hmp_migrate_set_capability(Monitor *mon, const QDict *qdict);
void hmp_migrate_set_cache_size(Monitor *mon, const QDict *qdict);
+void hmp_migrate_start_postcopy(Monitor *mon, const QDict *qdict);
void hmp_set_password(Monitor *mon, const QDict *qdict);
void hmp_expire_password(Monitor *mon, const QDict *qdict);
void hmp_eject(Monitor *mon, const QDict *qdict);
diff --git a/include/migration/migration.h b/include/migration/migration.h
index bbb616e..3c6fdd8 100644
--- a/include/migration/migration.h
+++ b/include/migration/migration.h
@@ -101,6 +101,9 @@ struct MigrationState
int64_t xbzrle_cache_size;
int64_t setup_time;
int64_t dirty_sync_count;
+
+ /* Flag set once the migration has been asked to enter postcopy */
+ volatile bool start_postcopy;
};
void process_incoming_migration(QEMUFile *f);
diff --git a/migration.c b/migration.c
index ee923e2..c473a0f 100644
--- a/migration.c
+++ b/migration.c
@@ -364,6 +364,28 @@ void
qmp_migrate_set_capabilities(MigrationCapabilityStatusList *params,
}
}
+void qmp_migrate_start_postcopy(Error **errp)
+{
+ MigrationState *s = migrate_get_current();
+
+ if (!migrate_postcopy_ram()) {
+ error_setg(errp, "Enable postcopy with migration_set_capability before"
+ " the start of migration");
+ return;
+ }
+
+ if (s->state == MIG_STATE_NONE) {
+ error_setg(errp, "Postcopy must be started after migration has been"
+ " started");
+ return;
+ }
+ /*
+ * we don't error if migration has finished since that would be racy
+ * with issuing this command.
+ */
+ s->start_postcopy = true;
+}
+
/* shared migration helpers */
static void migrate_set_state(MigrationState *s, int old_state, int new_state)
diff --git a/qapi-schema.json b/qapi-schema.json
index 77e57bd..d639a78 100644
--- a/qapi-schema.json
+++ b/qapi-schema.json
@@ -538,6 +538,14 @@
{ 'command': 'query-migrate-capabilities', 'returns':
['MigrationCapabilityStatus']}
##
+# @migrate-start-postcopy
+#
+# Switch migration to postcopy mode
+#
+# Since: 2.2
+{ 'command': 'migrate-start-postcopy' }
+
+##
# @MouseInfo:
#
# Information about a mouse device.
diff --git a/qmp-commands.hx b/qmp-commands.hx
index 4be4765..96eb854 100644
--- a/qmp-commands.hx
+++ b/qmp-commands.hx
@@ -686,6 +686,25 @@ Example:
EQMP
{
+ .name = "migrate-start-postcopy",
+ .args_type = "",
+ .mhandler.cmd_new = qmp_marshal_input_migrate_start_postcopy,
+ },
+
+SQMP
+migrate-start-postcopy
+----------------------
+
+Switch an in-progress migration to postcopy mode. Ignored after the end of
+migration (or once already in postcopy).
+
+Example:
+-> { "execute": "migrate-start-postcopy" }
+<- { "return": {} }
+
+EQMP
+
+ {
.name = "query-migrate-cache-size",
.args_type = "",
.mhandler.cmd_new = qmp_marshal_input_query_migrate_cache_size,
--
1.9.3
- [Qemu-devel] [PATCH v2 11/43] qemu_loadvm errors and debug, (continued)
- [Qemu-devel] [PATCH v2 11/43] qemu_loadvm errors and debug, Dr. David Alan Gilbert (git), 2014/08/11
- [Qemu-devel] [PATCH v2 12/43] ram_debug_dump_bitmap: Dump a migration bitmap as text, Dr. David Alan Gilbert (git), 2014/08/11
- [Qemu-devel] [PATCH v2 13/43] Rework loadvm path for subloops, Dr. David Alan Gilbert (git), 2014/08/11
- [Qemu-devel] [PATCH v2 14/43] Add migration-capability boolean for postcopy-ram., Dr. David Alan Gilbert (git), 2014/08/11
- [Qemu-devel] [PATCH v2 15/43] Add wrappers and handlers for sending/receiving the postcopy-ram migration messages., Dr. David Alan Gilbert (git), 2014/08/11
- [Qemu-devel] [PATCH v2 16/43] QEMU_VM_CMD_PACKAGED: Send a packaged chunk of migration stream, Dr. David Alan Gilbert (git), 2014/08/11
- [Qemu-devel] [PATCH v2 17/43] migrate_init: Call from savevm, Dr. David Alan Gilbert (git), 2014/08/11
- [Qemu-devel] [PATCH v2 19/43] postcopy: OS support test, Dr. David Alan Gilbert (git), 2014/08/11
- [Qemu-devel] [PATCH v2 18/43] Allow savevm handlers to state whether they could go into postcopy, Dr. David Alan Gilbert (git), 2014/08/11
- [Qemu-devel] [PATCH v2 20/43] migrate_start_postcopy: Command to trigger transition to postcopy,
Dr. David Alan Gilbert (git) <=
- [Qemu-devel] [PATCH v2 22/43] qemu_savevm_state_complete: Postcopy changes, Dr. David Alan Gilbert (git), 2014/08/11
- [Qemu-devel] [PATCH v2 24/43] Postcopy page-map-incoming (PMI) structure, Dr. David Alan Gilbert (git), 2014/08/11
- [Qemu-devel] [PATCH v2 21/43] MIG_STATE_POSTCOPY_ACTIVE: Add new migration state, Dr. David Alan Gilbert (git), 2014/08/11
- [Qemu-devel] [PATCH v2 25/43] postcopy: Add incoming_init/cleanup functions, Dr. David Alan Gilbert (git), 2014/08/11
- [Qemu-devel] [PATCH v2 23/43] Postcopy: Maintain sentmap during postcopy pre phase, Dr. David Alan Gilbert (git), 2014/08/11
- [Qemu-devel] [PATCH v2 27/43] postcopy: ram_enable_notify to switch on userfault, Dr. David Alan Gilbert (git), 2014/08/11
- [Qemu-devel] [PATCH v2 26/43] postcopy: Incoming initialisation, Dr. David Alan Gilbert (git), 2014/08/11
- [Qemu-devel] [PATCH v2 28/43] Postcopy: postcopy_start, Dr. David Alan Gilbert (git), 2014/08/11
- [Qemu-devel] [PATCH v2 29/43] Postcopy: Rework migration thread for postcopy mode, Dr. David Alan Gilbert (git), 2014/08/11