* Peter Xu (pet...@redhat.com) 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 <pet...@redhat.com>
Reviewed-by: Dr. David Alan Gilbert <dgilb...@redhat.com> > --- > 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(¤t_incoming->rp_mutex); > + qemu_event_init(¤t_incoming->main_thread_load_event, false); > + qemu_sem_init(¤t_incoming->postcopy_pause_sem_dst, 0); > + qemu_sem_init(¤t_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 / dgilb...@redhat.com / Manchester, UK