[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH v3 03/32] migration: provide postcopy_fault_thread_n
From: |
Peter Xu |
Subject: |
[Qemu-devel] [PATCH v3 03/32] migration: provide postcopy_fault_thread_notify() |
Date: |
Mon, 16 Oct 2017 14:51:47 +0800 |
A general helper to notify the fault thread.
Reviewed-by: Dr. David Alan Gilbert <address@hidden>
Signed-off-by: Peter Xu <address@hidden>
---
migration/postcopy-ram.c | 35 ++++++++++++++++++++---------------
migration/postcopy-ram.h | 2 ++
2 files changed, 22 insertions(+), 15 deletions(-)
diff --git a/migration/postcopy-ram.c b/migration/postcopy-ram.c
index 07dd29c9d7..e770077a81 100644
--- a/migration/postcopy-ram.c
+++ b/migration/postcopy-ram.c
@@ -369,6 +369,21 @@ int postcopy_ram_incoming_init(MigrationIncomingState
*mis, size_t ram_pages)
return 0;
}
+void postcopy_fault_thread_notify(MigrationIncomingState *mis)
+{
+ uint64_t tmp64 = 1;
+
+ /*
+ * Wakeup the fault_thread. It's an eventfd that should currently
+ * be at 0, we're going to increment it to 1
+ */
+ if (write(mis->userfault_event_fd, &tmp64, 8) != 8) {
+ /* Not much we can do here, but may as well report it */
+ error_report("%s: incrementing failed: %s", __func__,
+ strerror(errno));
+ }
+}
+
/*
* At the end of a migration where postcopy_ram_incoming_init was called.
*/
@@ -377,25 +392,15 @@ int postcopy_ram_incoming_cleanup(MigrationIncomingState
*mis)
trace_postcopy_ram_incoming_cleanup_entry();
if (mis->have_fault_thread) {
- uint64_t tmp64;
-
if (qemu_ram_foreach_block(cleanup_range, mis)) {
return -1;
}
- /*
- * Tell the fault_thread to exit, it's an eventfd that should
- * currently be at 0, we're going to increment it to 1
- */
- tmp64 = 1;
+ /* Let the fault thread quit */
atomic_set(&mis->fault_thread_quit, 1);
- if (write(mis->userfault_event_fd, &tmp64, 8) == 8) {
- trace_postcopy_ram_incoming_cleanup_join();
- qemu_thread_join(&mis->fault_thread);
- } else {
- /* Not much we can do here, but may as well report it */
- error_report("%s: incrementing userfault_event_fd: %s", __func__,
- strerror(errno));
- }
+ postcopy_fault_thread_notify(mis);
+ trace_postcopy_ram_incoming_cleanup_join();
+ qemu_thread_join(&mis->fault_thread);
+
trace_postcopy_ram_incoming_cleanup_closeuf();
close(mis->userfault_fd);
close(mis->userfault_event_fd);
diff --git a/migration/postcopy-ram.h b/migration/postcopy-ram.h
index 77ea0fd264..14f6cadcbd 100644
--- a/migration/postcopy-ram.h
+++ b/migration/postcopy-ram.h
@@ -114,4 +114,6 @@ PostcopyState postcopy_state_get(void);
/* Set the state and return the old state */
PostcopyState postcopy_state_set(PostcopyState new_state);
+void postcopy_fault_thread_notify(MigrationIncomingState *mis);
+
#endif
--
2.13.5
- [Qemu-devel] [PATCH v3 00/32] Migration: postcopy failure recovery, Peter Xu, 2017/10/16
- [Qemu-devel] [PATCH v3 01/32] migration: better error handling with QEMUFile, Peter Xu, 2017/10/16
- [Qemu-devel] [PATCH v3 02/32] migration: reuse mis->userfault_quit_fd, Peter Xu, 2017/10/16
- [Qemu-devel] [PATCH v3 03/32] migration: provide postcopy_fault_thread_notify(),
Peter Xu <=
- [Qemu-devel] [PATCH v3 04/32] migration: new postcopy-pause state, Peter Xu, 2017/10/16
- [Qemu-devel] [PATCH v3 05/32] migration: implement "postcopy-pause" src logic, Peter Xu, 2017/10/16
- [Qemu-devel] [PATCH v3 06/32] migration: allow dst vm pause on postcopy, Peter Xu, 2017/10/16
- [Qemu-devel] [PATCH v3 07/32] migration: allow src return path to pause, Peter Xu, 2017/10/16
- [Qemu-devel] [PATCH v3 08/32] migration: allow send_rq to fail, Peter Xu, 2017/10/16
- [Qemu-devel] [PATCH v3 09/32] migration: allow fault thread to pause, Peter Xu, 2017/10/16
- [Qemu-devel] [PATCH v3 10/32] qmp: hmp: add migrate "resume" option, Peter Xu, 2017/10/16
- [Qemu-devel] [PATCH v3 11/32] migration: pass MigrationState to migrate_init(), Peter Xu, 2017/10/16
- [Qemu-devel] [PATCH v3 12/32] migration: rebuild channel on source, Peter Xu, 2017/10/16
- [Qemu-devel] [PATCH v3 13/32] migration: new state "postcopy-recover", Peter Xu, 2017/10/16