qemu-devel
[Top][All Lists]
Advanced

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

Re: [Qemu-devel] [RFC v2 33/33] migration: init dst in migration_object_


From: Dr. David Alan Gilbert
Subject: Re: [Qemu-devel] [RFC v2 33/33] migration: init dst in migration_object_init too
Date: Fri, 22 Sep 2017 21:37:44 +0100
User-agent: Mutt/1.8.3 (2017-05-23)

* Peter Xu (address@hidden) wrote:
> Though we may not need it, now we init both the src/dst migration
> objects in migration_object_init() so that even incoming migration
> object would be thread safe (it was not).
> 
> Signed-off-by: Peter Xu <address@hidden>

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

> ---
>  migration/migration.c | 27 ++++++++++++++-------------
>  1 file changed, 14 insertions(+), 13 deletions(-)
> 
> diff --git a/migration/migration.c b/migration/migration.c
> index 5812478..7e9ccf0 100644
> --- a/migration/migration.c
> +++ b/migration/migration.c
> @@ -103,6 +103,7 @@ enum mig_rp_message_type {
>     dynamic creation of migration */
>  
>  static MigrationState *current_migration;
> +static MigrationIncomingState *current_incoming;
>  
>  static bool migration_object_check(MigrationState *ms, Error **errp);
>  
> @@ -128,6 +129,17 @@ void migration_object_init(void)
>      if (ms->enforce_config_section) {
>          current_migration->send_configuration = true;
>      }
> +
> +    /*
> +     * Init the migrate incoming object as well no matter whether
> +     * we'll use it or not.
> +     */
> +    current_incoming = g_new0(MigrationIncomingState, 1);
> +    current_incoming->state = MIGRATION_STATUS_NONE;
> +    qemu_mutex_init(&current_incoming->rp_mutex);
> +    qemu_event_init(&current_incoming->main_thread_load_event, false);
> +    qemu_sem_init(&current_incoming->postcopy_pause_sem_dst, 0);
> +    qemu_sem_init(&current_incoming->postcopy_pause_sem_fault, 0);
>  }
>  
>  /* For outgoing */
> @@ -140,19 +152,8 @@ MigrationState *migrate_get_current(void)
>  
>  MigrationIncomingState *migration_incoming_get_current(void)
>  {
> -    static bool once;
> -    static MigrationIncomingState mis_current;
> -
> -    if (!once) {
> -        mis_current.state = MIGRATION_STATUS_NONE;
> -        memset(&mis_current, 0, sizeof(MigrationIncomingState));
> -        qemu_mutex_init(&mis_current.rp_mutex);
> -        qemu_event_init(&mis_current.main_thread_load_event, false);
> -        qemu_sem_init(&mis_current.postcopy_pause_sem_dst, 0);
> -        qemu_sem_init(&mis_current.postcopy_pause_sem_fault, 0);
> -        once = true;
> -    }
> -    return &mis_current;
> +    assert(current_incoming);
> +    return current_incoming;
>  }
>  
>  void migration_incoming_state_destroy(void)
> -- 
> 2.7.4
> 
> 
--
Dr. David Alan Gilbert / address@hidden / Manchester, UK



reply via email to

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