[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [RFC v2 07/33] migration: provide postcopy_fault_thread_not
From: |
Peter Xu |
Subject: |
[Qemu-devel] [RFC v2 07/33] migration: provide postcopy_fault_thread_notify() |
Date: |
Wed, 30 Aug 2017 16:32:04 +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 0138a49..c28e340 100644
--- a/migration/postcopy-ram.c
+++ b/migration/postcopy-ram.c
@@ -287,6 +287,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.
*/
@@ -295,25 +310,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 78a3591..4a7644d 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.7.4
- [Qemu-devel] [RFC v2 00/33] Migration: postcopy failure recovery, Peter Xu, 2017/08/30
- [Qemu-devel] [RFC v2 01/33] bitmap: remove BITOP_WORD(), Peter Xu, 2017/08/30
- [Qemu-devel] [RFC v2 02/33] bitmap: introduce bitmap_count_one(), Peter Xu, 2017/08/30
- [Qemu-devel] [RFC v2 03/33] bitmap: provide to_le/from_le helpers, Peter Xu, 2017/08/30
- [Qemu-devel] [RFC v2 04/33] migration: dump str in migrate_set_state trace, Peter Xu, 2017/08/30
- [Qemu-devel] [RFC v2 05/33] migration: better error handling with QEMUFile, Peter Xu, 2017/08/30
- [Qemu-devel] [RFC v2 06/33] migration: reuse mis->userfault_quit_fd, Peter Xu, 2017/08/30
- [Qemu-devel] [RFC v2 07/33] migration: provide postcopy_fault_thread_notify(),
Peter Xu <=
- [Qemu-devel] [RFC v2 09/33] migration: implement "postcopy-pause" src logic, Peter Xu, 2017/08/30
- [Qemu-devel] [RFC v2 08/33] migration: new postcopy-pause state, Peter Xu, 2017/08/30
- [Qemu-devel] [RFC v2 10/33] migration: allow dst vm pause on postcopy, Peter Xu, 2017/08/30
- [Qemu-devel] [RFC v2 11/33] migration: allow src return path to pause, Peter Xu, 2017/08/30
- [Qemu-devel] [RFC v2 12/33] migration: allow send_rq to fail, Peter Xu, 2017/08/30
- [Qemu-devel] [RFC v2 13/33] migration: allow fault thread to pause, Peter Xu, 2017/08/30
- [Qemu-devel] [RFC v2 14/33] qmp: hmp: add migrate "resume" option, Peter Xu, 2017/08/30
- [Qemu-devel] [RFC v2 15/33] migration: pass MigrationState to migrate_init(), Peter Xu, 2017/08/30
- [Qemu-devel] [RFC v2 16/33] migration: rebuild channel on source, Peter Xu, 2017/08/30
- [Qemu-devel] [RFC v2 17/33] migration: new state "postcopy-recover", Peter Xu, 2017/08/30