peterdelevoryas / rpms / qemu

Forked from rpms/qemu 2 years ago
Clone

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

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