All of lore.kernel.org
 help / color / mirror / Atom feed
From: Gerd Hoffmann <kraxel@redhat.com>
To: qemu-devel@nongnu.org
Cc: Amit Shah <amit.shah@redhat.com>,
	Juan Quintela <quintela@redhat.com>,
	"Dr. David Alan Gilbert" <dgilbert@redhat.com>,
	Gerd Hoffmann <kraxel@redhat.com>
Subject: [Qemu-devel] [PULL 8/8] Postcopy+spice: Pass spice migration data earlier
Date: Tue, 23 Feb 2016 15:24:22 +0100	[thread overview]
Message-ID: <1456237462-3687-9-git-send-email-kraxel@redhat.com> (raw)
In-Reply-To: <1456237462-3687-1-git-send-email-kraxel@redhat.com>

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

Spice hooks the migration status changes to figure out when to
transmit information to the new spice server; but the migration
status in postcopy doesn't quite fit - the destination starts
running before the end of the source migration.

It's not a case of hanging off the migration status change to
postcopy-active either, since that happens before we stop the
guest CPU.

Fix it by sending a notify just after sending the device state,
and adding a flag that can be tested by the notify receiver.

Symptom:
   spice handover doesn't work with the error:
   red_worker.c:11540:display_channel_wait_for_migrate_data: timeout

Signed-off-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
Reviewed-by: Amit Shah <amit.shah@redhat.com>
Message-id: 1456161452-25318-1-git-send-email-dgilbert@redhat.com
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
 include/migration/migration.h |  4 ++++
 migration/migration.c         | 14 ++++++++++++++
 ui/spice-core.c               |  3 ++-
 3 files changed, 20 insertions(+), 1 deletion(-)

diff --git a/include/migration/migration.h b/include/migration/migration.h
index 74684ad..97622e4 100644
--- a/include/migration/migration.h
+++ b/include/migration/migration.h
@@ -159,6 +159,8 @@ struct MigrationState
 
     /* Flag set once the migration has been asked to enter postcopy */
     bool start_postcopy;
+    /* Flag set after postcopy has sent the device state */
+    bool postcopy_after_devices;
 
     /* Flag set once the migration thread is running (and needs joining) */
     bool migration_thread_running;
@@ -212,6 +214,8 @@ bool migration_has_finished(MigrationState *);
 bool migration_has_failed(MigrationState *);
 /* True if outgoing migration has entered postcopy phase */
 bool migration_in_postcopy(MigrationState *);
+/* ...and after the device transmission */
+bool migration_in_postcopy_after_devices(MigrationState *);
 MigrationState *migrate_get_current(void);
 
 void migrate_compress_threads_create(void);
diff --git a/migration/migration.c b/migration/migration.c
index a64cfcd..fc5e50b 100644
--- a/migration/migration.c
+++ b/migration/migration.c
@@ -905,6 +905,11 @@ bool migration_in_postcopy(MigrationState *s)
     return (s->state == MIGRATION_STATUS_POSTCOPY_ACTIVE);
 }
 
+bool migration_in_postcopy_after_devices(MigrationState *s)
+{
+    return migration_in_postcopy(s) && s->postcopy_after_devices;
+}
+
 MigrationState *migrate_init(const MigrationParams *params)
 {
     MigrationState *s = migrate_get_current();
@@ -930,6 +935,7 @@ MigrationState *migrate_init(const MigrationParams *params)
     s->setup_time = 0;
     s->dirty_sync_count = 0;
     s->start_postcopy = false;
+    s->postcopy_after_devices = false;
     s->migration_thread_running = false;
     s->last_req_rb = NULL;
 
@@ -1489,6 +1495,14 @@ static int postcopy_start(MigrationState *ms, bool *old_vm_running)
         goto fail_closefb;
     }
     qemu_fclose(fb);
+
+    /* Send a notify to give a chance for anything that needs to happen
+     * at the transition to postcopy and after the device state; in particular
+     * spice needs to trigger a transition now
+     */
+    ms->postcopy_after_devices = true;
+    notifier_list_notify(&migration_state_notifiers, ms);
+
     ms->downtime =  qemu_clock_get_ms(QEMU_CLOCK_REALTIME) - time_at_stop;
 
     qemu_mutex_unlock_iothread();
diff --git a/ui/spice-core.c b/ui/spice-core.c
index 5abec17..a68a665 100644
--- a/ui/spice-core.c
+++ b/ui/spice-core.c
@@ -573,7 +573,8 @@ static void migration_state_notifier(Notifier *notifier, void *data)
 
     if (migration_in_setup(s)) {
         spice_server_migrate_start(spice_server);
-    } else if (migration_has_finished(s)) {
+    } else if (migration_has_finished(s) ||
+               migration_in_postcopy_after_devices(s)) {
         spice_server_migrate_end(spice_server, true);
         spice_have_target_host = false;
     } else if (migration_has_failed(s)) {
-- 
1.8.3.1

  parent reply	other threads:[~2016-02-23 14:24 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-02-23 14:24 [Qemu-devel] [PULL 0/8] spice: initial opengl/virgl support, postcopy migration fix Gerd Hoffmann
2016-02-23 14:24 ` [Qemu-devel] [PULL 1/8] spice: init dcl before registering qxl interface Gerd Hoffmann
2016-02-23 14:24 ` [Qemu-devel] [PULL 2/8] configure: add dma-buf support detection Gerd Hoffmann
2016-02-26  9:29   ` Paolo Bonzini
2016-02-29 11:00     ` Gerd Hoffmann
2016-02-23 14:24 ` [Qemu-devel] [PULL 3/8] egl-helpers: add functions for render nodes and dma-buf passing Gerd Hoffmann
2016-03-02 14:14   ` Paolo Bonzini
2016-02-23 14:24 ` [Qemu-devel] [PULL 4/8] spice: reset cursor on resize Gerd Hoffmann
2016-02-25 23:10   ` Paolo Bonzini
2016-02-25 23:23     ` Marc-André Lureau
2016-02-25 23:23       ` Paolo Bonzini
2016-02-23 14:24 ` [Qemu-devel] [PULL 5/8] spice: add opengl/virgl/dmabuf support Gerd Hoffmann
2016-02-23 14:24 ` [Qemu-devel] [PULL 6/8] spice/gl: add unblock timer Gerd Hoffmann
2016-02-23 14:24 ` [Qemu-devel] [PULL 7/8] spice/gl: tweak debug messages Gerd Hoffmann
2016-02-23 14:24 ` Gerd Hoffmann [this message]
2016-02-23 16:44 ` [Qemu-devel] [PULL 0/8] spice: initial opengl/virgl support, postcopy migration fix Peter Maydell

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=1456237462-3687-9-git-send-email-kraxel@redhat.com \
    --to=kraxel@redhat.com \
    --cc=amit.shah@redhat.com \
    --cc=dgilbert@redhat.com \
    --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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.