Patchwork [RFC,5/5] spice: turn spice "migration end" handler to be async

login
register
mail settings
Submitter Yonit Halperin
Date June 5, 2012, 5:49 a.m.
Message ID <1338875386-21051-6-git-send-email-yhalperi@redhat.com>
Download mbox | patch
Permalink /patch/163020/
State New
Headers show

Comments

Yonit Halperin - June 5, 2012, 5:49 a.m.
Instead of immediatly calling the notifier completion callback,
the notification handler assigns a completion callback
to spice's migration interface. Spice should call this
callback when it completes handling the migration state change.

Signed-off-by: Yonit Halperin <yhalperi@redhat.com>
---
 ui/spice-core.c |   29 ++++++++++++++++++++++-------
 1 files changed, 22 insertions(+), 7 deletions(-)

Patch

diff --git a/ui/spice-core.c b/ui/spice-core.c
index d85c212..053f06f 100644
--- a/ui/spice-core.c
+++ b/ui/spice-core.c
@@ -282,9 +282,14 @@  typedef struct SpiceMigration {
         MonitorCompletion *cb;
         void *opaque;
     } connect_complete;
+    struct {
+        NotifiedCompletionFunc *cb;
+        void *opaque;
+    } end_complete;
 } SpiceMigration;
 
 static void migrate_connect_complete_cb(SpiceMigrateInstance *sin);
+static void migrate_end_complete_cb(SpiceMigrateInstance *sin);
 
 static const SpiceMigrateInterface migrate_interface = {
     .base.type = SPICE_INTERFACE_MIGRATION,
@@ -292,7 +297,7 @@  static const SpiceMigrateInterface migrate_interface = {
     .base.major_version = SPICE_INTERFACE_MIGRATION_MAJOR,
     .base.minor_version = SPICE_INTERFACE_MIGRATION_MINOR,
     .migrate_connect_complete = migrate_connect_complete_cb,
-    .migrate_end_complete = NULL,
+    .migrate_end_complete = migrate_end_complete_cb,
 };
 
 static SpiceMigration spice_migrate;
@@ -305,6 +310,15 @@  static void migrate_connect_complete_cb(SpiceMigrateInstance *sin)
     }
     sm->connect_complete.cb = NULL;
 }
+
+static void migrate_end_complete_cb(SpiceMigrateInstance *sin)
+{
+    SpiceMigration *sm = container_of(sin, SpiceMigration, sin);
+    if (sm->end_complete.cb) {
+        sm->end_complete.cb(&migrate_end_notifier, sm->end_complete.opaque);
+    }
+    sm->end_complete.cb = NULL;
+}
 #endif
 
 /* config string parsing */
@@ -492,16 +506,17 @@  static void migrate_end_notify_func(AsyncNotifier *notifier, void *data,
                                     void *cb_data)
 {
     bool success_end = *(bool *)data;
+
+#ifdef SPICE_INTERFACE_MIGRATION
+    spice_migrate.end_complete.cb = complete_cb;
+    spice_migrate.end_complete.opaque = cb_data;
+    spice_server_migrate_end(spice_server, success_end);
+#else
     if (success_end) {
-#ifndef SPICE_INTERFACE_MIGRATION
         spice_server_migrate_switch(spice_server);
-#else
-        spice_server_migrate_end(spice_server, true);
-    } else {
-        spice_server_migrate_end(spice_server, false);
-#endif
     }
     complete_cb(notifier, cb_data);
+#endif
 }
 
 int qemu_spice_migrate_info(const char *hostname, int port, int tls_port,