提交 14b1742e 编写于 作者: P Peter Xu 提交者: Juan Quintela

migration: allow src return path to pause

Let the thread pause for network issues.
Reviewed-by: NDr. David Alan Gilbert <dgilbert@redhat.com>
Signed-off-by: NPeter Xu <peterx@redhat.com>
Message-Id: <20180502104740.12123-6-peterx@redhat.com>
Signed-off-by: NJuan Quintela <quintela@redhat.com>
上级 b411b844
...@@ -1779,6 +1779,18 @@ static void migrate_handle_rp_req_pages(MigrationState *ms, const char* rbname, ...@@ -1779,6 +1779,18 @@ static void migrate_handle_rp_req_pages(MigrationState *ms, const char* rbname,
} }
} }
/* Return true to retry, false to quit */
static bool postcopy_pause_return_path_thread(MigrationState *s)
{
trace_postcopy_pause_return_path();
qemu_sem_wait(&s->postcopy_pause_rp_sem);
trace_postcopy_pause_return_path_continued();
return true;
}
/* /*
* Handles messages sent on the return path towards the source VM * Handles messages sent on the return path towards the source VM
* *
...@@ -1795,6 +1807,8 @@ static void *source_return_path_thread(void *opaque) ...@@ -1795,6 +1807,8 @@ static void *source_return_path_thread(void *opaque)
int res; int res;
trace_source_return_path_thread_entry(); trace_source_return_path_thread_entry();
retry:
while (!ms->rp_state.error && !qemu_file_get_error(rp) && while (!ms->rp_state.error && !qemu_file_get_error(rp) &&
migration_is_setup_or_active(ms->state)) { migration_is_setup_or_active(ms->state)) {
trace_source_return_path_thread_loop_top(); trace_source_return_path_thread_loop_top();
...@@ -1886,13 +1900,28 @@ static void *source_return_path_thread(void *opaque) ...@@ -1886,13 +1900,28 @@ static void *source_return_path_thread(void *opaque)
break; break;
} }
} }
if (qemu_file_get_error(rp)) {
out:
res = qemu_file_get_error(rp);
if (res) {
if (res == -EIO) {
/*
* Maybe there is something we can do: it looks like a
* network down issue, and we pause for a recovery.
*/
if (postcopy_pause_return_path_thread(ms)) {
/* Reload rp, reset the rest */
rp = ms->rp_state.from_dst_file;
ms->rp_state.error = false;
goto retry;
}
}
trace_source_return_path_thread_bad_end(); trace_source_return_path_thread_bad_end();
mark_source_rp_bad(ms); mark_source_rp_bad(ms);
} }
trace_source_return_path_thread_end(); trace_source_return_path_thread_end();
out:
ms->rp_state.from_dst_file = NULL; ms->rp_state.from_dst_file = NULL;
qemu_fclose(rp); qemu_fclose(rp);
return NULL; return NULL;
...@@ -2700,6 +2729,7 @@ static void migration_instance_finalize(Object *obj) ...@@ -2700,6 +2729,7 @@ static void migration_instance_finalize(Object *obj)
g_free(params->tls_creds); g_free(params->tls_creds);
qemu_sem_destroy(&ms->pause_sem); qemu_sem_destroy(&ms->pause_sem);
qemu_sem_destroy(&ms->postcopy_pause_sem); qemu_sem_destroy(&ms->postcopy_pause_sem);
qemu_sem_destroy(&ms->postcopy_pause_rp_sem);
error_free(ms->error); error_free(ms->error);
} }
...@@ -2731,6 +2761,7 @@ static void migration_instance_init(Object *obj) ...@@ -2731,6 +2761,7 @@ static void migration_instance_init(Object *obj)
params->has_xbzrle_cache_size = true; params->has_xbzrle_cache_size = true;
qemu_sem_init(&ms->postcopy_pause_sem, 0); qemu_sem_init(&ms->postcopy_pause_sem, 0);
qemu_sem_init(&ms->postcopy_pause_rp_sem, 0);
} }
/* /*
......
...@@ -200,6 +200,7 @@ struct MigrationState ...@@ -200,6 +200,7 @@ struct MigrationState
/* Needed by postcopy-pause state */ /* Needed by postcopy-pause state */
QemuSemaphore postcopy_pause_sem; QemuSemaphore postcopy_pause_sem;
QemuSemaphore postcopy_pause_rp_sem;
}; };
void migrate_set_state(int *state, int old_state, int new_state); void migrate_set_state(int *state, int old_state, int new_state);
......
...@@ -99,6 +99,8 @@ migration_thread_setup_complete(void) "" ...@@ -99,6 +99,8 @@ migration_thread_setup_complete(void) ""
open_return_path_on_source(void) "" open_return_path_on_source(void) ""
open_return_path_on_source_continue(void) "" open_return_path_on_source_continue(void) ""
postcopy_start(void) "" postcopy_start(void) ""
postcopy_pause_return_path(void) ""
postcopy_pause_return_path_continued(void) ""
postcopy_pause_continued(void) "" postcopy_pause_continued(void) ""
postcopy_pause_incoming(void) "" postcopy_pause_incoming(void) ""
postcopy_pause_incoming_continued(void) "" postcopy_pause_incoming_continued(void) ""
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册