[Spice-devel] [PATCH 09/11] cc: change reference from RedWorker to QXLInstance

Jonathon Jongsma jjongsma at redhat.com
Thu Feb 11 20:37:25 UTC 2016


I agree with this change, although it will probably make rebasing future patches
more difficult. I'd prefer to change the description a little though. Something
like:

CommonChannel: hold a reference to QXLInstance instead of RedWorker


Acked-by: Jonathon Jongsma <jjongsma at redhat.com>


On Tue, 2016-02-09 at 10:27 +0000, Frediano Ziglio wrote:
> CommonChannel does not need to know about RedWorker.
> This reduce a bit dependencies between objects.
> 
> Signed-off-by: Frediano Ziglio <fziglio at redhat.com>
> ---
>  server/cursor-channel.c  |  2 +-
>  server/dcc-encoders.c    |  3 +--
>  server/display-channel.c |  5 ++---
>  server/red-worker.c      | 12 ++++++------
>  server/red-worker.h      |  5 +++--
>  5 files changed, 13 insertions(+), 14 deletions(-)
> 
> diff --git a/server/cursor-channel.c b/server/cursor-channel.c
> index bbaac34..197376a 100644
> --- a/server/cursor-channel.c
> +++ b/server/cursor-channel.c
> @@ -489,7 +489,7 @@ void cursor_channel_process_cmd(CursorChannel *cursor,
> RedCursorCmd *cursor_cmd,
>      spice_return_if_fail(cursor);
>      spice_return_if_fail(cursor_cmd);
>  
> -    cursor_item = cursor_item_new(red_worker_get_qxl(cursor->common.worker),
> +    cursor_item = cursor_item_new(cursor->common.qxl,
>                                    cursor_cmd, group_id);
>  
>      switch (cursor_cmd->type) {
> diff --git a/server/dcc-encoders.c b/server/dcc-encoders.c
> index 0923c9c..c810b8e 100644
> --- a/server/dcc-encoders.c
> +++ b/server/dcc-encoders.c
> @@ -456,7 +456,6 @@ void dcc_free_glz_drawable_instance(DisplayChannelClient
> *dcc,
>                                      GlzDrawableInstanceItem *instance)
>  {
>      DisplayChannel *display_channel = DCC_TO_DC(dcc);
> -    RedWorker *worker = display_channel->common.worker;
>      RedGlzDrawable *glz_drawable;
>  
>      spice_assert(instance);
> @@ -484,7 +483,7 @@ void dcc_free_glz_drawable_instance(DisplayChannelClient
> *dcc,
>          if (drawable) {
>              ring_remove(&glz_drawable->drawable_link);
>          }
> -        red_drawable_unref(worker, glz_drawable->red_drawable,
> +        red_drawable_unref(display_channel, glz_drawable->red_drawable,
>                             glz_drawable->group_id);
>          display_channel->glz_drawable_count--;
>          if (ring_item_is_linked(&glz_drawable->link)) {
> diff --git a/server/display-channel.c b/server/display-channel.c
> index f0d133a..d505d3a 100644
> --- a/server/display-channel.c
> +++ b/server/display-channel.c
> @@ -241,8 +241,7 @@ static void stop_streams(DisplayChannel *display)
>  void display_channel_surface_unref(DisplayChannel *display, uint32_t
> surface_id)
>  {
>      RedSurface *surface = &display->surfaces[surface_id];
> -    RedWorker *worker = COMMON_CHANNEL(display)->worker;
> -    QXLInstance *qxl = red_worker_get_qxl(worker);
> +    QXLInstance *qxl = display->common.qxl;
>      DisplayChannelClient *dcc;
>      RingItem *link, *next;
>  
> @@ -1445,7 +1444,7 @@ void display_channel_drawable_unref(DisplayChannel
> *display, Drawable *drawable)
>          ring_remove(item);
>      }
>      if (drawable->red_drawable) {
> -        red_drawable_unref(COMMON_CHANNEL(display)->worker, drawable
> ->red_drawable, drawable->group_id);
> +        red_drawable_unref(display, drawable->red_drawable, drawable
> ->group_id);
>      }
>      drawable_free(display, drawable);
>      display->drawable_count--;
> diff --git a/server/red-worker.c b/server/red-worker.c
> index 3bb8227..1757b8e 100644
> --- a/server/red-worker.c
> +++ b/server/red-worker.c
> @@ -129,7 +129,7 @@ static void common_release_recv_buf(RedChannelClient *rcc,
> uint16_t type, uint32
>      }
>  }
>  
> -void red_drawable_unref(RedWorker *worker, RedDrawable *red_drawable,
> +void red_drawable_unref(DisplayChannel *display, RedDrawable *red_drawable,
>                          uint32_t group_id)
>  {
>      QXLReleaseInfoExt release_info_ext;
> @@ -137,10 +137,10 @@ void red_drawable_unref(RedWorker *worker, RedDrawable
> *red_drawable,
>      if (--red_drawable->refs) {
>          return;
>      }
> -    worker->display_channel->red_drawable_count--;
> +    display->red_drawable_count--;
>      release_info_ext.group_id = group_id;
>      release_info_ext.info = red_drawable->release_info;
> -    worker->qxl->st->qif->release_resource(worker->qxl, release_info_ext);
> +    display->common.qxl->st->qif->release_resource(display->common.qxl,
> release_info_ext);
>      red_put_drawable(red_drawable);
>      free(red_drawable);
>  }
> @@ -243,7 +243,7 @@ static int red_process_display(RedWorker *worker, int
> *ring_is_empty)
>                                               worker
> ->process_display_generation);
>              }
>              // release the red_drawable
> -            red_drawable_unref(worker, red_drawable, ext_cmd.group_id);
> +            red_drawable_unref(worker->display_channel, red_drawable,
> ext_cmd.group_id);
>              break;
>          }
>          case QXL_CMD_UPDATE: {
> @@ -469,7 +469,7 @@ CommonChannelClient
> *common_channel_new_client(CommonChannel *common,
>          return NULL;
>      }
>      CommonChannelClient *common_cc = (CommonChannelClient*)rcc;
> -    common_cc->id = common->worker->qxl->id;
> +    common_cc->id = common->qxl->id;
>      common->during_target_migrate = mig_target;
>  
>      // TODO: move wide/narrow ack setting to red_channel.
> @@ -510,7 +510,7 @@ CommonChannel *red_worker_new_channel(RedWorker *worker,
> int size,
>      red_channel_set_stat_node(channel, stat_add_node(worker->stat, name,
> TRUE));
>  
>      common = (CommonChannel *)channel;
> -    common->worker = worker;
> +    common->qxl = worker->qxl;
>      return common;
>  }
>  
> diff --git a/server/red-worker.h b/server/red-worker.h
> index 005c15f..1285942 100644
> --- a/server/red-worker.h
> +++ b/server/red-worker.h
> @@ -38,7 +38,7 @@ typedef struct CommonChannelClient {
>  typedef struct CommonChannel {
>      RedChannel base; // Must be the first thing
>  
> -    struct RedWorker *worker;
> +    QXLInstance *qxl;
>      uint8_t recv_buf[CHANNEL_RECEIVE_BUF_SIZE];
>      uint32_t id_alloc; // bitfield. TODO - use this instead of shift scheme.
>      int during_target_migrate; /* TRUE when the client that is associated
> with the channel
> @@ -97,7 +97,8 @@ QXLInstance* red_worker_get_qxl(RedWorker *worker);
>  RedChannel* red_worker_get_cursor_channel(RedWorker *worker);
>  RedChannel* red_worker_get_display_channel(RedWorker *worker);
>  
> -void red_drawable_unref(RedWorker *worker, RedDrawable *red_drawable,
> +struct DisplayChannel;
> +void red_drawable_unref(struct DisplayChannel *display, RedDrawable
> *red_drawable,
>                          uint32_t group_id);
>  
>  CommonChannel *red_worker_new_channel(RedWorker *worker, int size,


More information about the Spice-devel mailing list