migration: provide postcopy_fault_thread_notify()
A general helper to notify the fault thread. Reviewed-by: Dr. David Alan Gilbert <dgilbert@redhat.com> Signed-off-by: Peter Xu <peterx@redhat.com> Message-Id: <20180208103132.28452-4-peterx@redhat.com> Signed-off-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
This commit is contained in:
parent
64f615fe34
commit
9ab7ef9b66
migration
@ -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.
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user