qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [RFC 09/29] migration: provide postcopy_fault_thread_no


From: Dr. David Alan Gilbert
Subject: Re: [Qemu-devel] [RFC 09/29] migration: provide postcopy_fault_thread_notify()
Date: Mon, 31 Jul 2017 19:45:38 +0100
User-agent: Mutt/1.8.3 (2017-05-23)

* Peter Xu (address@hidden) wrote:
> A general helper to notify the fault thread.
> 
> 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 4278fe7..9ce391d 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;
> +
> +    /*
> +     * Tell the fault_thread to exit, 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 userfault_quit_fd: %s", __func__,

minor; that error message needs updating with the new name, or since
it's a standalone function, 'incrementing failed:'  would work.
Other than that:


Reviewed-by: Dr. David Alan Gilbert <address@hidden>

> +                     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_quit_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
> 
--
Dr. David Alan Gilbert / address@hidden / Manchester, UK



reply via email to

[Prev in Thread] Current Thread [Next in Thread]