aboutsummaryrefslogtreecommitdiff
path: root/migration/migration.c
diff options
context:
space:
mode:
authorDr. David Alan Gilbert <dgilbert@redhat.com>2015-01-08 11:11:32 +0000
committerAmit Shah <amit.shah@redhat.com>2015-01-16 13:06:17 +0530
commita26ba26e214911dc879a23e797d2c269cdb38577 (patch)
treef3c6e46ac8d221e53554cc5503c967fbed5a80dd /migration/migration.c
parent131fe9b843f9a1e55fcbf2457c9cb25c3711b9d8 (diff)
migration_cancel: shutdown migration socket
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 <dgilbert@redhat.com> Reviewed-by: Paolo Bonzini <pbonzini@redhat.com> Reviewed-by: Amit Shah <amit.shah@redhat.com> Signed-off-by: Amit Shah <amit.shah@redhat.com>
Diffstat (limited to 'migration/migration.c')
-rw-r--r--migration/migration.c12
1 files changed, 12 insertions, 0 deletions
diff --git a/migration/migration.c b/migration/migration.c
index c49a05a165..b3adbc653a 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)