summaryrefslogtreecommitdiffstats
path: root/server/red_channel.c
diff options
context:
space:
mode:
authorAlon Levy <alevy@redhat.com>2010-11-09 22:56:56 +0200
committerAlon Levy <alevy@redhat.com>2011-03-02 17:27:51 +0200
commitce03dcfbb55d38d06e3014a6c489ea82131472fc (patch)
tree332614693c3170276e042a8e061d4c79434f7253 /server/red_channel.c
parent8002a30f9ce4b8cbd00f5ff8ded6f72a297a2240 (diff)
downloadspice-ce03dcfbb55d38d06e3014a6c489ea82131472fc.tar.gz
spice-ce03dcfbb55d38d06e3014a6c489ea82131472fc.tar.xz
spice-ce03dcfbb55d38d06e3014a6c489ea82131472fc.zip
server/red_channel (all): handle MIGRATE_DATA and MIGRATE_FLUSH_DATA
Handling done in red_channel instead of per channel, using call backs for the channel specific part. Intended to reduce furthur reliance of channels on RedChannel struct. The commit makes the code harder to understand because of the artificial get_serial stuff, should later be fixed by having a joint migration header with the serial (since all channels pass it).
Diffstat (limited to 'server/red_channel.c')
-rw-r--r--server/red_channel.c40
1 files changed, 37 insertions, 3 deletions
diff --git a/server/red_channel.c b/server/red_channel.c
index 9028943f..5749dc35 100644
--- a/server/red_channel.c
+++ b/server/red_channel.c
@@ -322,7 +322,10 @@ RedChannel *red_channel_create(int size, RedsStream *stream,
channel_release_msg_recv_buf_proc release_recv_buf,
channel_hold_pipe_item_proc hold_item,
channel_send_pipe_item_proc send_item,
- channel_release_pipe_item_proc release_item)
+ channel_release_pipe_item_proc release_item,
+ channel_handle_migrate_flush_mark handle_migrate_flush_mark,
+ channel_handle_migrate_data handle_migrate_data,
+ channel_handle_migrate_data_get_serial handle_migrate_data_get_serial)
{
RedChannel *channel;
@@ -336,6 +339,9 @@ RedChannel *red_channel_create(int size, RedsStream *stream,
channel->send_item = send_item;
channel->release_item = release_item;
channel->hold_item = hold_item;
+ channel->handle_migrate_flush_mark = handle_migrate_flush_mark;
+ channel->handle_migrate_data = handle_migrate_data;
+ channel->handle_migrate_data_get_serial = handle_migrate_data_get_serial;
channel->stream = stream;
channel->core = core;
@@ -406,12 +412,16 @@ RedChannel *red_channel_create_parser(int size, RedsStream *stream,
channel_send_pipe_item_proc send_item,
channel_release_pipe_item_proc release_item,
channel_on_incoming_error_proc incoming_error,
- channel_on_outgoing_error_proc outgoing_error)
+ channel_on_outgoing_error_proc outgoing_error,
+ channel_handle_migrate_flush_mark handle_migrate_flush_mark,
+ channel_handle_migrate_data handle_migrate_data,
+ channel_handle_migrate_data_get_serial handle_migrate_data_get_serial)
{
RedChannel *channel = red_channel_create(size, stream,
core, migrate, handle_acks, config_socket, do_nothing_disconnect,
do_nothing_handle_message, alloc_recv_buf, release_recv_buf, hold_item,
- send_item, release_item);
+ send_item, release_item, handle_migrate_flush_mark, handle_migrate_data,
+ handle_migrate_data_get_serial);
if (channel == NULL) {
return NULL;
@@ -454,6 +464,24 @@ void red_channel_init_outgoing_messages_window(RedChannel *channel)
red_channel_push(channel);
}
+void red_channel_handle_migrate_flush_mark(RedChannel *channel)
+{
+ if (channel->handle_migrate_flush_mark) {
+ channel->handle_migrate_flush_mark(channel);
+ }
+}
+
+void red_channel_handle_migrate_data(RedChannel *channel, uint32_t size, void *message)
+{
+ if (!channel->handle_migrate_data) {
+ return;
+ }
+ ASSERT(red_channel_get_message_serial(channel) == 0);
+ red_channel_set_message_serial(channel,
+ channel->handle_migrate_data_get_serial(channel, size, message));
+ channel->handle_migrate_data(channel, size, message);
+}
+
int red_channel_handle_message(RedChannel *channel, uint32_t size,
uint16_t type, void *message)
{
@@ -473,6 +501,12 @@ int red_channel_handle_message(RedChannel *channel, uint32_t size,
break;
case SPICE_MSGC_DISCONNECTING:
break;
+ case SPICE_MSGC_MIGRATE_FLUSH_MARK:
+ red_channel_handle_migrate_flush_mark(channel);
+ break;
+ case SPICE_MSGC_MIGRATE_DATA:
+ red_channel_handle_migrate_data(channel, size, message);
+ break;
default:
red_printf("invalid message type %u", type);
return FALSE;