[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [RFC 17/29] migration: rebuild channel on source
From: |
Peter Xu |
Subject: |
[Qemu-devel] [RFC 17/29] migration: rebuild channel on source |
Date: |
Fri, 28 Jul 2017 16:06:26 +0800 |
This patch detects the "resume" flag of migration command, rebuild the
channels only if the flag is set.
Signed-off-by: Peter Xu <address@hidden>
---
migration/migration.c | 52 ++++++++++++++++++++++++++++++++++++++++-----------
1 file changed, 41 insertions(+), 11 deletions(-)
diff --git a/migration/migration.c b/migration/migration.c
index 36ff8c3..64de0ee 100644
--- a/migration/migration.c
+++ b/migration/migration.c
@@ -1244,6 +1244,15 @@ void qmp_migrate(const char *uri, bool has_blk, bool blk,
MigrationState *s = migrate_get_current();
const char *p;
+ if (has_resume && resume) {
+ if (s->state != MIGRATION_STATUS_POSTCOPY_PAUSED) {
+ error_setg(errp, "Cannot resume if there is no "
+ "paused migration");
+ return;
+ }
+ goto do_resume;
+ }
+
if (migration_is_setup_or_active(s->state) ||
s->state == MIGRATION_STATUS_CANCELLING ||
s->state == MIGRATION_STATUS_COLO) {
@@ -1279,6 +1288,7 @@ void qmp_migrate(const char *uri, bool has_blk, bool blk,
s = migrate_init();
+do_resume:
if (strstart(uri, "tcp:", &p)) {
tcp_start_outgoing_migration(s, p, &local_err);
#ifdef CONFIG_RDMA
@@ -1700,7 +1710,8 @@ out:
return NULL;
}
-static int open_return_path_on_source(MigrationState *ms)
+static int open_return_path_on_source(MigrationState *ms,
+ bool create_thread)
{
ms->rp_state.from_dst_file = qemu_file_get_return_path(ms->to_dst_file);
@@ -1709,6 +1720,12 @@ static int open_return_path_on_source(MigrationState *ms)
}
trace_open_return_path_on_source();
+
+ if (!create_thread) {
+ /* We're done */
+ return 0;
+ }
+
qemu_thread_create(&ms->rp_state.rp_thread, "return path",
source_return_path_thread, ms, QEMU_THREAD_JOINABLE);
@@ -2249,15 +2266,24 @@ static void *migration_thread(void *opaque)
void migrate_fd_connect(MigrationState *s)
{
- s->expected_downtime = s->parameters.downtime_limit;
- s->cleanup_bh = qemu_bh_new(migrate_fd_cleanup, s);
+ int64_t rate_limit;
+ bool resume = s->state == MIGRATION_STATUS_POSTCOPY_PAUSED;
- qemu_file_set_blocking(s->to_dst_file, true);
- qemu_file_set_rate_limit(s->to_dst_file,
- s->parameters.max_bandwidth / XFER_LIMIT_RATIO);
+ if (resume) {
+ /* This is a resumed migration */
+ rate_limit = INT64_MAX;
+ } else {
+ /* This is a fresh new migration */
+ rate_limit = s->parameters.max_bandwidth / XFER_LIMIT_RATIO;
+ s->expected_downtime = s->parameters.downtime_limit;
+ s->cleanup_bh = qemu_bh_new(migrate_fd_cleanup, s);
- /* Notify before starting migration thread */
- notifier_list_notify(&migration_state_notifiers, s);
+ /* Notify before starting migration thread */
+ notifier_list_notify(&migration_state_notifiers, s);
+ }
+
+ qemu_file_set_rate_limit(s->to_dst_file, rate_limit);
+ qemu_file_set_blocking(s->to_dst_file, true);
/*
* Open the return path. For postcopy, it is used exclusively. For
@@ -2265,15 +2291,19 @@ void migrate_fd_connect(MigrationState *s)
* QEMU uses the return path.
*/
if (migrate_postcopy_ram() || migrate_use_return_path()) {
- if (open_return_path_on_source(s)) {
+ if (open_return_path_on_source(s, !resume)) {
error_report("Unable to open return-path for postcopy");
- migrate_set_state(&s->state, MIGRATION_STATUS_SETUP,
- MIGRATION_STATUS_FAILED);
+ migrate_set_state(&s->state, s->state, MIGRATION_STATUS_FAILED);
migrate_fd_cleanup(s);
return;
}
}
+ if (resume) {
+ /* TODO: do the resume logic */
+ return;
+ }
+
qemu_thread_create(&s->thread, "live_migration", migration_thread, s,
QEMU_THREAD_JOINABLE);
s->migration_thread_running = true;
--
2.7.4
- [Qemu-devel] [RFC 11/29] migration: new postcopy-pause state, (continued)
- [Qemu-devel] [RFC 11/29] migration: new postcopy-pause state, Peter Xu, 2017/07/28
- [Qemu-devel] [RFC 12/29] migration: allow dst vm pause on postcopy, Peter Xu, 2017/07/28
- [Qemu-devel] [RFC 13/29] migration: allow src return path to pause, Peter Xu, 2017/07/28
- [Qemu-devel] [RFC 14/29] migration: allow send_rq to fail, Peter Xu, 2017/07/28
- [Qemu-devel] [RFC 15/29] migration: allow fault thread to pause, Peter Xu, 2017/07/28
- [Qemu-devel] [RFC 16/29] qmp: hmp: add migrate "resume" option, Peter Xu, 2017/07/28
- [Qemu-devel] [RFC 17/29] migration: rebuild channel on source,
Peter Xu <=
- [Qemu-devel] [RFC 19/29] migration: let dst listen on port always, Peter Xu, 2017/07/28
- [Qemu-devel] [RFC 18/29] migration: new state "postcopy-recover", Peter Xu, 2017/07/28
- [Qemu-devel] [RFC 20/29] migration: wakeup dst ram-load-thread for recover, Peter Xu, 2017/07/28
- [Qemu-devel] [RFC 21/29] migration: new cmd MIG_CMD_RECV_BITMAP, Peter Xu, 2017/07/28
- [Qemu-devel] [RFC 22/29] migration: new message MIG_RP_MSG_RECV_BITMAP, Peter Xu, 2017/07/28
- [Qemu-devel] [RFC 23/29] migration: new cmd MIG_CMD_POSTCOPY_RESUME, Peter Xu, 2017/07/28
- [Qemu-devel] [RFC 24/29] migration: new message MIG_RP_MSG_RESUME_ACK, Peter Xu, 2017/07/28
- [Qemu-devel] [RFC 25/29] migration: introduce SaveVMHandlers.resume_prepare, Peter Xu, 2017/07/28
- [Qemu-devel] [RFC 26/29] migration: synchronize dirty bitmap for resume, Peter Xu, 2017/07/28
- [Qemu-devel] [RFC 27/29] migration: setup ramstate for resume, Peter Xu, 2017/07/28