From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:51289) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Y9B0H-0002Az-Oc for qemu-devel@nongnu.org; Thu, 08 Jan 2015 06:11:51 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Y9B0B-0008Fz-JY for qemu-devel@nongnu.org; Thu, 08 Jan 2015 06:11:49 -0500 Received: from mx1.redhat.com ([209.132.183.28]:53372) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Y9B0B-0008Fp-BR for qemu-devel@nongnu.org; Thu, 08 Jan 2015 06:11:43 -0500 From: "Dr. David Alan Gilbert (git)" Date: Thu, 8 Jan 2015 11:11:32 +0000 Message-Id: <1420715492-5109-4-git-send-email-dgilbert@redhat.com> In-Reply-To: <1420715492-5109-1-git-send-email-dgilbert@redhat.com> References: <1420715492-5109-1-git-send-email-dgilbert@redhat.com> Subject: [Qemu-devel] [PATCH 3/3] migration_cancel: shutdown migration socket List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: amit.shah@redhat.com, cristian.klein@cs.umu.se, quintela@redhat.com From: "Dr. David Alan Gilbert" Force shutdown on migration socket on cancel to cause the cancel to complete even if the socket is blocked on a dead network. Signed-off-by: Dr. David Alan Gilbert --- migration/migration.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/migration/migration.c b/migration/migration.c index c49a05a..b3adbc6 100644 --- a/migration/migration.c +++ b/migration/migration.c @@ -330,6 +330,7 @@ void migrate_fd_error(MigrationState *s) static void migrate_fd_cancel(MigrationState *s) { int old_state ; + QEMUFile *f = migrate_get_current()->file; trace_migrate_fd_cancel(); do { @@ -339,6 +340,17 @@ static void migrate_fd_cancel(MigrationState *s) } migrate_set_state(s, old_state, MIG_STATE_CANCELLING); } while (s->state != MIG_STATE_CANCELLING); + + /* + * If we're unlucky the migration code might be stuck somewhere in a + * send/write while the network has failed and is waiting to timeout; + * if we've got shutdown(2) available then we can force it to quit. + * The outgoing qemu file gets closed in migrate_fd_cleanup that is + * called in a bh, so there is no race against this cancel. + */ + if (s->state == MIG_STATE_CANCELLING && f) { + qemu_file_shutdown(f); + } } void add_migration_state_change_notifier(Notifier *notify) -- 2.1.0