[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH v8 36/54] Split out end of migration code from migra
From: |
Dr. David Alan Gilbert (git) |
Subject: |
[Qemu-devel] [PATCH v8 36/54] Split out end of migration code from migration_thread |
Date: |
Tue, 29 Sep 2015 09:38:00 +0100 |
From: "Dr. David Alan Gilbert" <address@hidden>
The code that gets run at the end of the migration process
is getting large, and is about to have a chunk added for postcopy.
Split it into a separate function.
Signed-off-by: Dr. David Alan Gilbert <address@hidden>
---
migration/migration.c | 75 ++++++++++++++++++++++++++++++++-------------------
trace-events | 2 ++
2 files changed, 50 insertions(+), 27 deletions(-)
diff --git a/migration/migration.c b/migration/migration.c
index 6c662e6..1b32625 100644
--- a/migration/migration.c
+++ b/migration/migration.c
@@ -1324,6 +1324,50 @@ fail:
return -1;
}
+/**
+ * migration_completion: Used by migration_thread when there's not much left
+ * pending. The caller 'breaks' the loop when this returns.
+ *
+ * @s: Current migration state
+ * @current_active_state: The migration state we expect to be in
+ * @*old_vm_running: Pointer to old_vm_running flag
+ * @*start_time: Pointer to time to update
+ */
+static void migration_completion(MigrationState *s, int current_active_state,
+ bool *old_vm_running, int64_t *start_time)
+{
+ int ret;
+ qemu_mutex_lock_iothread();
+ *start_time = qemu_clock_get_ms(QEMU_CLOCK_REALTIME);
+ qemu_system_wakeup_request(QEMU_WAKEUP_REASON_OTHER);
+ *old_vm_running = runstate_is_running();
+ ret = global_state_store();
+
+ if (!ret) {
+ ret = vm_stop_force_state(RUN_STATE_FINISH_MIGRATE);
+ if (ret >= 0) {
+ qemu_file_set_rate_limit(s->file, INT64_MAX);
+ qemu_savevm_state_complete_precopy(s->file);
+ }
+ }
+ qemu_mutex_unlock_iothread();
+
+ if (ret < 0) {
+ goto fail;
+ }
+
+ if (qemu_file_get_error(s->file)) {
+ trace_migration_completion_file_err();
+ goto fail;
+ }
+
+ migrate_set_state(s, current_active_state, MIGRATION_STATUS_COMPLETED);
+ return;
+
+fail:
+ migrate_set_state(s, current_active_state, MIGRATION_STATUS_FAILED);
+}
+
/*
* Master migration thread on the source VM.
* It drives the migration and pumps the data down the outgoing channel.
@@ -1401,34 +1445,11 @@ static void *migration_thread(void *opaque)
/* Just another iteration step */
qemu_savevm_state_iterate(s->file);
} else {
- int ret;
-
- qemu_mutex_lock_iothread();
- start_time = qemu_clock_get_ms(QEMU_CLOCK_REALTIME);
- qemu_system_wakeup_request(QEMU_WAKEUP_REASON_OTHER);
- old_vm_running = runstate_is_running();
-
- ret = global_state_store();
- if (!ret) {
- ret = vm_stop_force_state(RUN_STATE_FINISH_MIGRATE);
- if (ret >= 0) {
- qemu_file_set_rate_limit(s->file, INT64_MAX);
- qemu_savevm_state_complete_precopy(s->file);
- }
- }
- qemu_mutex_unlock_iothread();
+ trace_migration_thread_low_pending(pending_size);
- if (ret < 0) {
- migrate_set_state(s, MIGRATION_STATUS_ACTIVE,
- MIGRATION_STATUS_FAILED);
- break;
- }
-
- if (!qemu_file_get_error(s->file)) {
- migrate_set_state(s, MIGRATION_STATUS_ACTIVE,
- MIGRATION_STATUS_COMPLETED);
- break;
- }
+ migration_completion(s, current_active_state, &old_vm_running,
+ &start_time);
+ break;
}
}
diff --git a/trace-events b/trace-events
index b0e7c20..875d9ef 100644
--- a/trace-events
+++ b/trace-events
@@ -1441,9 +1441,11 @@ migrate_fd_error(void) ""
migrate_fd_cancel(void) ""
migrate_pending(uint64_t size, uint64_t max, uint64_t post, uint64_t nonpost)
"pending size %" PRIu64 " max %" PRIu64 " (post=%" PRIu64 " nonpost=%" PRIu64
")"
migrate_send_rp_message(int msg_type, uint16_t len) "%d: len %d"
+migration_completion_file_err(void) ""
migration_thread_after_loop(void) ""
migration_thread_file_err(void) ""
migration_thread_setup_complete(void) ""
+migration_thread_low_pending(uint64_t pending) "%" PRIu64
open_return_path_on_source(void) ""
open_return_path_on_source_continue(void) ""
postcopy_start(void) ""
--
2.5.0
- [Qemu-devel] [PATCH v8 34/54] postcopy: ram_enable_notify to switch on userfault, (continued)
- [Qemu-devel] [PATCH v8 34/54] postcopy: ram_enable_notify to switch on userfault, Dr. David Alan Gilbert (git), 2015/10/01
- [Qemu-devel] [PATCH v8 37/54] Postcopy: End of iteration, Dr. David Alan Gilbert (git), 2015/10/01
- [Qemu-devel] [PATCH v8 33/54] postcopy: Incoming initialisation, Dr. David Alan Gilbert (git), 2015/10/01
- [Qemu-devel] [PATCH v8 35/54] Postcopy: Postcopy startup in migration thread, Dr. David Alan Gilbert (git), 2015/10/01
- [Qemu-devel] [PATCH v8 36/54] Split out end of migration code from migration_thread,
Dr. David Alan Gilbert (git) <=
- [Qemu-devel] [PATCH v8 38/54] Page request: Add MIG_RP_MSG_REQ_PAGES reverse command, Dr. David Alan Gilbert (git), 2015/10/01
- [Qemu-devel] [PATCH v8 39/54] Page request: Process incoming page request, Dr. David Alan Gilbert (git), 2015/10/01
- [Qemu-devel] [PATCH v8 40/54] Page request: Consume pages off the post-copy queue, Dr. David Alan Gilbert (git), 2015/10/01
- [Qemu-devel] [PATCH v8 42/54] Postcopy: Use helpers to map pages during migration, Dr. David Alan Gilbert (git), 2015/10/01