From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:40965) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XGqcr-0008Jj-B0 for qemu-devel@nongnu.org; Mon, 11 Aug 2014 10:31:11 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XGqcl-0001Kn-5t for qemu-devel@nongnu.org; Mon, 11 Aug 2014 10:31:05 -0400 Received: from mx1.redhat.com ([209.132.183.28]:47284) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XGqck-0001JC-K8 for qemu-devel@nongnu.org; Mon, 11 Aug 2014 10:30:58 -0400 From: "Dr. David Alan Gilbert (git)" Date: Mon, 11 Aug 2014 15:29:46 +0100 Message-Id: <1407767399-3030-31-git-send-email-dgilbert@redhat.com> In-Reply-To: <1407767399-3030-1-git-send-email-dgilbert@redhat.com> References: <1407767399-3030-1-git-send-email-dgilbert@redhat.com> Subject: [Qemu-devel] [PATCH v2 30/43] mig fd_connect: open return path List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: aarcange@redhat.com, yamahata@private.email.ne.jp, lilei@linux.vnet.ibm.com, quintela@redhat.com From: "Dr. David Alan Gilbert" Open the return path before migration thread creation. Since this can fail, guard the fd cleanup so it doesn't try and destroy the potentially non-existent thread. Signed-off-by: Dr. David Alan Gilbert --- include/migration/migration.h | 3 +++ migration.c | 18 +++++++++++++++++- 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/include/migration/migration.h b/include/migration/migration.h index 12a54e5..21aa8e3 100644 --- a/include/migration/migration.h +++ b/include/migration/migration.h @@ -122,6 +122,9 @@ struct MigrationState /* Flag set once the migration has been asked to enter postcopy */ volatile bool start_postcopy; + /* Flag set once the migration thread is running (and needs joining) */ + volatile bool started_migration_thread; + }; void process_incoming_migration(QEMUFile *f); diff --git a/migration.c b/migration.c index 472fc4d..9637941 100644 --- a/migration.c +++ b/migration.c @@ -470,7 +470,10 @@ static void migrate_fd_cleanup(void *opaque) if (s->file) { trace_migrate_fd_cleanup(); qemu_mutex_unlock_iothread(); - qemu_thread_join(&s->thread); + if (s->started_migration_thread) { + qemu_thread_join(&s->thread); + s->started_migration_thread = false; + } qemu_mutex_lock_iothread(); qemu_fclose(s->file); @@ -1162,6 +1165,19 @@ void migrate_fd_connect(MigrationState *s) /* Notify before starting migration thread */ notifier_list_notify(&migration_state_notifiers, s); + /* Open the return path; currently for postcopy but other things might + * also want it. + */ + if (migrate_postcopy_ram()) { + if (open_outgoing_return_path(s)) { + error_report("Unable to open return-path for postcopy"); + migrate_set_state(s, MIG_STATE_SETUP, MIG_STATE_ERROR); + migrate_fd_cleanup(s); + return; + } + } + qemu_thread_create(&s->thread, "migration", migration_thread, s, QEMU_THREAD_JOINABLE); + s->started_migration_thread = true; } -- 1.9.3