migration: init dst in migration_object_init too
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). Reviewed-by: Dr. David Alan Gilbert <dgilbert@redhat.com> Signed-off-by: Peter Xu <peterx@redhat.com> Message-Id: <20180502104740.12123-20-peterx@redhat.com> Signed-off-by: Juan Quintela <quintela@redhat.com>
This commit is contained in:
parent
9419069695
commit
e1b1b1bc36
@ -106,6 +106,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);
|
||||
static int migration_maybe_pause(MigrationState *s,
|
||||
@ -121,6 +122,22 @@ void migration_object_init(void)
|
||||
assert(!current_migration);
|
||||
current_migration = MIGRATION_OBJ(object_new(TYPE_MIGRATION));
|
||||
|
||||
/*
|
||||
* Init the migrate incoming object as well no matter whether
|
||||
* we'll use it or not.
|
||||
*/
|
||||
assert(!current_incoming);
|
||||
current_incoming = g_new0(MigrationIncomingState, 1);
|
||||
current_incoming->state = MIGRATION_STATUS_NONE;
|
||||
current_incoming->postcopy_remote_fds =
|
||||
g_array_new(FALSE, TRUE, sizeof(struct PostCopyFD));
|
||||
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);
|
||||
|
||||
init_dirty_bitmap_incoming_migration();
|
||||
|
||||
if (!migration_object_check(current_migration, &err)) {
|
||||
error_report_err(err);
|
||||
exit(1);
|
||||
@ -151,24 +168,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));
|
||||
mis_current.postcopy_remote_fds = g_array_new(FALSE, TRUE,
|
||||
sizeof(struct PostCopyFD));
|
||||
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);
|
||||
|
||||
init_dirty_bitmap_incoming_migration();
|
||||
|
||||
once = true;
|
||||
}
|
||||
return &mis_current;
|
||||
assert(current_incoming);
|
||||
return current_incoming;
|
||||
}
|
||||
|
||||
void migration_incoming_state_destroy(void)
|
||||
|
Loading…
Reference in New Issue
Block a user