5544c1b
From 8470a0f943e8605739b7bc0081507f787bed412d Mon Sep 17 00:00:00 2001
c8dfc65
From: Yonit Halperin <yhalperi@redhat.com>
c8dfc65
Date: Tue, 21 Aug 2012 11:51:57 +0300
5544c1b
Subject: [PATCH] spice migration: add QEVENT_SPICE_MIGRATE_COMPLETED
c8dfc65
c8dfc65
When migrating, libvirt queries the migration status, and upon migration
c8dfc65
completions, it closes the migration src. On the other hand, when
c8dfc65
migration is completed, spice transfers data from the src to destination
c8dfc65
via the client. This data is required for keeping the spice session
c8dfc65
after migration, without suffering from data loss and inconsistencies.
c8dfc65
In order to allow this data transfer, we add QEVENT for signaling
c8dfc65
libvirt that spice migration has completed, and libvirt needs to wait
c8dfc65
for this event before quitting the src process.
c8dfc65
c8dfc65
Signed-off-by: Yonit Halperin <yhalperi@redhat.com>
c8dfc65
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
5544c1b
(cherry picked from commit 2fdd16e239c2a2763aa3266e637718123328688c)
5544c1b
5544c1b
Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
c8dfc65
---
c8dfc65
 monitor.c       | 1 +
c8dfc65
 monitor.h       | 1 +
c8dfc65
 ui/spice-core.c | 9 ++++++++-
c8dfc65
 3 files changed, 10 insertions(+), 1 deletion(-)
c8dfc65
c8dfc65
diff --git a/monitor.c b/monitor.c
5544c1b
index 29e4287..f45cf92 100644
c8dfc65
--- a/monitor.c
c8dfc65
+++ b/monitor.c
c8dfc65
@@ -455,6 +455,7 @@ static const char *monitor_event_names[] = {
c8dfc65
     [QEVENT_SUSPEND_DISK] = "SUSPEND_DISK",
c8dfc65
     [QEVENT_WAKEUP] = "WAKEUP",
c8dfc65
     [QEVENT_BALLOON_CHANGE] = "BALLOON_CHANGE",
c8dfc65
+    [QEVENT_SPICE_MIGRATE_COMPLETED] = "SPICE_MIGRATE_COMPLETED",
c8dfc65
 };
c8dfc65
 QEMU_BUILD_BUG_ON(ARRAY_SIZE(monitor_event_names) != QEVENT_MAX)
c8dfc65
 
c8dfc65
diff --git a/monitor.h b/monitor.h
c8dfc65
index 47d556b..5fc2983 100644
c8dfc65
--- a/monitor.h
c8dfc65
+++ b/monitor.h
c8dfc65
@@ -43,6 +43,7 @@ typedef enum MonitorEvent {
c8dfc65
     QEVENT_SUSPEND_DISK,
c8dfc65
     QEVENT_WAKEUP,
c8dfc65
     QEVENT_BALLOON_CHANGE,
c8dfc65
+    QEVENT_SPICE_MIGRATE_COMPLETED,
c8dfc65
 
c8dfc65
     /* Add to 'monitor_event_names' array in monitor.c when
c8dfc65
      * defining new events here */
c8dfc65
diff --git a/ui/spice-core.c b/ui/spice-core.c
c8dfc65
index 1a7a773..851e869 100644
c8dfc65
--- a/ui/spice-core.c
c8dfc65
+++ b/ui/spice-core.c
c8dfc65
@@ -285,6 +285,7 @@ typedef struct SpiceMigration {
c8dfc65
 } SpiceMigration;
c8dfc65
 
c8dfc65
 static void migrate_connect_complete_cb(SpiceMigrateInstance *sin);
c8dfc65
+static void migrate_end_complete_cb(SpiceMigrateInstance *sin);
c8dfc65
 
c8dfc65
 static const SpiceMigrateInterface migrate_interface = {
c8dfc65
     .base.type = SPICE_INTERFACE_MIGRATION,
c8dfc65
@@ -292,7 +293,7 @@ static const SpiceMigrateInterface migrate_interface = {
c8dfc65
     .base.major_version = SPICE_INTERFACE_MIGRATION_MAJOR,
c8dfc65
     .base.minor_version = SPICE_INTERFACE_MIGRATION_MINOR,
c8dfc65
     .migrate_connect_complete = migrate_connect_complete_cb,
c8dfc65
-    .migrate_end_complete = NULL,
c8dfc65
+    .migrate_end_complete = migrate_end_complete_cb,
c8dfc65
 };
c8dfc65
 
c8dfc65
 static SpiceMigration spice_migrate;
c8dfc65
@@ -305,6 +306,11 @@ static void migrate_connect_complete_cb(SpiceMigrateInstance *sin)
c8dfc65
     }
c8dfc65
     sm->connect_complete.cb = NULL;
c8dfc65
 }
c8dfc65
+
c8dfc65
+static void migrate_end_complete_cb(SpiceMigrateInstance *sin)
c8dfc65
+{
c8dfc65
+    monitor_protocol_event(QEVENT_SPICE_MIGRATE_COMPLETED, NULL);
c8dfc65
+}
c8dfc65
 #endif
c8dfc65
 
c8dfc65
 /* config string parsing */
c8dfc65
@@ -489,6 +495,7 @@ static void migration_state_notifier(Notifier *notifier, void *data)
c8dfc65
     } else if (migration_has_finished(s)) {
c8dfc65
 #ifndef SPICE_INTERFACE_MIGRATION
c8dfc65
         spice_server_migrate_switch(spice_server);
c8dfc65
+        monitor_protocol_event(QEVENT_SPICE_MIGRATE_COMPLETED, NULL);
c8dfc65
 #else
c8dfc65
         spice_server_migrate_end(spice_server, true);
c8dfc65
     } else if (migration_has_failed(s)) {