[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PULL 08/10] migration: provide postcopy_fault_thread_notif
From: |
Dr. David Alan Gilbert (git) |
Subject: |
[Qemu-devel] [PULL 08/10] migration: provide postcopy_fault_thread_notify() |
Date: |
Wed, 14 Feb 2018 15:39:36 +0000 |
From: Peter Xu <address@hidden>
A general helper to notify the fault thread.
Reviewed-by: Dr. David Alan Gilbert <address@hidden>
Signed-off-by: Peter Xu <address@hidden>
Message-Id: <address@hidden>
Signed-off-by: Dr. David Alan Gilbert <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 9ad4f20f82..032abfbf1a 100644
--- a/migration/postcopy-ram.c
+++ b/migration/postcopy-ram.c
@@ -377,25 +377,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);
@@ -824,6 +814,21 @@ void *postcopy_get_tmp_page(MigrationIncomingState *mis)
/* ------------------------------------------------------------------------- */
+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));
+ }
+}
+
/**
* postcopy_discard_send_init: Called at the start of each RAMBlock before
* asking to discard individual ranges.
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.14.3
- [Qemu-devel] [PULL 00/10] migration queue, Dr. David Alan Gilbert (git), 2018/02/14
- [Qemu-devel] [PULL 01/10] migration/xen: Check return value of qemu_fclose, Dr. David Alan Gilbert (git), 2018/02/14
- [Qemu-devel] [PULL 04/10] migration: Fix early failure cleanup, Dr. David Alan Gilbert (git), 2018/02/14
- [Qemu-devel] [PULL 07/10] migration: reuse mis->userfault_quit_fd, Dr. David Alan Gilbert (git), 2018/02/14
- [Qemu-devel] [PULL 09/10] migration: allow send_rq to fail, Dr. David Alan Gilbert (git), 2018/02/14
- [Qemu-devel] [PULL 05/10] tests/migration: Add test for migration to bad destination, Dr. David Alan Gilbert (git), 2018/02/14
- [Qemu-devel] [PULL 02/10] migration: improve documentation of postcopy-ram, Dr. David Alan Gilbert (git), 2018/02/14
- [Qemu-devel] [PULL 06/10] migration: better error handling with QEMUFile, Dr. David Alan Gilbert (git), 2018/02/14
- [Qemu-devel] [PULL 03/10] tests/migration: Add source to PC boot block, Dr. David Alan Gilbert (git), 2018/02/14
- [Qemu-devel] [PULL 10/10] migration: pass MigrationState to migrate_init(), Dr. David Alan Gilbert (git), 2018/02/14
- [Qemu-devel] [PULL 08/10] migration: provide postcopy_fault_thread_notify(),
Dr. David Alan Gilbert (git) <=
- Re: [Qemu-devel] [PULL 00/10] migration queue, Peter Maydell, 2018/02/15
- Re: [Qemu-devel] [PULL 00/10] migration queue, Peter Maydell, 2018/02/16