[Spice-devel] [PATCH 01/19] CommonChannel -> CommonWorkerChannel

Frediano Ziglio fziglio at redhat.com
Tue Feb 16 14:32:44 UTC 2016


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.

Acked-by: Fabiano FidĂȘncio <fidencio at redhat.com>
---
 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(CursorChannelClient),
-                                                        client, stream,
-                                                        mig_target,
-                                                        FALSE,
-                                                        common_caps,
-                                                        num_common_caps,
-                                                        caps,
-                                                        num_caps);
+        (CursorChannelClient*)common_worker_channel_new_client(&cursor->common,
+                                                               sizeof(CursorChannelClient),
+                                                               client, stream,
+                                                               mig_target,
+                                                               FALSE,
+                                                               common_caps,
+                                                               num_common_caps,
+                                                               caps,
+                                                               num_caps);
     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 dca9a64..5ed46a3 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);
@@ -627,7 +627,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 cbeea75..bfefe99 100644
--- a/server/dcc.h
+++ b/server/dcc.h
@@ -55,7 +55,7 @@ typedef struct FreeList {
 } FreeList;
 
 struct DisplayChannelClient {
-    CommonChannelClient common;
+    CommonWorkerChannelClient common;
     uint32_t id;
     SpiceImageCompression image_compression;
     spice_wan_compression_t jpeg_state;
@@ -116,7 +116,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 bf12a22..fe0c05e 100644
--- a/server/red-worker.c
+++ b/server/red-worker.c
@@ -100,7 +100,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) {
@@ -400,7 +400,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;
 
@@ -432,16 +432,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,
+                                                            RedClient *client,
+                                                            RedsStream *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,
@@ -449,7 +449,7 @@ CommonChannelClient *common_channel_new_client(CommonChannel *common,
     if (!rcc) {
         return NULL;
     }
-    CommonChannelClient *common_cc = (CommonChannelClient*)rcc;
+    CommonWorkerChannelClient *common_cc = (CommonWorkerChannelClient*)rcc;
     common->during_target_migrate = mig_target;
 
     // TODO: move wide/narrow ack setting to red_channel.
@@ -460,14 +460,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_proc handle_parsed)
 {
     RedChannel *channel = NULL;
-    CommonChannel *common;
+    CommonWorkerChannel *common;
 
     spice_return_val_if_fail(worker, NULL);
     spice_return_val_if_fail(channel_cbs, NULL);
@@ -489,7 +489,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;
 }
@@ -808,7 +808,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 d366955..aa5d9ee 100644
--- a/server/red-worker.h
+++ b/server/red-worker.h
@@ -24,17 +24,17 @@
 
 typedef struct RedWorker RedWorker;
 
-typedef struct CommonChannelClient {
+typedef struct CommonWorkerChannelClient {
     RedChannelClient base;
 
     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;
@@ -45,9 +45,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,
@@ -97,21 +97,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_proc handle_parsed);
+
+CommonWorkerChannelClient *common_worker_channel_new_client(CommonWorkerChannel *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);
 
 #endif
-- 
2.5.0



More information about the Spice-devel mailing list