Change requested in launchpad bug #1288352
[packages/centos6/qemu.git] / 0104-spice-add-migrated-flag-to-spice-info.patch
1 From a4155f1a9fac362bfc1558790de9ea4cdb0a3c8a Mon Sep 17 00:00:00 2001
2 From: Yonit Halperin <yhalperi@redhat.com>
3 Date: Tue, 21 Aug 2012 11:51:58 +0300
4 Subject: [PATCH] spice: add 'migrated' flag to spice info
5
6 The flag is 'true' when spice migration has completed on the src side.
7 It is needed for a case where libvirt dies before migration completes
8 and it misses the event QEVENT_SPICE_MIGRATE_COMPLETED.
9 When libvirt is restored and queries the migration status, it also needs
10 to query spice and check if its migration has completed.
11
12 Signed-off-by: Yonit Halperin <yhalperi@redhat.com>
13 Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
14 (cherry picked from commit 61c4efe2cb85b0a9c6bc68f6a2dd107c8d7ec080)
15
16 Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
17 ---
18  hmp.c            | 2 ++
19  qapi-schema.json | 5 ++++-
20  ui/spice-core.c  | 4 ++++
21  3 files changed, 10 insertions(+), 1 deletion(-)
22
23 diff --git a/hmp.c b/hmp.c
24 index 81c8acb..ec4274b 100644
25 --- a/hmp.c
26 +++ b/hmp.c
27 @@ -413,6 +413,8 @@ void hmp_info_spice(Monitor *mon)
28          monitor_printf(mon, "     address: %s:%" PRId64 " [tls]\n",
29                         info->host, info->tls_port);
30      }
31 +    monitor_printf(mon, "    migrated: %s\n",
32 +                   info->migrated ? "true" : "false");
33      monitor_printf(mon, "        auth: %s\n", info->auth);
34      monitor_printf(mon, "    compiled: %s\n", info->compiled_version);
35      monitor_printf(mon, "  mouse-mode: %s\n",
36 diff --git a/qapi-schema.json b/qapi-schema.json
37 index bd8ad74..8ddde12 100644
38 --- a/qapi-schema.json
39 +++ b/qapi-schema.json
40 @@ -808,6 +808,9 @@
41  #
42  # @enabled: true if the SPICE server is enabled, false otherwise
43  #
44 +# @migrated: true if the last guest migration completed and spice
45 +#            migration had completed as well. false otherwise.
46 +#
47  # @host: #optional The hostname the SPICE server is bound to.  This depends on
48  #        the name resolution on the host and may be an IP address.
49  #
50 @@ -833,7 +836,7 @@
51  # Since: 0.14.0
52  ##
53  { 'type': 'SpiceInfo',
54 -  'data': {'enabled': 'bool', '*host': 'str', '*port': 'int',
55 +  'data': {'enabled': 'bool', 'migrated': 'bool', '*host': 'str', '*port': 'int',
56             '*tls-port': 'int', '*auth': 'str', '*compiled-version': 'str',
57             'mouse-mode': 'SpiceQueryMouseMode', '*channels': ['SpiceChannel']} }
58  
59 diff --git a/ui/spice-core.c b/ui/spice-core.c
60 index 851e869..ab069c5 100644
61 --- a/ui/spice-core.c
62 +++ b/ui/spice-core.c
63 @@ -46,6 +46,7 @@ static Notifier migration_state;
64  static const char *auth = "spice";
65  static char *auth_passwd;
66  static time_t auth_expires = TIME_MAX;
67 +static int spice_migration_completed;
68  int using_spice = 0;
69  
70  static QemuThread me;
71 @@ -310,6 +311,7 @@ static void migrate_connect_complete_cb(SpiceMigrateInstance *sin)
72  static void migrate_end_complete_cb(SpiceMigrateInstance *sin)
73  {
74      monitor_protocol_event(QEVENT_SPICE_MIGRATE_COMPLETED, NULL);
75 +    spice_migration_completed = true;
76  }
77  #endif
78  
79 @@ -443,6 +445,7 @@ SpiceInfo *qmp_query_spice(Error **errp)
80      }
81  
82      info->enabled = true;
83 +    info->migrated = spice_migration_completed;
84  
85      addr = qemu_opt_get(opts, "addr");
86      port = qemu_opt_get_number(opts, "port", 0);
87 @@ -496,6 +499,7 @@ static void migration_state_notifier(Notifier *notifier, void *data)
88  #ifndef SPICE_INTERFACE_MIGRATION
89          spice_server_migrate_switch(spice_server);
90          monitor_protocol_event(QEVENT_SPICE_MIGRATE_COMPLETED, NULL);
91 +        spice_migration_completed = true;
92  #else
93          spice_server_migrate_end(spice_server, true);
94      } else if (migration_has_failed(s)) {
95 -- 
96 1.7.12.1
97