qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: "Dr. David Alan Gilbert (git)" <dgilbert@redhat.com>
To: qemu-devel@nongnu.org
Cc: amit.shah@redhat.com, cristian.klein@cs.umu.se, quintela@redhat.com
Subject: [Qemu-devel] [PATCH 3/3] migration_cancel: shutdown migration socket
Date: Thu,  8 Jan 2015 11:11:32 +0000	[thread overview]
Message-ID: <1420715492-5109-4-git-send-email-dgilbert@redhat.com> (raw)
In-Reply-To: <1420715492-5109-1-git-send-email-dgilbert@redhat.com>

From: "Dr. David Alan Gilbert" <dgilbert@redhat.com>

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>
---
 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

  parent reply	other threads:[~2015-01-08 11:11 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-01-08 11:11 [Qemu-devel] [PATCH 0/3] Migration cancel with dead network Dr. David Alan Gilbert (git)
2015-01-08 11:11 ` [Qemu-devel] [PATCH 1/3] socket shutdown Dr. David Alan Gilbert (git)
2015-01-09  6:50   ` Amit Shah
2015-01-08 11:11 ` [Qemu-devel] [PATCH 2/3] Handle bi-directional communication for fd migration Dr. David Alan Gilbert (git)
2015-01-08 11:11 ` Dr. David Alan Gilbert (git) [this message]
2015-01-08 11:22 ` [Qemu-devel] [PATCH 0/3] Migration cancel with dead network Daniel P. Berrange
2015-01-08 11:29   ` Dr. David Alan Gilbert
2015-01-08 11:33     ` Daniel P. Berrange
2015-01-08 12:10 ` Paolo Bonzini
2015-01-09  6:50 ` Amit Shah

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1420715492-5109-4-git-send-email-dgilbert@redhat.com \
    --to=dgilbert@redhat.com \
    --cc=amit.shah@redhat.com \
    --cc=cristian.klein@cs.umu.se \
    --cc=qemu-devel@nongnu.org \
    --cc=quintela@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).