[Spice-devel] [PATCH spice-server v2] Move channel registration to constructed vfunc
Frediano Ziglio
fziglio at redhat.com
Fri Mar 15 09:04:04 UTC 2019
>
> For the Display Channel and the Cursor channel, move the call to
> reds_register_channel() to the _constructed() vfunc rather than calling
> it explicitly from RedWorker. This matches what other channels do.
Acked-by: Frediano Ziglio <fziglio at redhat.com>
> ---
> Changes in v2:
> - remove cursor channel registration in stream device
>
> Note that I didn't implement a couple other suggestions from Frediano's first
> review. Reference
> earlier email reply for justification.
>
> server/cursor-channel.c | 12 ++++++++++++
> server/display-channel.c | 2 ++
> server/red-stream-device.c | 1 -
> server/red-worker.c | 2 --
> 4 files changed, 14 insertions(+), 3 deletions(-)
>
> diff --git a/server/cursor-channel.c b/server/cursor-channel.c
> index 9dd69fa25..4220084f5 100644
> --- a/server/cursor-channel.c
> +++ b/server/cursor-channel.c
> @@ -366,12 +366,24 @@ cursor_channel_finalize(GObject *object)
> G_OBJECT_CLASS(cursor_channel_parent_class)->finalize(object);
> }
>
> +static void
> +cursor_channel_constructed(GObject *object)
> +{
> + RedChannel *red_channel = RED_CHANNEL(object);
> + RedsState *reds = red_channel_get_server(red_channel);
> +
> + G_OBJECT_CLASS(cursor_channel_parent_class)->constructed(object);
> +
> + reds_register_channel(reds, red_channel);
> +}
> +
> static void
> cursor_channel_class_init(CursorChannelClass *klass)
> {
> GObjectClass *object_class = G_OBJECT_CLASS(klass);
> RedChannelClass *channel_class = RED_CHANNEL_CLASS(klass);
>
> + object_class->constructed = cursor_channel_constructed;
> object_class->finalize = cursor_channel_finalize;
>
> channel_class->parser =
> spice_get_client_channel_parser(SPICE_CHANNEL_CURSOR, NULL);
> diff --git a/server/display-channel.c b/server/display-channel.c
> index e68ed10f8..6684135eb 100644
> --- a/server/display-channel.c
> +++ b/server/display-channel.c
> @@ -2304,6 +2304,8 @@ display_channel_constructed(GObject *object)
> red_channel_set_cap(channel, SPICE_DISPLAY_CAP_PREF_COMPRESSION);
> red_channel_set_cap(channel, SPICE_DISPLAY_CAP_PREF_VIDEO_CODEC_TYPE);
> red_channel_set_cap(channel, SPICE_DISPLAY_CAP_STREAM_REPORT);
> +
> + reds_register_channel(reds, channel);
> }
>
> void display_channel_process_surface_cmd(DisplayChannel *display,
> diff --git a/server/red-stream-device.c b/server/red-stream-device.c
> index b9e0827af..78a8c9083 100644
> --- a/server/red-stream-device.c
> +++ b/server/red-stream-device.c
> @@ -701,7 +701,6 @@ stream_device_create_channel(StreamDevice *dev)
> client_cbs.connect = (channel_client_connect_proc)
> cursor_channel_connect;
> client_cbs.migrate = cursor_channel_client_migrate;
> red_channel_register_client_cbs(RED_CHANNEL(cursor_channel),
> &client_cbs);
> - reds_register_channel(reds, RED_CHANNEL(cursor_channel));
>
> dev->stream_channel = stream_channel;
> dev->cursor_channel = cursor_channel;
> diff --git a/server/red-worker.c b/server/red-worker.c
> index c74ae8886..3cb12b9c2 100644
> --- a/server/red-worker.c
> +++ b/server/red-worker.c
> @@ -1322,7 +1322,6 @@ RedWorker* red_worker_new(QXLInstance *qxl,
> red_channel_init_stat_node(channel, &worker->stat, "cursor_channel");
> red_channel_register_client_cbs(channel, client_cursor_cbs);
> g_object_set_data(G_OBJECT(channel), "dispatcher", dispatcher);
> - reds_register_channel(reds, channel);
>
> // TODO: handle seamless migration. Temp, setting migrate to FALSE
> worker->display_channel = display_channel_new(reds, qxl, &worker->core,
> FALSE,
> @@ -1333,7 +1332,6 @@ RedWorker* red_worker_new(QXLInstance *qxl,
> red_channel_init_stat_node(channel, &worker->stat, "display_channel");
> red_channel_register_client_cbs(channel, client_display_cbs);
> g_object_set_data(G_OBJECT(channel), "dispatcher", dispatcher);
> - reds_register_channel(reds, channel);
>
> return worker;
> }
More information about the Spice-devel
mailing list