summaryrefslogtreecommitdiffstats
path: root/server/main_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/main_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/main_channel.c')
-rw-r--r--server/main_channel.c45
1 files changed, 34 insertions, 11 deletions
diff --git a/server/main_channel.c b/server/main_channel.c
index 6acb134c..75accac7 100644
--- a/server/main_channel.c
+++ b/server/main_channel.c
@@ -418,11 +418,31 @@ static void main_channel_marshall_migrate_data_item(SpiceMarshaller *m, int seri
data->ping_id = ping_id;
}
-static void main_channel_receive_migrate_data(MainChannel *main_chan,
- MainMigrateData *data, uint8_t *end)
+static uint64_t main_channel_handle_migrate_data_get_serial(RedChannel *base,
+ uint32_t size, void *message)
{
- red_channel_set_message_serial(&main_chan->base, data->serial);
+ MainMigrateData *data = message;
+
+ if (size < sizeof(*data)) {
+ red_printf("bad message size");
+ return 0;
+ }
+ return data->serial;
+}
+
+static uint64_t main_channel_handle_migrate_data(RedChannel *base,
+ uint32_t size, void *message)
+{
+ MainChannel *main_chan = SPICE_CONTAINEROF(base, MainChannel, base);
+ MainMigrateData *data = message;
+
+ if (size < sizeof(*data)) {
+ red_printf("bad message size");
+ return FALSE;
+ }
main_chan->ping_id = data->ping_id;
+ reds_on_main_receive_migrate_data(data, ((uint8_t*)message) + size);
+ return TRUE;
}
void main_channel_push_init(Channel *channel, int connection_id,
@@ -729,15 +749,9 @@ static int main_channel_handle_parsed(RedChannel *channel, uint32_t size, uint16
break;
}
case SPICE_MSGC_MIGRATE_FLUSH_MARK:
- main_channel_push_migrate_data_item(main_chan);
break;
case SPICE_MSGC_MIGRATE_DATA: {
- MainMigrateData *data = (MainMigrateData *)message;
- uint8_t *end = ((uint8_t *)message) + size;
- main_channel_receive_migrate_data(main_chan, data, end);
- reds_on_main_receive_migrate_data(data, end);
- break;
- }
+ }
case SPICE_MSGC_DISCONNECTING:
break;
default:
@@ -772,6 +786,12 @@ static void main_channel_hold_pipe_item(RedChannel *channel, PipeItem *item)
{
}
+static int main_channel_handle_migrate_flush_mark(RedChannel *base)
+{
+ main_channel_push_migrate_data_item(SPICE_CONTAINEROF(base, MainChannel, base));
+ return TRUE;
+}
+
static void main_channel_link(Channel *channel, RedsStream *stream, int migration,
int num_common_caps, uint32_t *common_caps, int num_caps,
uint32_t *caps)
@@ -791,7 +811,10 @@ static void main_channel_link(Channel *channel, RedsStream *stream, int migratio
,main_channel_send_item
,main_channel_release_pipe_item
,main_channel_on_error
- ,main_channel_on_error);
+ ,main_channel_on_error
+ ,main_channel_handle_migrate_flush_mark
+ ,main_channel_handle_migrate_data
+ ,main_channel_handle_migrate_data_get_serial);
ASSERT(main_chan);
channel->data = main_chan;
}