[Spice-devel] [PATCH 09/18] CommonChannel -> CommonWorkerChannel

Fabiano Fidêncio ffidenci at redhat.com
Mon Feb 15 23:04:55 UTC 2016


On Mon, 2016-02-15 at 16:01 +0000, Frediano Ziglio wrote:
> From: Jonathon Jongsma <jjongsma at redhat.com>
> 
> Rename this struct to make it clear that it's only the base class for
> worker channels (e.g. display and cursor), not all channels.
> 
> Also renamed CommonChannelClient to CommonWorkerChannelClient.
> ---
>  server/cursor-channel.c  | 26 +++++++++++++-------------
>  server/dcc.c             |  6 +++---
>  server/dcc.h             |  4 ++--
>  server/display-channel.h |  2 +-
>  server/red-worker.c      | 42 +++++++++++++++++++++-----------------
> ----
>  server/red-worker.h      | 44 ++++++++++++++++++++++--------------
> --------
>  6 files changed, 62 insertions(+), 62 deletions(-)
> 
> diff --git a/server/cursor-channel.c b/server/cursor-channel.c
> index 0ab0d80..59f2991 100644
> --- a/server/cursor-channel.c
> +++ b/server/cursor-channel.c
> @@ -51,7 +51,7 @@ typedef struct CursorPipeItem {
>  } CursorPipeItem;
>  
>  struct CursorChannel {
> -    CommonChannel common; // Must be the first thing
> +    CommonWorkerChannel common; // Must be the first thing
>  
>      CursorItem *item;
>      int cursor_visible;
> @@ -66,7 +66,7 @@ struct CursorChannel {
>  };
>  
>  struct CursorChannelClient {
> -    CommonChannelClient common;
> +    CommonWorkerChannelClient common;
>  
>      CacheItem *cursor_cache[CURSOR_CACHE_HASH_SIZE];
>      Ring cursor_cache_lru;
> @@ -415,7 +415,7 @@ static void
> cursor_channel_release_item(RedChannelClient *rcc, PipeItem *item, i
>  CursorChannel* cursor_channel_new(RedWorker *worker)
>  {
>      CursorChannel *cursor_channel;
> -    CommonChannel *channel = NULL;
> +    CommonWorkerChannel *channel = NULL;
>      ChannelCbs cbs = {
>          .on_disconnect =  cursor_channel_client_on_disconnect,
>          .send_item = cursor_channel_send_item,
> @@ -458,15 +458,15 @@ CursorChannelClient*
> cursor_channel_client_new(CursorChannel *cursor, RedClient
>      spice_return_val_if_fail(!num_caps || caps, NULL);
>  
>      CursorChannelClient *ccc =
> -        (CursorChannelClient*)common_channel_new_client(&cursor-
> >common,
> -                                                        sizeof(Curso
> rChannelClient),
> -                                                        client,
> stream,
> -                                                        mig_target,
> -                                                        FALSE,
> -                                                        common_caps,
> -                                                        num_common_c
> aps,
> -                                                        caps,
> -                                                        num_caps);
> +        (CursorChannelClient*)common_worker_channel_new_client(&curs
> or->common,
> +                                                               sizeo
> f(CursorChannelClient),
> +                                                               clien
> t, stream,
> +                                                               mig_t
> arget,
> +                                                               FALSE
> ,
> +                                                               commo
> n_caps,
> +                                                               num_c
> ommon_caps,
> +                                                               caps,
> +                                                               num_c
> aps);
>      spice_return_val_if_fail(ccc != NULL, NULL);
>  
>      ring_init(&ccc->cursor_cache_lru);
> @@ -547,7 +547,7 @@ void cursor_channel_init(CursorChannel *cursor,
> CursorChannelClient *client)
>      spice_return_if_fail(cursor);
>  
>      if (!red_channel_is_connected(&cursor->common.base)
> -        || COMMON_CHANNEL(cursor)->during_target_migrate) {
> +        || COMMON_WORKER_CHANNEL(cursor)->during_target_migrate) {
>          spice_debug("during_target_migrate: skip init");
>          return;
>      }
> diff --git a/server/dcc.c b/server/dcc.c
> index 9a4e90c..66de2bb 100644
> --- a/server/dcc.c
> +++ b/server/dcc.c
> @@ -368,8 +368,8 @@ DisplayChannelClient *dcc_new(DisplayChannel
> *display,
>  {
>      DisplayChannelClient *dcc;
>  
> -    dcc = (DisplayChannelClient*)common_channel_new_client(
> -        COMMON_CHANNEL(display), sizeof(DisplayChannelClient),
> +    dcc = (DisplayChannelClient*)common_worker_channel_new_client(
> +        COMMON_WORKER_CHANNEL(display),
> sizeof(DisplayChannelClient),
>          client, stream, mig_target, TRUE,
>          common_caps, num_common_caps,
>          caps, num_caps);
> @@ -626,7 +626,7 @@ void dcc_destroy_surface(DisplayChannelClient
> *dcc, uint32_t surface_id)
>      display = DCC_TO_DC(dcc);
>      channel = RED_CHANNEL(display);
>  
> -    if (COMMON_CHANNEL(display)->during_target_migrate ||
> +    if (COMMON_WORKER_CHANNEL(display)->during_target_migrate ||
>          !dcc->surface_client_created[surface_id]) {
>          return;
>      }
> diff --git a/server/dcc.h b/server/dcc.h
> index a482938..c78f3b8 100644
> --- a/server/dcc.h
> +++ b/server/dcc.h
> @@ -55,7 +55,7 @@ typedef struct FreeList {
>  } FreeList;
>  
>  struct DisplayChannelClient {
> -    CommonChannelClient common;
> +    CommonWorkerChannelClient common;
>      SpiceImageCompression image_compression;
>      spice_wan_compression_t jpeg_state;
>      spice_wan_compression_t zlib_glz_state;
> @@ -115,7 +115,7 @@ struct DisplayChannelClient {
>  };
>  
>  #define
> DCC_TO_WORKER(dcc)                                              \
> -    (SPICE_CONTAINEROF((dcc)->common.base.channel, CommonChannel,
> base)->worker)
> +    (SPICE_CONTAINEROF((dcc)->common.base.channel,
> CommonWorkerChannel, base)->worker)
>  #define
> DCC_TO_DC(dcc)                                                  \
>       SPICE_CONTAINEROF((dcc)->common.base.channel, DisplayChannel,
> common.base)
>  #define RCC_TO_DCC(rcc) SPICE_CONTAINEROF((rcc),
> DisplayChannelClient, common.base)
> diff --git a/server/display-channel.h b/server/display-channel.h
> index 13b13b1..f2e9f51 100644
> --- a/server/display-channel.h
> +++ b/server/display-channel.h
> @@ -164,7 +164,7 @@ struct _Drawable {
>  };
>  
>  struct DisplayChannel {
> -    CommonChannel common; // Must be the first thing
> +    CommonWorkerChannel common; // Must be the first thing
>      uint32_t bits_unique;
>  
>      MonitorsConfig *monitors_config;
> diff --git a/server/red-worker.c b/server/red-worker.c
> index 6780d2b..76e8625 100644
> --- a/server/red-worker.c
> +++ b/server/red-worker.c
> @@ -107,7 +107,7 @@ static int display_is_connected(RedWorker
> *worker)
>  
>  static uint8_t *common_alloc_recv_buf(RedChannelClient *rcc,
> uint16_t type, uint32_t size)
>  {
> -    CommonChannel *common = SPICE_CONTAINEROF(rcc->channel,
> CommonChannel, base);
> +    CommonWorkerChannel *common = SPICE_CONTAINEROF(rcc->channel,
> CommonWorkerChannel, base);
>  
>      /* SPICE_MSGC_MIGRATE_DATA is the only client message whose size
> is dynamic */
>      if (type == SPICE_MSGC_MIGRATE_DATA) {
> @@ -407,7 +407,7 @@ static int
> common_channel_config_socket(RedChannelClient *rcc)
>      RedClient *client = red_channel_client_get_client(rcc);
>      MainChannelClient *mcc = red_client_get_main(client);
>      RedsStream *stream = red_channel_client_get_stream(rcc);
> -    CommonChannelClient *ccc = COMMON_CHANNEL_CLIENT(rcc);
> +    CommonWorkerChannelClient *ccc =
> COMMON_WORKER_CHANNEL_CLIENT(rcc);
>      int flags;
>      int delay_val;
>  
> @@ -439,16 +439,16 @@ static int
> common_channel_config_socket(RedChannelClient *rcc)
>      return TRUE;
>  }
>  
> -CommonChannelClient *common_channel_new_client(CommonChannel
> *common,
> -                                               int size,
> -                                               RedClient *client,
> -                                               RedsStream *stream,
> -                                               int mig_target,
> -                                               int monitor_latency,
> -                                               uint32_t
> *common_caps,
> -                                               int num_common_caps,
> -                                               uint32_t *caps,
> -                                               int num_caps)
> +CommonWorkerChannelClient
> *common_worker_channel_new_client(CommonWorkerChannel *common,
> +                                                            int
> size,
> +                                                            RedClien
> t *client,
> +                                                            RedsStre
> am *stream,
> +                                                            int
> mig_target,
> +                                                            int
> monitor_latency,
> +                                                            uint32_t
> *common_caps,
> +                                                            int
> num_common_caps,
> +                                                            uint32_t
> *caps,
> +                                                            int
> num_caps)
>  {
>      RedChannelClient *rcc =
>          red_channel_client_create(size, &common->base, client,
> stream, monitor_latency,
> @@ -456,7 +456,7 @@ CommonChannelClient
> *common_channel_new_client(CommonChannel *common,
>      if (!rcc) {
>          return NULL;
>      }
> -    CommonChannelClient *common_cc = (CommonChannelClient*)rcc;
> +    CommonWorkerChannelClient *common_cc =
> (CommonWorkerChannelClient*)rcc;
>      common_cc->id = common->qxl->id;
>      common->during_target_migrate = mig_target;
>  
> @@ -468,14 +468,14 @@ CommonChannelClient
> *common_channel_new_client(CommonChannel *common,
>  }
>  
>  
> -CommonChannel *red_worker_new_channel(RedWorker *worker, int size,
> -                                   const char *name,
> -                                   uint32_t channel_type, int
> migration_flags,
> -                                   ChannelCbs *channel_cbs,
> -                                   channel_handle_parsed_proc
> handle_parsed)
> +CommonWorkerChannel *red_worker_new_channel(RedWorker *worker, int
> size,
> +                                            const char *name,
> +                                            uint32_t channel_type,
> int migration_flags,
> +                                            ChannelCbs *channel_cbs,
> +                                            channel_handle_parsed_pr
> oc handle_parsed)
>  {
>      RedChannel *channel = NULL;
> -    CommonChannel *common;
> +    CommonWorkerChannel *common;
>  
>      spice_return_val_if_fail(worker, NULL);
>      spice_return_val_if_fail(channel_cbs, NULL);
> @@ -497,7 +497,7 @@ CommonChannel *red_worker_new_channel(RedWorker
> *worker, int size,
>      spice_return_val_if_fail(channel, NULL);
>      red_channel_set_stat_node(channel, stat_add_node(reds, worker-
> >stat, name, TRUE));
>  
> -    common = (CommonChannel *)channel;
> +    common = (CommonWorkerChannel *)channel;
>      common->qxl = worker->qxl;
>      return common;
>  }
> @@ -816,7 +816,7 @@ static void handle_dev_start(void *opaque, void
> *payload)
>  
>      spice_assert(!worker->running);
>      if (worker->cursor_channel) {
> -        COMMON_CHANNEL(worker->cursor_channel)-
> >during_target_migrate = FALSE;
> +        COMMON_WORKER_CHANNEL(worker->cursor_channel)-
> >during_target_migrate = FALSE;
>      }
>      if (worker->display_channel) {
>          worker->display_channel->common.during_target_migrate =
> FALSE;
> diff --git a/server/red-worker.h b/server/red-worker.h
> index 94974b7..8ef8287 100644
> --- a/server/red-worker.h
> +++ b/server/red-worker.h
> @@ -24,18 +24,18 @@
>  
>  typedef struct RedWorker RedWorker;
>  
> -typedef struct CommonChannelClient {
> +typedef struct CommonWorkerChannelClient {
>      RedChannelClient base;
>  
>      uint32_t id;
>      int is_low_bandwidth;
> -} CommonChannelClient;
> +} CommonWorkerChannelClient;
>  
> -#define COMMON_CHANNEL_CLIENT(Client)
> ((CommonChannelClient*)(Client))
> +#define COMMON_WORKER_CHANNEL_CLIENT(Client)
> ((CommonWorkerChannelClient*)(Client))
>  #define COMMON_CLIENT_TIMEOUT (NSEC_PER_SEC * 30)
>  
>  #define CHANNEL_RECEIVE_BUF_SIZE 1024
> -typedef struct CommonChannel {
> +typedef struct CommonWorkerChannel {
>      RedChannel base; // Must be the first thing
>  
>      QXLInstance *qxl;
> @@ -46,9 +46,9 @@ typedef struct CommonChannel {
>                                    The flag is used to avoid sending
> messages that are artifacts
>                                    of the transition from stopped vm
> to loaded vm (e.g., recreation
>                                    of the primary surface) */
> -} CommonChannel;
> +} CommonWorkerChannel;
>  
> -#define COMMON_CHANNEL(Channel) ((CommonChannel*)(Channel))
> +#define COMMON_WORKER_CHANNEL(Channel)
> ((CommonWorkerChannel*)(Channel))
>  
>  enum {
>      PIPE_ITEM_TYPE_VERB = PIPE_ITEM_TYPE_CHANNEL_BASE,
> @@ -99,21 +99,21 @@ RedChannel*
> red_worker_get_display_channel(RedWorker *worker);
>  
>  void red_drawable_unref(RedDrawable *red_drawable);
>  
> -CommonChannel *red_worker_new_channel(RedWorker *worker, int size,
> -                                   const char *name,
> -                                   uint32_t channel_type, int
> migration_flags,
> -                                   ChannelCbs *channel_cbs,
> -                                   channel_handle_parsed_proc
> handle_parsed);
> -
> -CommonChannelClient *common_channel_new_client(CommonChannel
> *common,
> -                                               int size,
> -                                               RedClient *client,
> -                                               RedsStream *stream,
> -                                               int mig_target,
> -                                               int monitor_latency,
> -                                               uint32_t
> *common_caps,
> -                                               int num_common_caps,
> -                                               uint32_t *caps,
> -                                               int num_caps);
> +CommonWorkerChannel *red_worker_new_channel(RedWorker *worker, int
> size,
> +                                            const char *name,
> +                                            uint32_t channel_type,
> int migration_flags,
> +                                            ChannelCbs *channel_cbs,
> +                                            channel_handle_parsed_pr
> oc handle_parsed);
> +
> +CommonWorkerChannelClient
> *common_worker_channel_new_client(CommonWorkerChannel *common,
> +                                                            int
> size,
> +                                                            RedClien
> t *client,
> +                                                            RedsStre
> am *stream,
> +                                                            int
> mig_target,
> +                                                            int
> monitor_latency,
> +                                                            uint32_t
> *common_caps,
> +                                                            int
> num_common_caps,
> +                                                            uint32_t
> *caps,
> +                                                            int
> num_caps);
>  
>  #endif

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


More information about the Spice-devel mailing list