summaryrefslogtreecommitdiffstats
path: root/server/main_dispatcher.c
diff options
context:
space:
mode:
authorYonit Halperin <yhalperi@redhat.com>2012-08-14 14:47:49 +0300
committerYonit Halperin <yhalperi@redhat.com>2012-08-27 09:13:00 +0300
commit275e4312df6c0f13ca2253ceac3976cee7d700e9 (patch)
tree7b49c3f4b54d7382c0a79ecc5cf71cd282362e08 /server/main_dispatcher.c
parenteb4c95b08b6848ee604497bb66392636341ad1fe (diff)
downloadspice-275e4312df6c0f13ca2253ceac3976cee7d700e9.tar.gz
spice-275e4312df6c0f13ca2253ceac3976cee7d700e9.tar.xz
spice-275e4312df6c0f13ca2253ceac3976cee7d700e9.zip
seamless migration: migration completion on the destination side
Tracking the channels that wait for migration data. If there is a new migration process pending, when all the channels have restored their state, we begin the new migration.
Diffstat (limited to 'server/main_dispatcher.c')
-rw-r--r--server/main_dispatcher.c32
1 files changed, 32 insertions, 0 deletions
diff --git a/server/main_dispatcher.c b/server/main_dispatcher.c
index f5b8b4c4..1126ec06 100644
--- a/server/main_dispatcher.c
+++ b/server/main_dispatcher.c
@@ -7,6 +7,8 @@
#include "red_common.h"
#include "dispatcher.h"
#include "main_dispatcher.h"
+#include "red_channel.h"
+#include "reds.h"
/*
* Main Dispatcher
@@ -37,6 +39,7 @@ MainDispatcher main_dispatcher;
enum {
MAIN_DISPATCHER_CHANNEL_EVENT = 0,
+ MAIN_DISPATCHER_MIGRATE_SEAMLESS_DST_COMPLETE,
MAIN_DISPATCHER_NUM_MESSAGES
};
@@ -46,6 +49,10 @@ typedef struct MainDispatcherChannelEventMessage {
SpiceChannelEventInfo *info;
} MainDispatcherChannelEventMessage;
+typedef struct MainDispatcherMigrateSeamlessDstCompleteMessage {
+ RedClient *client;
+} MainDispatcherMigrateSeamlessDstCompleteMessage;
+
/* channel_event - calls core->channel_event, must be done in main thread */
static void main_dispatcher_self_handle_channel_event(
int event,
@@ -80,6 +87,28 @@ void main_dispatcher_channel_event(int event, SpiceChannelEventInfo *info)
&msg);
}
+
+static void main_dispatcher_handle_migrate_complete(void *opaque,
+ void *payload)
+{
+ MainDispatcherMigrateSeamlessDstCompleteMessage *mig_complete = payload;
+
+ reds_on_client_seamless_migrate_complete(mig_complete->client);
+}
+
+void main_dispatcher_seamless_migrate_dst_complete(RedClient *client)
+{
+ MainDispatcherMigrateSeamlessDstCompleteMessage msg;
+
+ if (pthread_self() == main_dispatcher.base.self) {
+ reds_on_client_seamless_migrate_complete(client);
+ return;
+ }
+
+ msg.client = client;
+ dispatcher_send_message(&main_dispatcher.base, MAIN_DISPATCHER_MIGRATE_SEAMLESS_DST_COMPLETE,
+ &msg);
+}
static void dispatcher_handle_read(int fd, int event, void *opaque)
{
Dispatcher *dispatcher = opaque;
@@ -97,4 +126,7 @@ void main_dispatcher_init(SpiceCoreInterface *core)
dispatcher_register_handler(&main_dispatcher.base, MAIN_DISPATCHER_CHANNEL_EVENT,
main_dispatcher_handle_channel_event,
sizeof(MainDispatcherChannelEventMessage), 0 /* no ack */);
+ dispatcher_register_handler(&main_dispatcher.base, MAIN_DISPATCHER_MIGRATE_SEAMLESS_DST_COMPLETE,
+ main_dispatcher_handle_migrate_complete,
+ sizeof(MainDispatcherMigrateSeamlessDstCompleteMessage), 0 /* no ack */);
}