From: Marc-André Lureau <marcandre.lureau@xxxxxxxxxx> This is useful to associate an interface instance with a channel. --- server/inputs_channel.c | 1 + server/main_channel.c | 4 +++- server/red_channel.c | 8 ++++++-- server/red_channel.h | 5 ++++- server/red_worker.c | 10 ++++++++-- server/smartcard.c | 1 + server/snd_worker.c | 8 ++++++-- server/spice.h | 2 ++ server/spicevmc.c | 1 + 9 files changed, 32 insertions(+), 8 deletions(-) diff --git a/server/inputs_channel.c b/server/inputs_channel.c index dd8f5ae..dc3fac4 100644 --- a/server/inputs_channel.c +++ b/server/inputs_channel.c @@ -648,6 +648,7 @@ void inputs_init(void) g_inputs_channel = (InputsChannel *)red_channel_create_parser( sizeof(InputsChannel), + NULL, core, SPICE_CHANNEL_INPUTS, 0, FALSE, /* handle_acks */ diff --git a/server/main_channel.c b/server/main_channel.c index 54718ba..a6ba7d6 100644 --- a/server/main_channel.c +++ b/server/main_channel.c @@ -1204,7 +1204,9 @@ MainChannel* main_channel_init(void) channel_cbs.handle_migrate_data = main_channel_handle_migrate_data; // TODO: set the migration flag of the channel - channel = red_channel_create_parser(sizeof(MainChannel), core, + channel = red_channel_create_parser(sizeof(MainChannel), + NULL, + core, SPICE_CHANNEL_MAIN, 0, FALSE, /* handle_acks */ spice_get_client_channel_parser(SPICE_CHANNEL_MAIN, NULL), diff --git a/server/red_channel.c b/server/red_channel.c index 24a8b64..f1eb912 100644 --- a/server/red_channel.c +++ b/server/red_channel.c @@ -1020,6 +1020,7 @@ void red_channel_client_default_migrate(RedChannelClient *rcc) } RedChannel *red_channel_create(int size, + SpiceBaseInstance *sin, SpiceCoreInterface *core, uint32_t type, uint32_t id, int handle_acks, @@ -1041,6 +1042,7 @@ RedChannel *red_channel_create(int size, channel->refs = 1; channel->handle_acks = handle_acks; channel->migration_flags = migration_flags; + channel->sin = sin; memcpy(&channel->channel_cbs, channel_cbs, sizeof(ChannelCbs)); channel->core = core; @@ -1098,7 +1100,7 @@ SpiceCoreInterface dummy_core = { .watch_remove = dummy_watch_remove, }; -RedChannel *red_channel_create_dummy(int size, uint32_t type, uint32_t id) +RedChannel *red_channel_create_dummy(int size, SpiceBaseInstance *sin, uint32_t type, uint32_t id) { RedChannel *channel; ClientCbs client_cbs = { NULL, }; @@ -1109,6 +1111,7 @@ RedChannel *red_channel_create_dummy(int size, uint32_t type, uint32_t id) channel->id = id; channel->refs = 1; channel->core = &dummy_core; + channel->sin = sin; ring_init(&channel->clients); client_cbs.connect = red_channel_client_default_connect; client_cbs.disconnect = red_channel_client_default_disconnect; @@ -1135,6 +1138,7 @@ static int do_nothing_handle_message(RedChannelClient *rcc, } RedChannel *red_channel_create_parser(int size, + SpiceBaseInstance *sin, SpiceCoreInterface *core, uint32_t type, uint32_t id, int handle_acks, @@ -1143,7 +1147,7 @@ RedChannel *red_channel_create_parser(int size, ChannelCbs *channel_cbs, uint32_t migration_flags) { - RedChannel *channel = red_channel_create(size, core, type, id, + RedChannel *channel = red_channel_create(size, sin, core, type, id, handle_acks, do_nothing_handle_message, channel_cbs, diff --git a/server/red_channel.h b/server/red_channel.h index 9e54dce..12bc640 100644 --- a/server/red_channel.h +++ b/server/red_channel.h @@ -308,6 +308,7 @@ struct RedChannel { RingItem link; // channels link for reds + SpiceBaseInstance *sin; SpiceCoreInterface *core; int handle_acks; @@ -353,6 +354,7 @@ struct RedChannel { /* if one of the callbacks should cause disconnect, use red_channel_shutdown and don't * explicitly destroy the channel */ RedChannel *red_channel_create(int size, + SpiceBaseInstance *sin, SpiceCoreInterface *core, uint32_t type, uint32_t id, int handle_acks, @@ -363,6 +365,7 @@ RedChannel *red_channel_create(int size, /* alternative constructor, meant for marshaller based (inputs,main) channels, * will become default eventually */ RedChannel *red_channel_create_parser(int size, + SpiceBaseInstance *sin, SpiceCoreInterface *core, uint32_t type, uint32_t id, int handle_acks, @@ -385,7 +388,7 @@ RedChannelClient *red_channel_client_create(int size, RedChannel *channel, RedCl // TODO: tmp, for channels that don't use RedChannel yet (e.g., snd channel), but // do use the client callbacks. So the channel clients are not connected (the channel doesn't // have list of them, but they do have a link to the channel, and the client has a list of them) -RedChannel *red_channel_create_dummy(int size, uint32_t type, uint32_t id); +RedChannel *red_channel_create_dummy(int size, SpiceBaseInstance *sin, uint32_t type, uint32_t id); RedChannelClient *red_channel_client_create_dummy(int size, RedChannel *channel, RedClient *client, diff --git a/server/red_worker.c b/server/red_worker.c index afbdd91..d9c1fc5 100644 --- a/server/red_worker.c +++ b/server/red_worker.c @@ -10308,7 +10308,9 @@ CursorChannelClient *cursor_channel_create_rcc(CommonChannel *common, return ccc; } -static RedChannel *__new_channel(RedWorker *worker, int size, uint32_t channel_type, +static RedChannel *__new_channel(RedWorker *worker, int size, + SpiceBaseInstance *sin, + uint32_t channel_type, int migration_flags, channel_disconnect_proc on_disconnect, channel_send_pipe_item_proc send_item, @@ -10334,7 +10336,9 @@ static RedChannel *__new_channel(RedWorker *worker, int size, uint32_t channel_t channel_cbs.handle_migrate_data = handle_migrate_data; channel_cbs.handle_migrate_data_get_serial = migrate_get_serial; - channel = red_channel_create_parser(size, &worker_core, + channel = red_channel_create_parser(size, + sin, + &worker_core, channel_type, worker->id, TRUE /* handle_acks */, spice_get_client_channel_parser(channel_type, NULL), @@ -10497,6 +10501,7 @@ static void display_channel_create(RedWorker *worker, int migrate) spice_info("create display channel"); if (!(worker->display_channel = (DisplayChannel *)__new_channel( worker, sizeof(*display_channel), + SPICE_BASE_INSTANCE(worker->qxl), SPICE_CHANNEL_DISPLAY, SPICE_MIGRATE_NEED_FLUSH | SPICE_MIGRATE_NEED_DATA_TRANSFER, display_channel_client_on_disconnect, @@ -10752,6 +10757,7 @@ static void cursor_channel_create(RedWorker *worker, int migrate) spice_info("create cursor channel"); worker->cursor_channel = (CursorChannel *)__new_channel( worker, sizeof(*worker->cursor_channel), + SPICE_BASE_INSTANCE(worker->qxl), SPICE_CHANNEL_CURSOR, 0, cursor_channel_client_on_disconnect, diff --git a/server/smartcard.c b/server/smartcard.c index aad22aa..c6323ae 100644 --- a/server/smartcard.c +++ b/server/smartcard.c @@ -842,6 +842,7 @@ static void smartcard_init(void) channel_cbs.handle_migrate_data = smartcard_channel_client_handle_migrate_data; g_smartcard_channel = (SmartCardChannel*)red_channel_create(sizeof(SmartCardChannel), + NULL, core, SPICE_CHANNEL_SMARTCARD, 0, FALSE /* handle_acks */, smartcard_channel_handle_message, diff --git a/server/snd_worker.c b/server/snd_worker.c index 9156bf5..41cf4d2 100644 --- a/server/snd_worker.c +++ b/server/snd_worker.c @@ -1490,7 +1490,9 @@ void snd_attach_playback(SpicePlaybackInstance *sin) playback_worker = &sin->st->worker; // TODO: Make RedChannel base of worker? instead of assigning it to channel->data - channel = red_channel_create_dummy(sizeof(RedChannel), SPICE_CHANNEL_PLAYBACK, 0); + channel = red_channel_create_dummy(sizeof(RedChannel), + SPICE_BASE_INSTANCE(sin), + SPICE_CHANNEL_PLAYBACK, 0); channel->data = playback_worker; client_cbs.connect = snd_set_playback_peer; @@ -1517,7 +1519,9 @@ void snd_attach_record(SpiceRecordInstance *sin) record_worker = &sin->st->worker; // TODO: Make RedChannel base of worker? instead of assigning it to channel->data - channel = red_channel_create_dummy(sizeof(RedChannel), SPICE_CHANNEL_RECORD, 0); + channel = red_channel_create_dummy(sizeof(RedChannel), + SPICE_BASE_INSTANCE(sin), + SPICE_CHANNEL_RECORD, 0); channel->data = record_worker; client_cbs.connect = snd_set_record_peer; diff --git a/server/spice.h b/server/spice.h index b645112..03e7bd8 100644 --- a/server/spice.h +++ b/server/spice.h @@ -46,6 +46,8 @@ struct SpiceBaseInstance { const SpiceBaseInterface *sif; }; +#define SPICE_BASE_INSTANCE(sin) ((SpiceBaseInstance*)sin) + /* core interface */ #define SPICE_INTERFACE_CORE "core" diff --git a/server/spicevmc.c b/server/spicevmc.c index e10f183..7897312 100644 --- a/server/spicevmc.c +++ b/server/spicevmc.c @@ -519,6 +519,7 @@ SpiceCharDeviceState *spicevmc_device_connect(SpiceCharDeviceInstance *sin, channel_cbs.handle_migrate_data = spicevmc_channel_client_handle_migrate_data; state = (SpiceVmcState*)red_channel_create(sizeof(SpiceVmcState), + SPICE_BASE_INSTANCE(sin), core, channel_type, id[channel_type]++, FALSE /* handle_acks */, spicevmc_red_channel_client_handle_message, -- 1.8.3.1 _______________________________________________ Spice-devel mailing list Spice-devel@xxxxxxxxxxxxxxxxxxxxx http://lists.freedesktop.org/mailman/listinfo/spice-devel