Blame 0204-spice-migration-add-QEVENT_SPICE_MIGRATE_COMPLETED.patch

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