add files in repository from qemu-1.2.0-24.el6.src.rpm
[packages/centos6/qemu.git] / 0103-spice-migration-add-QEVENT_SPICE_MIGRATE_COMPLETED.patch
1 From 8470a0f943e8605739b7bc0081507f787bed412d Mon Sep 17 00:00:00 2001
2 From: Yonit Halperin <yhalperi@redhat.com>
3 Date: Tue, 21 Aug 2012 11:51:57 +0300
4 Subject: [PATCH] spice migration: add QEVENT_SPICE_MIGRATE_COMPLETED
5
6 When migrating, libvirt queries the migration status, and upon migration
7 completions, it closes the migration src. On the other hand, when
8 migration is completed, spice transfers data from the src to destination
9 via the client. This data is required for keeping the spice session
10 after migration, without suffering from data loss and inconsistencies.
11 In order to allow this data transfer, we add QEVENT for signaling
12 libvirt that spice migration has completed, and libvirt needs to wait
13 for this event before quitting the src process.
14
15 Signed-off-by: Yonit Halperin <yhalperi@redhat.com>
16 Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
17 (cherry picked from commit 2fdd16e239c2a2763aa3266e637718123328688c)
18
19 Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
20 ---
21  monitor.c       | 1 +
22  monitor.h       | 1 +
23  ui/spice-core.c | 9 ++++++++-
24  3 files changed, 10 insertions(+), 1 deletion(-)
25
26 diff --git a/monitor.c b/monitor.c
27 index 29e4287..f45cf92 100644
28 --- a/monitor.c
29 +++ b/monitor.c
30 @@ -455,6 +455,7 @@ static const char *monitor_event_names[] = {
31      [QEVENT_SUSPEND_DISK] = "SUSPEND_DISK",
32      [QEVENT_WAKEUP] = "WAKEUP",
33      [QEVENT_BALLOON_CHANGE] = "BALLOON_CHANGE",
34 +    [QEVENT_SPICE_MIGRATE_COMPLETED] = "SPICE_MIGRATE_COMPLETED",
35  };
36  QEMU_BUILD_BUG_ON(ARRAY_SIZE(monitor_event_names) != QEVENT_MAX)
37  
38 diff --git a/monitor.h b/monitor.h
39 index 47d556b..5fc2983 100644
40 --- a/monitor.h
41 +++ b/monitor.h
42 @@ -43,6 +43,7 @@ typedef enum MonitorEvent {
43      QEVENT_SUSPEND_DISK,
44      QEVENT_WAKEUP,
45      QEVENT_BALLOON_CHANGE,
46 +    QEVENT_SPICE_MIGRATE_COMPLETED,
47  
48      /* Add to 'monitor_event_names' array in monitor.c when
49       * defining new events here */
50 diff --git a/ui/spice-core.c b/ui/spice-core.c
51 index 1a7a773..851e869 100644
52 --- a/ui/spice-core.c
53 +++ b/ui/spice-core.c
54 @@ -285,6 +285,7 @@ typedef struct SpiceMigration {
55  } SpiceMigration;
56  
57  static void migrate_connect_complete_cb(SpiceMigrateInstance *sin);
58 +static void migrate_end_complete_cb(SpiceMigrateInstance *sin);
59  
60  static const SpiceMigrateInterface migrate_interface = {
61      .base.type = SPICE_INTERFACE_MIGRATION,
62 @@ -292,7 +293,7 @@ static const SpiceMigrateInterface migrate_interface = {
63      .base.major_version = SPICE_INTERFACE_MIGRATION_MAJOR,
64      .base.minor_version = SPICE_INTERFACE_MIGRATION_MINOR,
65      .migrate_connect_complete = migrate_connect_complete_cb,
66 -    .migrate_end_complete = NULL,
67 +    .migrate_end_complete = migrate_end_complete_cb,
68  };
69  
70  static SpiceMigration spice_migrate;
71 @@ -305,6 +306,11 @@ static void migrate_connect_complete_cb(SpiceMigrateInstance *sin)
72      }
73      sm->connect_complete.cb = NULL;
74  }
75 +
76 +static void migrate_end_complete_cb(SpiceMigrateInstance *sin)
77 +{
78 +    monitor_protocol_event(QEVENT_SPICE_MIGRATE_COMPLETED, NULL);
79 +}
80  #endif
81  
82  /* config string parsing */
83 @@ -489,6 +495,7 @@ static void migration_state_notifier(Notifier *notifier, void *data)
84      } else if (migration_has_finished(s)) {
85  #ifndef SPICE_INTERFACE_MIGRATION
86          spice_server_migrate_switch(spice_server);
87 +        monitor_protocol_event(QEVENT_SPICE_MIGRATE_COMPLETED, NULL);
88  #else
89          spice_server_migrate_end(spice_server, true);
90      } else if (migration_has_failed(s)) {
91 -- 
92 1.7.12.1
93