yeahuh / rpms / qemu-kvm

Forked from rpms/qemu-kvm 2 years ago
Clone

Blame SOURCES/kvm-migration-notify-migration-state-before-starting-thread.patch

218e99
From cfa096accd51fe9b1dfa9693ce6f4628a4e83fe6 Mon Sep 17 00:00:00 2001
218e99
From: Stefan Hajnoczi <stefanha@redhat.com>
218e99
Date: Tue, 13 Aug 2013 09:06:35 +0200
218e99
Subject: migration: notify migration state before starting thread
218e99
218e99
RH-Author: Stefan Hajnoczi <stefanha@redhat.com>
218e99
Message-id: <1376384797-4701-5-git-send-email-stefanha@redhat.com>
218e99
Patchwork-id: 53209
218e99
O-Subject: [PATCH v2 4/6] migration: notify migration state before starting thread
218e99
Bugzilla: 995030
218e99
RH-Acked-by: Laszlo Ersek <lersek@redhat.com>
218e99
RH-Acked-by: Kevin Wolf <kwolf@redhat.com>
218e99
RH-Acked-by: Michael S. Tsirkin <mst@redhat.com>
218e99
218e99
The migration thread runs outside the QEMU global mutex when possible.
218e99
Therefore we must notify migration state change *before* starting the
218e99
migration thread.
218e99
218e99
This allows registered listeners to act before live migration iterations
218e99
begin.  Therefore they can get into a state that allows for live
218e99
migration.  When the migration thread starts everything will be ready.
218e99
218e99
Without this patch there is a race condition during migration setup,
218e99
depending on whether the migration thread has already transitioned from
218e99
SETUP to ACTIVE state.
218e99
218e99
Acked-by: Paolo Bonzini <pbonzini@redhat.com>
218e99
Reviewed-by: Kevin Wolf <kwolf@redhat.com>
218e99
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
218e99
(cherry picked from commit 9287ac271d83166f99e050a0e0a4ebd462f7eb2b)
218e99
218e99
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
218e99
218e99
diff --git a/migration.c b/migration.c
218e99
index 6e29f72..177fc22 100644
218e99
--- a/migration.c
218e99
+++ b/migration.c
218e99
@@ -601,7 +601,9 @@ void migrate_fd_connect(MigrationState *s)
218e99
     qemu_file_set_rate_limit(s->file,
218e99
                              s->bandwidth_limit / XFER_LIMIT_RATIO);
218e99
 
218e99
+    /* Notify before starting migration thread */
218e99
+    notifier_list_notify(&migration_state_notifiers, s);
218e99
+
218e99
     qemu_thread_create(&s->thread, migration_thread, s,
218e99
                        QEMU_THREAD_JOINABLE);
218e99
-    notifier_list_notify(&migration_state_notifiers, s);
218e99
 }