thebeanogamer / rpms / qemu-kvm

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