Blame 0205-spice-add-migrated-flag-to-spice-info.patch

c8dfc6
From ad7734d7a3cb4560dcc0bef2794adeddc793af75 Mon Sep 17 00:00:00 2001
c8dfc6
From: Yonit Halperin <yhalperi@redhat.com>
c8dfc6
Date: Tue, 21 Aug 2012 11:51:58 +0300
c8dfc6
Subject: [PATCH 205/215] spice: add 'migrated' flag to spice info
c8dfc6
c8dfc6
The flag is 'true' when spice migration has completed on the src side.
c8dfc6
It is needed for a case where libvirt dies before migration completes
c8dfc6
and it misses the event QEVENT_SPICE_MIGRATE_COMPLETED.
c8dfc6
When libvirt is restored and queries the migration status, it also needs
c8dfc6
to query spice and check if its migration has completed.
c8dfc6
c8dfc6
Signed-off-by: Yonit Halperin <yhalperi@redhat.com>
c8dfc6
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
c8dfc6
---
c8dfc6
 hmp.c            | 2 ++
c8dfc6
 qapi-schema.json | 5 ++++-
c8dfc6
 ui/spice-core.c  | 4 ++++
c8dfc6
 3 files changed, 10 insertions(+), 1 deletion(-)
c8dfc6
c8dfc6
diff --git a/hmp.c b/hmp.c
c8dfc6
index 81c8acb..ec4274b 100644
c8dfc6
--- a/hmp.c
c8dfc6
+++ b/hmp.c
c8dfc6
@@ -413,6 +413,8 @@ void hmp_info_spice(Monitor *mon)
c8dfc6
         monitor_printf(mon, "     address: %s:%" PRId64 " [tls]\n",
c8dfc6
                        info->host, info->tls_port);
c8dfc6
     }
c8dfc6
+    monitor_printf(mon, "    migrated: %s\n",
c8dfc6
+                   info->migrated ? "true" : "false");
c8dfc6
     monitor_printf(mon, "        auth: %s\n", info->auth);
c8dfc6
     monitor_printf(mon, "    compiled: %s\n", info->compiled_version);
c8dfc6
     monitor_printf(mon, "  mouse-mode: %s\n",
c8dfc6
diff --git a/qapi-schema.json b/qapi-schema.json
c8dfc6
index bd8ad74..8ddde12 100644
c8dfc6
--- a/qapi-schema.json
c8dfc6
+++ b/qapi-schema.json
c8dfc6
@@ -808,6 +808,9 @@
c8dfc6
 #
c8dfc6
 # @enabled: true if the SPICE server is enabled, false otherwise
c8dfc6
 #
c8dfc6
+# @migrated: true if the last guest migration completed and spice
c8dfc6
+#            migration had completed as well. false otherwise.
c8dfc6
+#
c8dfc6
 # @host: #optional The hostname the SPICE server is bound to.  This depends on
c8dfc6
 #        the name resolution on the host and may be an IP address.
c8dfc6
 #
c8dfc6
@@ -833,7 +836,7 @@
c8dfc6
 # Since: 0.14.0
c8dfc6
 ##
c8dfc6
 { 'type': 'SpiceInfo',
c8dfc6
-  'data': {'enabled': 'bool', '*host': 'str', '*port': 'int',
c8dfc6
+  'data': {'enabled': 'bool', 'migrated': 'bool', '*host': 'str', '*port': 'int',
c8dfc6
            '*tls-port': 'int', '*auth': 'str', '*compiled-version': 'str',
c8dfc6
            'mouse-mode': 'SpiceQueryMouseMode', '*channels': ['SpiceChannel']} }
c8dfc6
 
c8dfc6
diff --git a/ui/spice-core.c b/ui/spice-core.c
c8dfc6
index 851e869..ab069c5 100644
c8dfc6
--- a/ui/spice-core.c
c8dfc6
+++ b/ui/spice-core.c
c8dfc6
@@ -46,6 +46,7 @@ static Notifier migration_state;
c8dfc6
 static const char *auth = "spice";
c8dfc6
 static char *auth_passwd;
c8dfc6
 static time_t auth_expires = TIME_MAX;
c8dfc6
+static int spice_migration_completed;
c8dfc6
 int using_spice = 0;
c8dfc6
 
c8dfc6
 static QemuThread me;
c8dfc6
@@ -310,6 +311,7 @@ static void migrate_connect_complete_cb(SpiceMigrateInstance *sin)
c8dfc6
 static void migrate_end_complete_cb(SpiceMigrateInstance *sin)
c8dfc6
 {
c8dfc6
     monitor_protocol_event(QEVENT_SPICE_MIGRATE_COMPLETED, NULL);
c8dfc6
+    spice_migration_completed = true;
c8dfc6
 }
c8dfc6
 #endif
c8dfc6
 
c8dfc6
@@ -443,6 +445,7 @@ SpiceInfo *qmp_query_spice(Error **errp)
c8dfc6
     }
c8dfc6
 
c8dfc6
     info->enabled = true;
c8dfc6
+    info->migrated = spice_migration_completed;
c8dfc6
 
c8dfc6
     addr = qemu_opt_get(opts, "addr");
c8dfc6
     port = qemu_opt_get_number(opts, "port", 0);
c8dfc6
@@ -496,6 +499,7 @@ static void migration_state_notifier(Notifier *notifier, void *data)
c8dfc6
 #ifndef SPICE_INTERFACE_MIGRATION
c8dfc6
         spice_server_migrate_switch(spice_server);
c8dfc6
         monitor_protocol_event(QEVENT_SPICE_MIGRATE_COMPLETED, NULL);
c8dfc6
+        spice_migration_completed = true;
c8dfc6
 #else
c8dfc6
         spice_server_migrate_end(spice_server, true);
c8dfc6
     } else if (migration_has_failed(s)) {
c8dfc6
-- 
c8dfc6
1.7.12
c8dfc6