yeahuh / rpms / qemu-kvm

Forked from rpms/qemu-kvm 2 years ago
Clone

Blame SOURCES/kvm-migration_cancel-shutdown-migration-socket.patch

9ae3a8
From 8f6bbf90e819d271a62f2b59732d188b51a96128 Mon Sep 17 00:00:00 2001
9ae3a8
From: "Dr. David Alan Gilbert" <dgilbert@redhat.com>
9ae3a8
Date: Fri, 16 Jan 2015 17:35:37 +0100
9ae3a8
Subject: [PATCH 05/16] migration_cancel: shutdown migration socket
9ae3a8
9ae3a8
Message-id: <1421429737-23581-4-git-send-email-dgilbert@redhat.com>
9ae3a8
Patchwork-id: 63334
9ae3a8
O-Subject: [RHEL-7.2 qemu-kvm PATCH 3/3] migration_cancel: shutdown migration socket
9ae3a8
Bugzilla: 1086168
9ae3a8
RH-Acked-by: Paolo Bonzini <pbonzini@redhat.com>
9ae3a8
RH-Acked-by: Amit Shah <amit.shah@redhat.com>
9ae3a8
RH-Acked-by: Laszlo Ersek <lersek@redhat.com>
9ae3a8
9ae3a8
From: "Dr. David Alan Gilbert" <dgilbert@redhat.com>
9ae3a8
9ae3a8
Force shutdown on migration socket on cancel to cause the cancel
9ae3a8
to complete even if the socket is blocked on a dead network.
9ae3a8
9ae3a8
Signed-off-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
9ae3a8
Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
9ae3a8
Reviewed-by: Amit Shah <amit.shah@redhat.com>
9ae3a8
Signed-off-by: Amit Shah <amit.shah@redhat.com>
9ae3a8
(cherry picked from commit a26ba26e214911dc879a23e797d2c269cdb38577)
9ae3a8
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
9ae3a8
9ae3a8
Conflicts:
9ae3a8
	migration.c
9ae3a8
---
9ae3a8
 migration.c | 12 ++++++++++++
9ae3a8
 1 file changed, 12 insertions(+)
9ae3a8
9ae3a8
diff --git a/migration.c b/migration.c
9ae3a8
index 44b993a..e8c5939 100644
9ae3a8
--- a/migration.c
9ae3a8
+++ b/migration.c
9ae3a8
@@ -331,6 +331,7 @@ void migrate_fd_error(MigrationState *s)
9ae3a8
 static void migrate_fd_cancel(MigrationState *s)
9ae3a8
 {
9ae3a8
     int old_state ;
9ae3a8
+    QEMUFile *f = migrate_get_current()->file;
9ae3a8
     DPRINTF("cancelling migration\n");
9ae3a8
 
9ae3a8
     do {
9ae3a8
@@ -340,6 +341,17 @@ static void migrate_fd_cancel(MigrationState *s)
9ae3a8
         }
9ae3a8
         migrate_set_state(s, old_state, MIG_STATE_CANCELLING);
9ae3a8
     } while (s->state != MIG_STATE_CANCELLING);
9ae3a8
+
9ae3a8
+    /*
9ae3a8
+     * If we're unlucky the migration code might be stuck somewhere in a
9ae3a8
+     * send/write while the network has failed and is waiting to timeout;
9ae3a8
+     * if we've got shutdown(2) available then we can force it to quit.
9ae3a8
+     * The outgoing qemu file gets closed in migrate_fd_cleanup that is
9ae3a8
+     * called in a bh, so there is no race against this cancel.
9ae3a8
+     */
9ae3a8
+    if (s->state == MIG_STATE_CANCELLING && f) {
9ae3a8
+        qemu_file_shutdown(f);
9ae3a8
+    }
9ae3a8
 }
9ae3a8
 
9ae3a8
 void add_migration_state_change_notifier(Notifier *notify)
9ae3a8
-- 
9ae3a8
1.8.3.1
9ae3a8