[Spice-devel] [PATCH 05/18] use list in RedsState for ic_change and sv_change

Fabiano Fidêncio ffidenci at redhat.com
Mon Feb 15 22:50:35 UTC 2016


On Mon, 2016-02-15 at 16:01 +0000, Frediano Ziglio wrote:
> Instead of using list in RedDispatcher (which is going to be removed)
> use the one in RedsState.
> 
> Signed-off-by: Jonathon Jongsma <jjongsma at redhat.com>
> Signed-off-by: Frediano Ziglio <fziglio at redhat.com>
> ---
>  server/red-dispatcher.c | 48 ++++++++++++++++++++-------------------
> ---------
>  server/red-dispatcher.h |  5 +++--
>  server/reds.c           | 30 ++++++++++++++++++++++++++++--
>  3 files changed, 51 insertions(+), 32 deletions(-)
> 
> diff --git a/server/red-dispatcher.c b/server/red-dispatcher.c
> index 68423a1..7d755c1 100644
> --- a/server/red-dispatcher.c
> +++ b/server/red-dispatcher.c
> @@ -682,35 +682,9 @@ static void qxl_worker_loadvm_commands(QXLWorker
> *qxl_worker,
>      red_dispatcher_loadvm_commands((RedDispatcher*)qxl_worker, ext,
> count);
>  }
>  
> -void red_dispatcher_on_ic_change(void)
> +void red_dispatcher_set_compression_level(RedDispatcher *dispatcher,
> int level)
>  {
> -    RedWorkerMessageSetCompression payload;
> -    int compression_level = calc_compression_level(reds);
> -    RedDispatcher *now = dispatchers;
> -
> -    while (now) {
> -        now->qxl->st->qif->set_compression_level(now->qxl,
> compression_level);
> -        payload.image_compression =
> spice_server_get_image_compression(reds);
> -        dispatcher_send_message(&now->dispatcher,
> -                                RED_WORKER_MESSAGE_SET_COMPRESSION,
> -                                &payload);
> -        now = now->next;
> -    }
> -}
> -
> -void red_dispatcher_on_sv_change(void)
> -{
> -    RedWorkerMessageSetStreamingVideo payload;
> -    int compression_level = calc_compression_level(reds);
> -    RedDispatcher *now = dispatchers;
> -    while (now) {
> -        now->qxl->st->qif->set_compression_level(now->qxl,
> compression_level);
> -        payload.streaming_video = reds_get_streaming_video(reds);
> -        dispatcher_send_message(&now->dispatcher,
> -                                RED_WORKER_MESSAGE_SET_STREAMING_VID
> EO,
> -                                &payload);
> -        now = now->next;
> -    }
> +    dispatcher->qxl->st->qif->set_compression_level(dispatcher->qxl, 
> level);
>  }
>  
>  void red_dispatcher_on_vm_stop(void)
> @@ -1089,6 +1063,24 @@ void
> red_dispatcher_clear_pending(RedDispatcher *red_dispatcher, int
> pending)
>      clear_bit(pending, &red_dispatcher->pending);
>  }
>  
> +void red_dispatcher_on_ic_change(RedDispatcher *dispatcher,
> SpiceImageCompression ic)
> +{
> +    RedWorkerMessageSetCompression payload;
> +    payload.image_compression = ic;
> +    dispatcher_send_message(&dispatcher->dispatcher,
> +                            RED_WORKER_MESSAGE_SET_COMPRESSION,
> +                            &payload);
> +}
> +
> +void red_dispatcher_on_sv_change(RedDispatcher *dispatcher, int sv)
> +{
> +    RedWorkerMessageSetStreamingVideo payload;
> +    payload.streaming_video = sv;
> +    dispatcher_send_message(&dispatcher->dispatcher,
> +                            RED_WORKER_MESSAGE_SET_STREAMING_VIDEO,
> +                            &payload);
> +}
> +
>  void red_dispatcher_set_mouse_mode(RedDispatcher *dispatcher,
> uint32_t mode)
>  {
>      RedWorkerMessageSetMouseMode payload;
> diff --git a/server/red-dispatcher.h b/server/red-dispatcher.h
> index 1c0c218..bfb74fe 100644
> --- a/server/red-dispatcher.h
> +++ b/server/red-dispatcher.h
> @@ -26,9 +26,10 @@ typedef struct AsyncCommand AsyncCommand;
>  
>  void red_dispatcher_init(QXLInstance *qxl);
>  
> -void red_dispatcher_on_ic_change(void);
> -void red_dispatcher_on_sv_change(void);
> +void red_dispatcher_on_ic_change(RedDispatcher *dispatcher,
> SpiceImageCompression ic);
> +void red_dispatcher_on_sv_change(RedDispatcher *dispatcher, int sv);
>  void red_dispatcher_set_mouse_mode(RedDispatcher *dispatcher,
> uint32_t mode);
> +void red_dispatcher_set_compression_level(RedDispatcher *dispatcher,
> int level);
>  void red_dispatcher_on_vm_stop(void);
>  void red_dispatcher_on_vm_start(void);
>  int red_dispatcher_count(void);
> diff --git a/server/reds.c b/server/reds.c
> index 3882477..0f8f69a 100644
> --- a/server/reds.c
> +++ b/server/reds.c
> @@ -172,6 +172,8 @@ static void
> reds_mig_remove_wait_disconnect_client(RedsState *reds, RedClient *c
>  static void reds_char_device_add_state(RedsState *reds,
> SpiceCharDeviceState *st);
>  static void reds_char_device_remove_state(RedsState *reds,
> SpiceCharDeviceState *st);
>  static void reds_send_mm_time(RedsState *reds);
> +static void reds_on_ic_change(RedsState *reds);
> +static void reds_on_sv_change(RedsState *reds);
>  
>  static VDIReadBuf *vdi_port_state_get_read_buf(VDIPortState *state);
>  static VDIReadBuf *vdi_port_read_buf_ref(VDIReadBuf *buf);
> @@ -2774,7 +2776,7 @@ static void
> reds_set_image_compression(RedsState *reds, SpiceImageCompression va
>          return;
>      }
>      reds->image_compression = val;
> -    red_dispatcher_on_ic_change();
> +    reds_on_ic_change(reds);
>  }
>  
>  static void reds_set_one_channel_security(RedsState *reds, int id,
> uint32_t security)
> @@ -3797,7 +3799,7 @@ SPICE_GNUC_VISIBLE int
> spice_server_set_streaming_video(SpiceServer *s, int valu
>          value != SPICE_STREAM_VIDEO_FILTER)
>          return -1;
>      s->streaming_video = value;
> -    red_dispatcher_on_sv_change();
> +    reds_on_sv_change(reds);
>      return 0;
>  }
>  
> @@ -4061,3 +4063,27 @@ int calc_compression_level(RedsState *reds)
>          return 1;
>      }
>  }
> +
> +void reds_on_ic_change(RedsState *reds)
> +{
> +    int compression_level = calc_compression_level(reds);
> +    GList *l;
> +
> +    for (l = reds->dispatchers; l != NULL; l = l->next) {
> +        RedDispatcher *d = l->data;
> +        red_dispatcher_set_compression_level(d, compression_level);
> +        red_dispatcher_on_ic_change(d,
> spice_server_get_image_compression(reds));
> +    }
> +}
> +
> +void reds_on_sv_change(RedsState *reds)
> +{
> +    int compression_level = calc_compression_level(reds);
> +    GList *l;
> +
> +    for (l = reds->dispatchers; l != NULL; l = l->next) {
> +        RedDispatcher *d = l->data;
> +        red_dispatcher_set_compression_level(d, compression_level);
> +        red_dispatcher_on_sv_change(d,
> reds_get_streaming_video(reds));
> +    }
> +}

Acked-by: Fabiano Fidêncio <fidencio at redhat.com>


More information about the Spice-devel mailing list