dcavalca / rpms / qemu

Forked from rpms/qemu a year ago
Clone

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

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