[Spice-devel] [PATCH spice-gtk 03/14] channel: add SPICE_DISABLE_CHANNELS

Yonit Halperin yhalperi at redhat.com
Tue Sep 10 12:14:59 PDT 2013


On 09/10/2013 10:44 AM, Marc-André Lureau wrote:
> Allow to disable selectively channels, mainly used for testing,
> ex: SPICE_DISABLE_CHANNELS=display spicy-stats -p 12345
> ---
>   gtk/spice-channel-priv.h | 2 ++
>   gtk/spice-channel.c      | 7 +++++++
>   2 files changed, 9 insertions(+)
>
> diff --git a/gtk/spice-channel-priv.h b/gtk/spice-channel-priv.h
> index 92c9315..1f29c23 100644
> --- a/gtk/spice-channel-priv.h
> +++ b/gtk/spice-channel-priv.h
> @@ -134,6 +134,8 @@ struct _SpiceChannelPrivate {
>       gsize                       total_read_bytes;
>       uint64_t                    last_message_serial;
>       GSList                      *flushing;
> +
> +    gboolean                    disable_channel_msg;
>   };
>
>   SpiceMsgIn *spice_msg_in_new(SpiceChannel *channel);
> diff --git a/gtk/spice-channel.c b/gtk/spice-channel.c
> index a0d9c15..46caeef 100644
> --- a/gtk/spice-channel.c
> +++ b/gtk/spice-channel.c
> @@ -126,6 +126,10 @@ static void spice_channel_constructed(GObject *gobject)
>                desc ? desc : "unknown", c->channel_type, c->channel_id);
>       CHANNEL_DEBUG(channel, "%s", __FUNCTION__);
>
> +    const char *disabled  = g_getenv("SPICE_DISABLE_CHANNELS");
> +    if (disabled && strstr(disabled, desc))
> +        c->disable_channel_msg = TRUE;
> +
>       c->connection_id = spice_session_get_connection_id(c->session);
>       spice_session_channel_new(c->session, channel);
>
> @@ -2075,6 +2079,7 @@ static void spice_channel_iterate_write(SpiceChannel *channel)
>   static void spice_channel_iterate_read(SpiceChannel *channel)
>   {
>       SpiceChannelPrivate *c = channel->priv;
> +
>       g_return_if_fail(c->state != SPICE_CHANNEL_STATE_MIGRATING);
>
>       spice_channel_recv_msg(channel,
> @@ -2771,6 +2776,8 @@ static void spice_channel_handle_msg(SpiceChannel *channel, SpiceMsgIn *msg)
>       spice_msg_handler handler;
>
>       g_return_if_fail(type < klass->handlers->len);
> +    if (type > 100 && channel->priv->disable_channel_msg)
please replace 100 with a define. (Yes, we should have 100 as the enum 
ending the basic messages in the protocol. But shame on us we don't...)
> +        return;
>
>       handler = g_array_index(klass->handlers, spice_msg_handler, type);
>       g_return_if_fail(handler != NULL);
>



More information about the Spice-devel mailing list