[Spice-commits] 5 commits - server/char-device.c server/char-device.h server/reds-private.h server/reds.c server/reds.h server/smartcard.c server/smartcard.h server/spicevmc.c

Frediano Ziglio fziglio at kemper.freedesktop.org
Fri Apr 1 11:00:18 UTC 2016


 server/char-device.c  |  505 +++++++++++++++++++++++++-------------------------
 server/char-device.h  |  140 +++++++------
 server/reds-private.h |    4 
 server/reds.c         |  162 ++++++++--------
 server/reds.h         |    3 
 server/smartcard.c    |   94 ++++-----
 server/smartcard.h    |    2 
 server/spicevmc.c     |   81 ++++----
 8 files changed, 499 insertions(+), 492 deletions(-)

New commits:
commit a24ebcae8965d188edd9798f813fb37e3dfe6475
Author: Jonathon Jongsma <jjongsma at redhat.com>
Date:   Thu Mar 31 16:07:03 2016 -0500

    Rename RedCharDevice functions
    
    make the function names match the type names. So
    spice_char_device_state_* becomes red_char_device_* and
    spice_char_device_* also becomes red_char_device_*.
    
    Acked-by: Frediano Ziglio <fziglio at redhat.com>

diff --git a/server/char-device.c b/server/char-device.c
index d5f203f..2957a1b 100644
--- a/server/char-device.c
+++ b/server/char-device.c
@@ -27,7 +27,7 @@
 #include "reds.h"
 
 #define CHAR_DEVICE_WRITE_TO_TIMEOUT 100
-#define SPICE_CHAR_DEVICE_WAIT_TOKENS_TIMEOUT 30000
+#define RED_CHAR_DEVICE_WAIT_TOKENS_TIMEOUT 30000
 #define MAX_POOL_SIZE (10 * 64 * 1024)
 
 typedef struct RedCharDeviceClient RedCharDeviceClient;
@@ -88,8 +88,8 @@ enum {
 
 /* Holding references for avoiding access violation if the char device was
  * destroyed during a callback */
-static void spice_char_device_state_ref(RedCharDevice *char_dev);
-static void spice_char_device_state_unref(RedCharDevice *char_dev);
+static void red_char_device_ref(RedCharDevice *char_dev);
+static void red_char_device_unref(RedCharDevice *char_dev);
 static void red_char_device_write_buffer_unref(RedCharDeviceWriteBuffer *write_buf);
 
 static void spice_char_dev_write_retry(void *opaque);
@@ -100,43 +100,43 @@ typedef struct RedCharDeviceMsgToClientItem {
 } RedCharDeviceMsgToClientItem;
 
 static RedCharDeviceMsgToClient *
-spice_char_device_read_one_msg_from_device(RedCharDevice *dev)
+red_char_device_read_one_msg_from_device(RedCharDevice *dev)
 {
    return dev->priv->cbs.read_one_msg_from_device(dev->priv->sin, dev->priv->opaque);
 }
 
 static RedCharDeviceMsgToClient *
-spice_char_device_ref_msg_to_client(RedCharDevice *dev,
-                                    RedCharDeviceMsgToClient *msg)
+red_char_device_ref_msg_to_client(RedCharDevice *dev,
+                                  RedCharDeviceMsgToClient *msg)
 {
    return dev->priv->cbs.ref_msg_to_client(msg, dev->priv->opaque);
 }
 
 static void
-spice_char_device_unref_msg_to_client(RedCharDevice *dev,
-                                      RedCharDeviceMsgToClient *msg)
+red_char_device_unref_msg_to_client(RedCharDevice *dev,
+                                    RedCharDeviceMsgToClient *msg)
 {
    dev->priv->cbs.unref_msg_to_client(msg, dev->priv->opaque);
 }
 
 static void
-spice_char_device_send_msg_to_client(RedCharDevice *dev,
-                                     RedCharDeviceMsgToClient *msg,
-                                     RedClient *client)
+red_char_device_send_msg_to_client(RedCharDevice *dev,
+                                   RedCharDeviceMsgToClient *msg,
+                                   RedClient *client)
 {
    dev->priv->cbs.send_msg_to_client(msg, client, dev->priv->opaque);
 }
 
 static void
-spice_char_device_send_tokens_to_client(RedCharDevice *dev,
-                                        RedClient *client,
-                                        uint32_t tokens)
+red_char_device_send_tokens_to_client(RedCharDevice *dev,
+                                      RedClient *client,
+                                      uint32_t tokens)
 {
    dev->priv->cbs.send_tokens_to_client(client, tokens, dev->priv->opaque);
 }
 
 static void
-spice_char_device_on_free_self_token(RedCharDevice *dev)
+red_char_device_on_free_self_token(RedCharDevice *dev)
 {
    if (dev->priv->cbs.on_free_self_token != NULL) {
        dev->priv->cbs.on_free_self_token(dev->priv->opaque);
@@ -144,7 +144,7 @@ spice_char_device_on_free_self_token(RedCharDevice *dev)
 }
 
 static void
-spice_char_device_remove_client(RedCharDevice *dev, RedClient *client)
+red_char_device_remove_client(RedCharDevice *dev, RedClient *client)
 {
    dev->priv->cbs.remove_client(client, dev->priv->opaque);
 }
@@ -170,8 +170,8 @@ static void write_buffers_queue_free(Ring *write_queue)
     }
 }
 
-static void spice_char_device_write_buffer_pool_add(RedCharDevice *dev,
-                                                    RedCharDeviceWriteBuffer *buf)
+static void red_char_device_write_buffer_pool_add(RedCharDevice *dev,
+                                                  RedCharDeviceWriteBuffer *buf)
 {
     if (buf->refs == 1 &&
         dev->priv->cur_pool_size < MAX_POOL_SIZE) {
@@ -187,8 +187,8 @@ static void spice_char_device_write_buffer_pool_add(RedCharDevice *dev,
     red_char_device_write_buffer_unref(buf);
 }
 
-static void spice_char_device_client_send_queue_free(RedCharDevice *dev,
-                                                     RedCharDeviceClient *dev_client)
+static void red_char_device_client_send_queue_free(RedCharDevice *dev,
+                                                   RedCharDeviceClient *dev_client)
 {
     spice_debug("send_queue_empty %d", ring_is_empty(&dev_client->send_queue));
     while (!ring_is_empty(&dev_client->send_queue)) {
@@ -198,15 +198,15 @@ static void spice_char_device_client_send_queue_free(RedCharDevice *dev,
                                                                    link);
 
         ring_remove(item);
-        spice_char_device_unref_msg_to_client(dev, msg_item->msg);
+        red_char_device_unref_msg_to_client(dev, msg_item->msg);
         free(msg_item);
     }
     dev_client->num_send_tokens += dev_client->send_queue_size;
     dev_client->send_queue_size = 0;
 }
 
-static void spice_char_device_client_free(RedCharDevice *dev,
-                                          RedCharDeviceClient *dev_client)
+static void red_char_device_client_free(RedCharDevice *dev,
+                                        RedCharDeviceClient *dev_client)
 {
     RingItem *item, *next;
 
@@ -215,7 +215,7 @@ static void spice_char_device_client_free(RedCharDevice *dev,
         dev_client->wait_for_tokens_timer = NULL;
     }
 
-    spice_char_device_client_send_queue_free(dev, dev_client);
+    red_char_device_client_send_queue_free(dev, dev_client);
 
     /* remove write buffers that are associated with the client */
     spice_debug("write_queue_is_empty %d", ring_is_empty(&dev->priv->write_queue) && !dev->priv->cur_write_buf);
@@ -226,7 +226,7 @@ static void spice_char_device_client_free(RedCharDevice *dev,
         if (write_buf->origin == WRITE_BUFFER_ORIGIN_CLIENT &&
             write_buf->client == dev_client->client) {
             ring_remove(item);
-            spice_char_device_write_buffer_pool_add(dev, write_buf);
+            red_char_device_write_buffer_pool_add(dev, write_buf);
         }
     }
 
@@ -241,15 +241,15 @@ static void spice_char_device_client_free(RedCharDevice *dev,
     free(dev_client);
 }
 
-static void spice_char_device_handle_client_overflow(RedCharDeviceClient *dev_client)
+static void red_char_device_handle_client_overflow(RedCharDeviceClient *dev_client)
 {
     RedCharDevice *dev = dev_client->dev;
     spice_printerr("dev %p client %p ", dev, dev_client);
-    spice_char_device_remove_client(dev, dev_client->client);
+    red_char_device_remove_client(dev, dev_client->client);
 }
 
-static RedCharDeviceClient *spice_char_device_client_find(RedCharDevice *dev,
-                                                          RedClient *client)
+static RedCharDeviceClient *red_char_device_client_find(RedCharDevice *dev,
+                                                        RedClient *client)
 {
     RingItem *item;
 
@@ -272,15 +272,15 @@ static void device_client_wait_for_tokens_timeout(void *opaque)
 {
     RedCharDeviceClient *dev_client = opaque;
 
-    spice_char_device_handle_client_overflow(dev_client);
+    red_char_device_handle_client_overflow(dev_client);
 }
 
-static int spice_char_device_can_send_to_client(RedCharDeviceClient *dev_client)
+static int red_char_device_can_send_to_client(RedCharDeviceClient *dev_client)
 {
     return !dev_client->do_flow_control || dev_client->num_send_tokens;
 }
 
-static uint64_t spice_char_device_max_send_tokens(RedCharDevice *dev)
+static uint64_t red_char_device_max_send_tokens(RedCharDevice *dev)
 {
     RingItem *item;
     uint64_t max = 0;
@@ -302,30 +302,30 @@ static uint64_t spice_char_device_max_send_tokens(RedCharDevice *dev)
     return max;
 }
 
-static void spice_char_device_add_msg_to_client_queue(RedCharDeviceClient *dev_client,
-                                                      RedCharDeviceMsgToClient *msg)
+static void red_char_device_add_msg_to_client_queue(RedCharDeviceClient *dev_client,
+                                                    RedCharDeviceMsgToClient *msg)
 {
     RedCharDevice *dev = dev_client->dev;
     RedCharDeviceMsgToClientItem *msg_item;
 
     if (dev_client->send_queue_size >= dev_client->max_send_queue_size) {
-        spice_char_device_handle_client_overflow(dev_client);
+        red_char_device_handle_client_overflow(dev_client);
         return;
     }
 
     msg_item = spice_new0(RedCharDeviceMsgToClientItem, 1);
-    msg_item->msg = spice_char_device_ref_msg_to_client(dev, msg);
+    msg_item->msg = red_char_device_ref_msg_to_client(dev, msg);
     ring_add(&dev_client->send_queue, &msg_item->link);
     dev_client->send_queue_size++;
     if (!dev_client->wait_for_tokens_started) {
         reds_core_timer_start(dev->priv->reds, dev_client->wait_for_tokens_timer,
-                              SPICE_CHAR_DEVICE_WAIT_TOKENS_TIMEOUT);
+                              RED_CHAR_DEVICE_WAIT_TOKENS_TIMEOUT);
         dev_client->wait_for_tokens_started = TRUE;
     }
 }
 
-static void spice_char_device_send_msg_to_clients(RedCharDevice *dev,
-                                                  RedCharDeviceMsgToClient *msg)
+static void red_char_device_send_msg_to_clients(RedCharDevice *dev,
+                                                RedCharDeviceMsgToClient *msg)
 {
     RingItem *item, *next;
 
@@ -333,19 +333,19 @@ static void spice_char_device_send_msg_to_clients(RedCharDevice *dev,
         RedCharDeviceClient *dev_client;
 
         dev_client = SPICE_CONTAINEROF(item, RedCharDeviceClient, link);
-        if (spice_char_device_can_send_to_client(dev_client)) {
+        if (red_char_device_can_send_to_client(dev_client)) {
             dev_client->num_send_tokens--;
             spice_assert(ring_is_empty(&dev_client->send_queue));
-            spice_char_device_send_msg_to_client(dev, msg, dev_client->client);
+            red_char_device_send_msg_to_client(dev, msg, dev_client->client);
 
             /* don't refer to dev_client anymore, it may have been released */
         } else {
-            spice_char_device_add_msg_to_client_queue(dev_client, msg);
+            red_char_device_add_msg_to_client_queue(dev_client, msg);
         }
     }
 }
 
-static int spice_char_device_read_from_device(RedCharDevice *dev)
+static int red_char_device_read_from_device(RedCharDevice *dev)
 {
     uint64_t max_send_tokens;
     int did_read = FALSE;
@@ -364,8 +364,8 @@ static int spice_char_device_read_from_device(RedCharDevice *dev)
         return FALSE;
     }
 
-    max_send_tokens = spice_char_device_max_send_tokens(dev);
-    spice_char_device_state_ref(dev);
+    max_send_tokens = red_char_device_max_send_tokens(dev);
+    red_char_device_ref(dev);
     /*
      * Reading from the device only in case at least one of the clients have a free token.
      * All messages will be discarded if no client is attached to the device
@@ -373,7 +373,7 @@ static int spice_char_device_read_from_device(RedCharDevice *dev)
     while ((max_send_tokens || ring_is_empty(&dev->priv->clients)) && dev->priv->running) {
         RedCharDeviceMsgToClient *msg;
 
-        msg = spice_char_device_read_one_msg_from_device(dev);
+        msg = red_char_device_read_one_msg_from_device(dev);
         if (!msg) {
             if (dev->priv->during_read_from_device > 1) {
                 dev->priv->during_read_from_device = 1;
@@ -383,82 +383,82 @@ static int spice_char_device_read_from_device(RedCharDevice *dev)
             break;
         }
         did_read = TRUE;
-        spice_char_device_send_msg_to_clients(dev, msg);
-        spice_char_device_unref_msg_to_client(dev, msg);
+        red_char_device_send_msg_to_clients(dev, msg);
+        red_char_device_unref_msg_to_client(dev, msg);
         max_send_tokens--;
     }
     dev->priv->during_read_from_device = 0;
     if (dev->priv->running) {
         dev->priv->active = dev->priv->active || did_read;
     }
-    spice_char_device_state_unref(dev);
+    red_char_device_unref(dev);
     return did_read;
 }
 
-static void spice_char_device_client_send_queue_push(RedCharDeviceClient *dev_client)
+static void red_char_device_client_send_queue_push(RedCharDeviceClient *dev_client)
 {
     RingItem *item;
     while ((item = ring_get_tail(&dev_client->send_queue)) &&
-           spice_char_device_can_send_to_client(dev_client)) {
+           red_char_device_can_send_to_client(dev_client)) {
         RedCharDeviceMsgToClientItem *msg_item;
 
         msg_item = SPICE_CONTAINEROF(item, RedCharDeviceMsgToClientItem, link);
         ring_remove(item);
 
         dev_client->num_send_tokens--;
-        spice_char_device_send_msg_to_client(dev_client->dev,
-                                             msg_item->msg,
-                                             dev_client->client);
-        spice_char_device_unref_msg_to_client(dev_client->dev, msg_item->msg);
+        red_char_device_send_msg_to_client(dev_client->dev,
+                                           msg_item->msg,
+                                           dev_client->client);
+        red_char_device_unref_msg_to_client(dev_client->dev, msg_item->msg);
         dev_client->send_queue_size--;
         free(msg_item);
     }
 }
 
-static void spice_char_device_send_to_client_tokens_absorb(RedCharDeviceClient *dev_client,
-                                                           uint32_t tokens)
+static void red_char_device_send_to_client_tokens_absorb(RedCharDeviceClient *dev_client,
+                                                         uint32_t tokens)
 {
     RedCharDevice *dev = dev_client->dev;
     dev_client->num_send_tokens += tokens;
 
     if (dev_client->send_queue_size) {
         spice_assert(dev_client->num_send_tokens == tokens);
-        spice_char_device_client_send_queue_push(dev_client);
+        red_char_device_client_send_queue_push(dev_client);
     }
 
-    if (spice_char_device_can_send_to_client(dev_client)) {
+    if (red_char_device_can_send_to_client(dev_client)) {
         reds_core_timer_cancel(dev->priv->reds, dev_client->wait_for_tokens_timer);
         dev_client->wait_for_tokens_started = FALSE;
-        spice_char_device_read_from_device(dev_client->dev);
+        red_char_device_read_from_device(dev_client->dev);
     } else if (dev_client->send_queue_size) {
         reds_core_timer_start(dev->priv->reds, dev_client->wait_for_tokens_timer,
-                              SPICE_CHAR_DEVICE_WAIT_TOKENS_TIMEOUT);
+                              RED_CHAR_DEVICE_WAIT_TOKENS_TIMEOUT);
         dev_client->wait_for_tokens_started = TRUE;
     }
 }
 
-void spice_char_device_send_to_client_tokens_add(RedCharDevice *dev,
-                                                 RedClient *client,
-                                                 uint32_t tokens)
+void red_char_device_send_to_client_tokens_add(RedCharDevice *dev,
+                                               RedClient *client,
+                                               uint32_t tokens)
 {
     RedCharDeviceClient *dev_client;
 
-    dev_client = spice_char_device_client_find(dev, client);
+    dev_client = red_char_device_client_find(dev, client);
 
     if (!dev_client) {
         spice_error("client wasn't found dev %p client %p", dev, client);
         return;
     }
-    spice_char_device_send_to_client_tokens_absorb(dev_client, tokens);
+    red_char_device_send_to_client_tokens_absorb(dev_client, tokens);
 }
 
-void spice_char_device_send_to_client_tokens_set(RedCharDevice *dev,
-                                                 RedClient *client,
-                                                 uint32_t tokens)
+void red_char_device_send_to_client_tokens_set(RedCharDevice *dev,
+                                               RedClient *client,
+                                               uint32_t tokens)
 {
     RedCharDeviceClient *dev_client;
 
-    dev_client = spice_char_device_client_find(dev, client);
+    dev_client = red_char_device_client_find(dev, client);
 
     if (!dev_client) {
         spice_error("client wasn't found dev %p client %p", dev, client);
@@ -466,16 +466,16 @@ void spice_char_device_send_to_client_tokens_set(RedCharDevice *dev,
     }
 
     dev_client->num_send_tokens = 0;
-    spice_char_device_send_to_client_tokens_absorb(dev_client, tokens);
+    red_char_device_send_to_client_tokens_absorb(dev_client, tokens);
 }
 
 /**************************
  * Writing to the device  *
 ***************************/
 
-static void spice_char_device_client_tokens_add(RedCharDevice *dev,
-                                                RedCharDeviceClient *dev_client,
-                                                uint32_t num_tokens)
+static void red_char_device_client_tokens_add(RedCharDevice *dev,
+                                              RedCharDeviceClient *dev_client,
+                                              uint32_t num_tokens)
 {
     if (!dev_client->do_flow_control) {
         return;
@@ -489,11 +489,11 @@ static void spice_char_device_client_tokens_add(RedCharDevice *dev,
 
         dev_client->num_client_tokens += dev_client->num_client_tokens_free;
         dev_client->num_client_tokens_free = 0;
-        spice_char_device_send_tokens_to_client(dev, dev_client->client, tokens);
+        red_char_device_send_tokens_to_client(dev, dev_client->client, tokens);
     }
 }
 
-static int spice_char_device_write_to_device(RedCharDevice *dev)
+static int red_char_device_write_to_device(RedCharDevice *dev)
 {
     SpiceCharDeviceInterface *sif;
     int total = 0;
@@ -503,12 +503,12 @@ static int spice_char_device_write_to_device(RedCharDevice *dev)
         return 0;
     }
 
-    /* protect against recursion with spice_char_device_wakeup */
+    /* protect against recursion with red_char_device_wakeup */
     if (dev->priv->during_write_to_device++ > 0) {
         return 0;
     }
 
-    spice_char_device_state_ref(dev);
+    red_char_device_ref(dev);
 
     if (dev->priv->write_to_dev_timer) {
         reds_core_timer_cancel(dev->priv->reds, dev->priv->write_to_dev_timer);
@@ -544,7 +544,7 @@ static int spice_char_device_write_to_device(RedCharDevice *dev)
         if (!write_len) {
             RedCharDeviceWriteBuffer *release_buf = dev->priv->cur_write_buf;
             dev->priv->cur_write_buf = NULL;
-            spice_char_device_write_buffer_release(dev, release_buf);
+            red_char_device_write_buffer_release(dev, release_buf);
             continue;
         }
         dev->priv->cur_write_buf_pos += n;
@@ -562,7 +562,7 @@ static int spice_char_device_write_to_device(RedCharDevice *dev)
         dev->priv->active = dev->priv->active || total;
     }
     dev->priv->during_write_to_device = 0;
-    spice_char_device_state_unref(dev);
+    red_char_device_unref(dev);
     return total;
 }
 
@@ -573,10 +573,10 @@ static void spice_char_dev_write_retry(void *opaque)
     if (dev->priv->write_to_dev_timer) {
         reds_core_timer_cancel(dev->priv->reds, dev->priv->write_to_dev_timer);
     }
-    spice_char_device_write_to_device(dev);
+    red_char_device_write_to_device(dev);
 }
 
-static RedCharDeviceWriteBuffer *__spice_char_device_write_buffer_get(
+static RedCharDeviceWriteBuffer *__red_char_device_write_buffer_get(
     RedCharDevice *dev, RedClient *client,
     int size, int origin, int migrated_data_tokens)
 {
@@ -605,12 +605,12 @@ static RedCharDeviceWriteBuffer *__spice_char_device_write_buffer_get(
 
     if (origin == WRITE_BUFFER_ORIGIN_CLIENT) {
        spice_assert(client);
-       RedCharDeviceClient *dev_client = spice_char_device_client_find(dev, client);
+       RedCharDeviceClient *dev_client = red_char_device_client_find(dev, client);
        if (dev_client) {
             if (!migrated_data_tokens &&
                 dev_client->do_flow_control && !dev_client->num_client_tokens) {
                 spice_printerr("token violation: dev %p client %p", dev, client);
-                spice_char_device_handle_client_overflow(dev_client);
+                red_char_device_handle_client_overflow(dev_client);
                 goto error;
             }
             ret->client = client;
@@ -636,19 +636,19 @@ error:
     return NULL;
 }
 
-RedCharDeviceWriteBuffer *spice_char_device_write_buffer_get(RedCharDevice *dev,
-                                                             RedClient *client,
-                                                             int size)
+RedCharDeviceWriteBuffer *red_char_device_write_buffer_get(RedCharDevice *dev,
+                                                           RedClient *client,
+                                                           int size)
 {
-   return  __spice_char_device_write_buffer_get(dev, client, size,
+   return  __red_char_device_write_buffer_get(dev, client, size,
              client ? WRITE_BUFFER_ORIGIN_CLIENT : WRITE_BUFFER_ORIGIN_SERVER,
              0);
 }
 
-RedCharDeviceWriteBuffer *spice_char_device_write_buffer_get_server_no_token(
+RedCharDeviceWriteBuffer *red_char_device_write_buffer_get_server_no_token(
     RedCharDevice *dev, int size)
 {
-   return  __spice_char_device_write_buffer_get(dev, NULL, size,
+   return  __red_char_device_write_buffer_get(dev, NULL, size,
              WRITE_BUFFER_ORIGIN_SERVER_NO_TOKEN, 0);
 }
 
@@ -669,24 +669,24 @@ static void red_char_device_write_buffer_unref(RedCharDeviceWriteBuffer *write_b
         red_char_device_write_buffer_free(write_buf);
 }
 
-void spice_char_device_write_buffer_add(RedCharDevice *dev,
-                                        RedCharDeviceWriteBuffer *write_buf)
+void red_char_device_write_buffer_add(RedCharDevice *dev,
+                                      RedCharDeviceWriteBuffer *write_buf)
 {
     spice_assert(dev);
     /* caller shouldn't add buffers for client that was removed */
     if (write_buf->origin == WRITE_BUFFER_ORIGIN_CLIENT &&
-        !spice_char_device_client_find(dev, write_buf->client)) {
+        !red_char_device_client_find(dev, write_buf->client)) {
         spice_printerr("client not found: dev %p client %p", dev, write_buf->client);
-        spice_char_device_write_buffer_pool_add(dev, write_buf);
+        red_char_device_write_buffer_pool_add(dev, write_buf);
         return;
     }
 
     ring_add(&dev->priv->write_queue, &write_buf->link);
-    spice_char_device_write_to_device(dev);
+    red_char_device_write_to_device(dev);
 }
 
-void spice_char_device_write_buffer_release(RedCharDevice *dev,
-                                            RedCharDeviceWriteBuffer *write_buf)
+void red_char_device_write_buffer_release(RedCharDevice *dev,
+                                          RedCharDeviceWriteBuffer *write_buf)
 {
     int buf_origin = write_buf->origin;
     uint32_t buf_token_price = write_buf->token_price;
@@ -701,18 +701,18 @@ void spice_char_device_write_buffer_release(RedCharDevice *dev,
 
     spice_assert(dev->priv->cur_write_buf != write_buf);
 
-    spice_char_device_write_buffer_pool_add(dev, write_buf);
+    red_char_device_write_buffer_pool_add(dev, write_buf);
     if (buf_origin == WRITE_BUFFER_ORIGIN_CLIENT) {
         RedCharDeviceClient *dev_client;
 
         spice_assert(client);
-        dev_client = spice_char_device_client_find(dev, client);
+        dev_client = red_char_device_client_find(dev, client);
         /* when a client is removed, we remove all the buffers that are associated with it */
         spice_assert(dev_client);
-        spice_char_device_client_tokens_add(dev, dev_client, buf_token_price);
+        red_char_device_client_tokens_add(dev, dev_client, buf_token_price);
     } else if (buf_origin == WRITE_BUFFER_ORIGIN_SERVER) {
         dev->priv->num_self_tokens++;
-        spice_char_device_on_free_self_token(dev);
+        red_char_device_on_free_self_token(dev);
     }
 }
 
@@ -720,12 +720,12 @@ void spice_char_device_write_buffer_release(RedCharDevice *dev,
  * char_device_state management *
  ********************************/
 
-RedCharDevice *spice_char_device_state_create(SpiceCharDeviceInstance *sin,
-                                              RedsState *reds,
-                                              uint32_t client_tokens_interval,
-                                              uint32_t self_tokens,
-                                              SpiceCharDeviceCallbacks *cbs,
-                                              void *opaque)
+RedCharDevice *red_char_device_create(SpiceCharDeviceInstance *sin,
+                                      RedsState *reds,
+                                      uint32_t client_tokens_interval,
+                                      uint32_t self_tokens,
+                                      SpiceCharDeviceCallbacks *cbs,
+                                      void *opaque)
 {
     RedCharDevice *char_dev;
     SpiceCharDeviceInterface *sif;
@@ -762,39 +762,39 @@ RedCharDevice *spice_char_device_state_create(SpiceCharDeviceInstance *sin,
     return char_dev;
 }
 
-void spice_char_device_state_reset_dev_instance(RedCharDevice *state,
-                                                SpiceCharDeviceInstance *sin)
+void red_char_device_reset_dev_instance(RedCharDevice *state,
+                                        SpiceCharDeviceInstance *sin)
 {
     spice_debug("sin %p dev_state %p", sin, state);
     state->priv->sin = sin;
     sin->st = state;
 }
 
-void *spice_char_device_state_opaque_get(RedCharDevice *dev)
+void *red_char_device_opaque_get(RedCharDevice *dev)
 {
     return dev->priv->opaque;
 }
 
-static void spice_char_device_state_ref(RedCharDevice *char_dev)
+static void red_char_device_ref(RedCharDevice *char_dev)
 {
     char_dev->priv->refs++;
 }
 
-static void spice_char_device_state_unref(RedCharDevice *char_dev)
+static void red_char_device_unref(RedCharDevice *char_dev)
 {
     /* The refs field protects the char_dev from being deallocated in
-     * case spice_char_device_state_destroy has been called
+     * case red_char_device_destroy has been called
      * during a callabck, and we might still access the char_dev afterwards.
-     * spice_char_device_state_unref is always coupled with a preceding
-     * spice_char_device_state_ref. Here, refs can turn 0
-     * only when spice_char_device_state_destroy is called in between
-     * the calls to spice_char_device_state_ref and spice_char_device_state_unref.*/
+     * red_char_device_unref is always coupled with a preceding
+     * red_char_device_ref. Here, refs can turn 0
+     * only when red_char_device_destroy is called in between
+     * the calls to red_char_device_ref and red_char_device_unref.*/
     if (!--char_dev->priv->refs) {
         free(char_dev);
     }
 }
 
-void spice_char_device_state_destroy(RedCharDevice *char_dev)
+void red_char_device_destroy(RedCharDevice *char_dev)
 {
     reds_on_char_device_state_destroy(char_dev->priv->reds, char_dev);
     if (char_dev->priv->write_to_dev_timer) {
@@ -812,11 +812,11 @@ void spice_char_device_state_destroy(RedCharDevice *char_dev)
         RedCharDeviceClient *dev_client;
 
         dev_client = SPICE_CONTAINEROF(item, RedCharDeviceClient, link);
-        spice_char_device_client_free(char_dev, dev_client);
+        red_char_device_client_free(char_dev, dev_client);
     }
     char_dev->priv->running = FALSE;
 
-    spice_char_device_state_unref(char_dev);
+    red_char_device_unref(char_dev);
 }
 
 static RedCharDeviceClient *red_char_device_client_new(RedClient *client,
@@ -850,13 +850,13 @@ static RedCharDeviceClient *red_char_device_client_new(RedClient *client,
     return dev_client;
 }
 
-int spice_char_device_client_add(RedCharDevice *dev,
-                                 RedClient *client,
-                                 int do_flow_control,
-                                 uint32_t max_send_queue_size,
-                                 uint32_t num_client_tokens,
-                                 uint32_t num_send_tokens,
-                                 int wait_for_migrate_data)
+int red_char_device_client_add(RedCharDevice *dev,
+                               RedClient *client,
+                               int do_flow_control,
+                               uint32_t max_send_queue_size,
+                               uint32_t num_client_tokens,
+                               uint32_t num_send_tokens,
+                               int wait_for_migrate_data)
 {
     RedCharDeviceClient *dev_client;
 
@@ -880,27 +880,27 @@ int spice_char_device_client_add(RedCharDevice *dev,
     ring_add(&dev->priv->clients, &dev_client->link);
     dev->priv->num_clients++;
     /* Now that we have a client, forward any pending device data */
-    spice_char_device_wakeup(dev);
+    red_char_device_wakeup(dev);
     return TRUE;
 }
 
-void spice_char_device_client_remove(RedCharDevice *dev,
-                                     RedClient *client)
+void red_char_device_client_remove(RedCharDevice *dev,
+                                   RedClient *client)
 {
     RedCharDeviceClient *dev_client;
 
     spice_debug("dev_state %p client %p", dev, client);
-    dev_client = spice_char_device_client_find(dev, client);
+    dev_client = red_char_device_client_find(dev, client);
 
     if (!dev_client) {
         spice_error("client wasn't found");
         return;
     }
-    spice_char_device_client_free(dev, dev_client);
+    red_char_device_client_free(dev, dev_client);
     if (dev->priv->wait_for_migrate_data) {
         spice_assert(dev->priv->num_clients == 0);
         dev->priv->wait_for_migrate_data  = FALSE;
-        spice_char_device_read_from_device(dev);
+        red_char_device_read_from_device(dev);
     }
 
     if (dev->priv->num_clients == 0) {
@@ -910,23 +910,23 @@ void spice_char_device_client_remove(RedCharDevice *dev,
     }
 }
 
-int spice_char_device_client_exists(RedCharDevice *dev,
-                                    RedClient *client)
+int red_char_device_client_exists(RedCharDevice *dev,
+                                  RedClient *client)
 {
-    return (spice_char_device_client_find(dev, client) != NULL);
+    return (red_char_device_client_find(dev, client) != NULL);
 }
 
-void spice_char_device_start(RedCharDevice *dev)
+void red_char_device_start(RedCharDevice *dev)
 {
     spice_debug("dev_state %p", dev);
     dev->priv->running = TRUE;
-    spice_char_device_state_ref(dev);
-    while (spice_char_device_write_to_device(dev) ||
-           spice_char_device_read_from_device(dev));
-    spice_char_device_state_unref(dev);
+    red_char_device_ref(dev);
+    while (red_char_device_write_to_device(dev) ||
+           red_char_device_read_from_device(dev));
+    red_char_device_unref(dev);
 }
 
-void spice_char_device_stop(RedCharDevice *dev)
+void red_char_device_stop(RedCharDevice *dev)
 {
     spice_debug("dev_state %p", dev);
     dev->priv->running = FALSE;
@@ -936,11 +936,11 @@ void spice_char_device_stop(RedCharDevice *dev)
     }
 }
 
-void spice_char_device_reset(RedCharDevice *dev)
+void red_char_device_reset(RedCharDevice *dev)
 {
     RingItem *client_item;
 
-    spice_char_device_stop(dev);
+    red_char_device_stop(dev);
     dev->priv->wait_for_migrate_data = FALSE;
     spice_debug("dev_state %p", dev);
     while (!ring_is_empty(&dev->priv->write_queue)) {
@@ -950,35 +950,35 @@ void spice_char_device_reset(RedCharDevice *dev)
         ring_remove(item);
         buf = SPICE_CONTAINEROF(item, RedCharDeviceWriteBuffer, link);
         /* tracking the tokens */
-        spice_char_device_write_buffer_release(dev, buf);
+        red_char_device_write_buffer_release(dev, buf);
     }
     if (dev->priv->cur_write_buf) {
         RedCharDeviceWriteBuffer *release_buf = dev->priv->cur_write_buf;
 
         dev->priv->cur_write_buf = NULL;
-        spice_char_device_write_buffer_release(dev, release_buf);
+        red_char_device_write_buffer_release(dev, release_buf);
     }
 
     RING_FOREACH(client_item, &dev->priv->clients) {
         RedCharDeviceClient *dev_client;
 
         dev_client = SPICE_CONTAINEROF(client_item, RedCharDeviceClient, link);
-        spice_char_device_client_send_queue_free(dev, dev_client);
+        red_char_device_client_send_queue_free(dev, dev_client);
     }
     dev->priv->sin = NULL;
 }
 
-void spice_char_device_wakeup(RedCharDevice *dev)
+void red_char_device_wakeup(RedCharDevice *dev)
 {
-    spice_char_device_write_to_device(dev);
-    spice_char_device_read_from_device(dev);
+    red_char_device_write_to_device(dev);
+    red_char_device_read_from_device(dev);
 }
 
 /*************
  * Migration *
  * **********/
 
-void spice_char_device_state_migrate_data_marshall_empty(SpiceMarshaller *m)
+void red_char_device_migrate_data_marshall_empty(SpiceMarshaller *m)
 {
     SpiceMigrateDataCharDevice *mig_data;
 
@@ -997,8 +997,8 @@ static void migrate_data_marshaller_write_buffer_free(uint8_t *data, void *opaqu
     red_char_device_write_buffer_unref(write_buf);
 }
 
-void spice_char_device_state_migrate_data_marshall(RedCharDevice *dev,
-                                                   SpiceMarshaller *m)
+void red_char_device_migrate_data_marshall(RedCharDevice *dev,
+                                           SpiceMarshaller *m)
 {
     RedCharDeviceClient *dev_client;
     RingItem *item;
@@ -1057,8 +1057,8 @@ void spice_char_device_state_migrate_data_marshall(RedCharDevice *dev,
                 dev, *write_to_dev_size_ptr, *write_to_dev_tokens_ptr);
 }
 
-int spice_char_device_state_restore(RedCharDevice *dev,
-                                    SpiceMigrateDataCharDevice *mig_data)
+int red_char_device_restore(RedCharDevice *dev,
+                            SpiceMigrateDataCharDevice *mig_data)
 {
     RedCharDeviceClient *dev_client;
     uint32_t client_tokens_window;
@@ -1087,12 +1087,12 @@ int spice_char_device_state_restore(RedCharDevice *dev,
     if (mig_data->write_size > 0) {
         if (mig_data->write_num_client_tokens) {
             dev->priv->cur_write_buf =
-                __spice_char_device_write_buffer_get(dev, dev_client->client,
+                __red_char_device_write_buffer_get(dev, dev_client->client,
                     mig_data->write_size, WRITE_BUFFER_ORIGIN_CLIENT,
                     mig_data->write_num_client_tokens);
         } else {
             dev->priv->cur_write_buf =
-                __spice_char_device_write_buffer_get(dev, NULL,
+                __red_char_device_write_buffer_get(dev, NULL,
                     mig_data->write_size, WRITE_BUFFER_ORIGIN_SERVER, 0);
         }
         /* the first write buffer contains all the data that was saved for migration */
@@ -1103,12 +1103,12 @@ int spice_char_device_state_restore(RedCharDevice *dev,
         dev->priv->cur_write_buf_pos = dev->priv->cur_write_buf->buf;
     }
     dev->priv->wait_for_migrate_data = FALSE;
-    spice_char_device_write_to_device(dev);
-    spice_char_device_read_from_device(dev);
+    red_char_device_write_to_device(dev);
+    red_char_device_read_from_device(dev);
     return TRUE;
 }
 
-SpiceServer* spice_char_device_get_server(RedCharDevice *dev)
+SpiceServer* red_char_device_get_server(RedCharDevice *dev)
 {
     return dev->priv->reds;
 }
diff --git a/server/char-device.h b/server/char-device.h
index 86bf1b9..f3ae6cb 100644
--- a/server/char-device.h
+++ b/server/char-device.h
@@ -27,19 +27,19 @@
  *
  * How to use the api:
  * ==================
- * device attached: call spice_char_device_state_create
- * device detached: call spice_char_device_state_destroy/reset
+ * device attached: call red_char_device_create
+ * device detached: call red_char_device_destroy/reset
  *
- * client connected and associated with a device: spice_char_device_client_add
- * client disconnected: spice_char_device_client_remove
+ * client connected and associated with a device: red_char_device__add
+ * client disconnected: red_char_device__remove
  *
  * Writing to the device
  * ---------------------
  * Write the data into RedCharDeviceWriteBuffer:
- * call spice_char_device_write_buffer_get in order to get an appropriate buffer.
- * call spice_char_device_write_buffer_add in order to push the buffer to the write queue.
+ * call red_char_device_buffer_get in order to get an appropriate buffer.
+ * call red_char_device_buffer_add in order to push the buffer to the write queue.
  * If you choose not to push the buffer to the device, call
- * spice_char_device_write_buffer_release
+ * red_char_device_buffer_release
  *
  * reading from the device
  * -----------------------
@@ -51,9 +51,9 @@
  *
  * calls triggered from the device (qemu):
  * --------------------------------------
- * spice_char_device_start
- * spice_char_device_stop
- * spice_char_device_wakeup (for reading from the device)
+ * red_char_device_start
+ * red_char_device_stop
+ * red_char_device_wakeup (for reading from the device)
  */
 
 /*
@@ -131,26 +131,26 @@ typedef struct SpiceCharDeviceCallbacks {
     void (*remove_client)(RedClient *client, void *opaque);
 } SpiceCharDeviceCallbacks;
 
-RedCharDevice *spice_char_device_state_create(SpiceCharDeviceInstance *sin,
-                                              struct RedsState *reds,
-                                              uint32_t client_tokens_interval,
-                                              uint32_t self_tokens,
-                                              SpiceCharDeviceCallbacks *cbs,
-                                              void *opaque);
+RedCharDevice *red_char_device_create(SpiceCharDeviceInstance *sin,
+                                      struct RedsState *reds,
+                                      uint32_t client_tokens_interval,
+                                      uint32_t self_tokens,
+                                      SpiceCharDeviceCallbacks *cbs,
+                                      void *opaque);
 
-void spice_char_device_state_reset_dev_instance(RedCharDevice *dev,
-                                                SpiceCharDeviceInstance *sin);
-void spice_char_device_state_destroy(RedCharDevice *dev);
+void red_char_device_reset_dev_instance(RedCharDevice *dev,
+                                        SpiceCharDeviceInstance *sin);
+void red_char_device_destroy(RedCharDevice *dev);
 
-void *spice_char_device_state_opaque_get(RedCharDevice *dev);
+void *red_char_device_opaque_get(RedCharDevice *dev);
 
 /* only one client is supported */
-void spice_char_device_state_migrate_data_marshall(RedCharDevice *dev,
-                                                  SpiceMarshaller *m);
-void spice_char_device_state_migrate_data_marshall_empty(SpiceMarshaller *m);
+void red_char_device_migrate_data_marshall(RedCharDevice *dev,
+                                           SpiceMarshaller *m);
+void red_char_device_migrate_data_marshall_empty(SpiceMarshaller *m);
 
-int spice_char_device_state_restore(RedCharDevice *dev,
-                                    SpiceMigrateDataCharDevice *mig_data);
+int red_char_device_restore(RedCharDevice *dev,
+                            SpiceMigrateDataCharDevice *mig_data);
 
 /*
  * Resets write/read queues, and moves that state to being stopped.
@@ -167,50 +167,50 @@ int spice_char_device_state_restore(RedCharDevice *dev,
  *
  *  todo: change AGENT_CONNECT msg to contain tokens count.
  */
-void spice_char_device_reset(RedCharDevice *dev);
+void red_char_device_reset(RedCharDevice *dev);
 
 /* max_send_queue_size = how many messages we can read from the device and enqueue for this client,
  * when we have tokens for other clients and no tokens for this one */
-int spice_char_device_client_add(RedCharDevice *dev,
-                                 RedClient *client,
-                                 int do_flow_control,
-                                 uint32_t max_send_queue_size,
-                                 uint32_t num_client_tokens,
-                                 uint32_t num_send_tokens,
-                                 int wait_for_migrate_data);
-
-void spice_char_device_client_remove(RedCharDevice *dev,
-                                     RedClient *client);
-int spice_char_device_client_exists(RedCharDevice *dev,
-                                    RedClient *client);
-
-void spice_char_device_start(RedCharDevice *dev);
-void spice_char_device_stop(RedCharDevice *dev);
-SpiceServer* spice_char_device_get_server(RedCharDevice *dev);
+int red_char_device_client_add(RedCharDevice *dev,
+                               RedClient *client,
+                               int do_flow_control,
+                               uint32_t max_send_queue_size,
+                               uint32_t num_client_tokens,
+                               uint32_t num_send_tokens,
+                               int wait_for_migrate_data);
+
+void red_char_device_client_remove(RedCharDevice *dev,
+                                   RedClient *client);
+int red_char_device_client_exists(RedCharDevice *dev,
+                                  RedClient *client);
+
+void red_char_device_start(RedCharDevice *dev);
+void red_char_device_stop(RedCharDevice *dev);
+SpiceServer* red_char_device_get_server(RedCharDevice *dev);
 
 /** Read from device **/
 
-void spice_char_device_wakeup(RedCharDevice *dev);
+void red_char_device_wakeup(RedCharDevice *dev);
 
-void spice_char_device_send_to_client_tokens_add(RedCharDevice *dev,
-                                                 RedClient *client,
-                                                 uint32_t tokens);
+void red_char_device_send_to_client_tokens_add(RedCharDevice *dev,
+                                               RedClient *client,
+                                               uint32_t tokens);
 
 
-void spice_char_device_send_to_client_tokens_set(RedCharDevice *dev,
-                                                 RedClient *client,
-                                                 uint32_t tokens);
+void red_char_device_send_to_client_tokens_set(RedCharDevice *dev,
+                                               RedClient *client,
+                                               uint32_t tokens);
 /** Write to device **/
 
-RedCharDeviceWriteBuffer *spice_char_device_write_buffer_get(RedCharDevice *dev,
-                                                             RedClient *client, int size);
-RedCharDeviceWriteBuffer *spice_char_device_write_buffer_get_server_no_token(
+RedCharDeviceWriteBuffer *red_char_device_write_buffer_get(RedCharDevice *dev,
+                                                           RedClient *client, int size);
+RedCharDeviceWriteBuffer *red_char_device_write_buffer_get_server_no_token(
     RedCharDevice *dev, int size);
 
 /* Either add the buffer to the write queue or release it */
-void spice_char_device_write_buffer_add(RedCharDevice *dev,
+void red_char_device_write_buffer_add(RedCharDevice *dev,
                                         RedCharDeviceWriteBuffer *write_buf);
-void spice_char_device_write_buffer_release(RedCharDevice *dev,
+void red_char_device_write_buffer_release(RedCharDevice *dev,
                                             RedCharDeviceWriteBuffer *write_buf);
 
 /* api for specific char devices */
diff --git a/server/reds.c b/server/reds.c
index bb96d09..12de608 100644
--- a/server/reds.c
+++ b/server/reds.c
@@ -434,10 +434,10 @@ static void reds_reset_vdp(RedsState *reds)
      */
     if (red_channel_test_remote_cap(&reds->main_channel->base,
                                     SPICE_MAIN_CAP_AGENT_CONNECTED_TOKENS)) {
-        spice_char_device_state_destroy(state->base);
+        red_char_device_destroy(state->base);
         state->base = NULL;
     } else {
-        spice_char_device_reset(state->base);
+        red_char_device_reset(state->base);
     }
 
     sif = spice_char_device_get_interface(reds->vdagent);
@@ -488,8 +488,8 @@ void reds_client_disconnect(RedsState *reds, RedClient *client)
     if (reds->agent_state.base) {
         /* note that vdagent might be NULL, if the vdagent was once
          * up and than was removed */
-        if (spice_char_device_client_exists(reds->agent_state.base, client)) {
-            spice_char_device_client_remove(reds->agent_state.base, client);
+        if (red_char_device_client_exists(reds->agent_state.base, client)) {
+            red_char_device_client_remove(reds->agent_state.base, client);
         }
     }
 
@@ -507,7 +507,7 @@ void reds_client_disconnect(RedsState *reds, RedClient *client)
             uint32_t total_msg_size;
 
             total_msg_size = sizeof(VDIChunkHeader) + sizeof(VDAgentMessage);
-            char_dev_buf = spice_char_device_write_buffer_get_server_no_token(
+            char_dev_buf = red_char_device_write_buffer_get_server_no_token(
                                reds->agent_state.base, total_msg_size);
             char_dev_buf->buf_used = total_msg_size;
             internal_buf = (VDInternalBuf *)char_dev_buf->buf;
@@ -518,8 +518,8 @@ void reds_client_disconnect(RedsState *reds, RedClient *client)
             internal_buf->header.opaque = 0;
             internal_buf->header.size = 0;
 
-            spice_char_device_write_buffer_add(reds->agent_state.base,
-                                               char_dev_buf);
+            red_char_device_write_buffer_add(reds->agent_state.base,
+                                             char_dev_buf);
         }
 
         /* Reset write filter to start with clean state on client reconnect */
@@ -696,10 +696,10 @@ static void vdi_port_read_buf_unref(VDIReadBuf *buf)
 
         /* read_one_msg_from_vdi_port may have never completed because the read_bufs
         ring was empty. So we call it again so it can complete its work if
-        necessary. Note that since we can be called from spice_char_device_wakeup
+        necessary. Note that since we can be called from red_char_device_wakeup
         this can cause recursion, but we have protection for that */
         if (buf->state->base) {
-            spice_char_device_wakeup(buf->state->base);
+            red_char_device_wakeup(buf->state->base);
         }
     }
 }
@@ -845,9 +845,9 @@ void reds_handle_agent_mouse_event(RedsState *reds, const VDAgentMouseState *mou
 
     total_msg_size = sizeof(VDIChunkHeader) + sizeof(VDAgentMessage) +
                      sizeof(VDAgentMouseState);
-    char_dev_buf = spice_char_device_write_buffer_get(reds->agent_state.base,
-                                                      NULL,
-                                                      total_msg_size);
+    char_dev_buf = red_char_device_write_buffer_get(reds->agent_state.base,
+                                                    NULL,
+                                                    total_msg_size);
 
     if (!char_dev_buf) {
         reds->pending_mouse_event = TRUE;
@@ -866,7 +866,7 @@ void reds_handle_agent_mouse_event(RedsState *reds, const VDAgentMouseState *mou
     internal_buf->u.mouse_state = *mouse_state;
 
     char_dev_buf->buf_used = total_msg_size;
-    spice_char_device_write_buffer_add(reds->agent_state.base, char_dev_buf);
+    red_char_device_write_buffer_add(reds->agent_state.base, char_dev_buf);
 }
 
 int reds_get_n_channels(RedsState *reds)
@@ -938,16 +938,16 @@ void reds_on_main_agent_start(RedsState *reds, MainChannelClient *mcc, uint32_t
      * and vice versa, the sending from the server to the client won't have
      * flow control, but will have no other problem.
      */
-    if (!spice_char_device_client_exists(dev_state, rcc->client)) {
+    if (!red_char_device_client_exists(dev_state, rcc->client)) {
         int client_added;
 
-        client_added = spice_char_device_client_add(dev_state,
-                                                    rcc->client,
-                                                    TRUE, /* flow control */
-                                                    REDS_VDI_PORT_NUM_RECEIVE_BUFFS,
-                                                    REDS_AGENT_WINDOW_SIZE,
-                                                    num_tokens,
-                                                    red_channel_client_is_waiting_for_migrate_data(rcc));
+        client_added = red_char_device_client_add(dev_state,
+                                                  rcc->client,
+                                                  TRUE, /* flow control */
+                                                  REDS_VDI_PORT_NUM_RECEIVE_BUFFS,
+                                                  REDS_AGENT_WINDOW_SIZE,
+                                                  num_tokens,
+                                                  red_channel_client_is_waiting_for_migrate_data(rcc));
 
         if (!client_added) {
             spice_warning("failed to add client to agent");
@@ -955,9 +955,9 @@ void reds_on_main_agent_start(RedsState *reds, MainChannelClient *mcc, uint32_t
             return;
         }
     } else {
-        spice_char_device_send_to_client_tokens_set(dev_state,
-                                                    rcc->client,
-                                                    num_tokens);
+        red_char_device_send_to_client_tokens_set(dev_state,
+                                                  rcc->client,
+                                                  num_tokens);
     }
 
     agent_msg_filter_config(&reds->agent_state.write_filter, reds->agent_copypaste,
@@ -972,7 +972,7 @@ void reds_on_main_agent_tokens(RedsState *reds, MainChannelClient *mcc, uint32_t
         return;
     }
     spice_assert(reds->vdagent->st);
-    spice_char_device_send_to_client_tokens_add(reds->vdagent->st,
+    red_char_device_send_to_client_tokens_add(reds->vdagent->st,
                                                 main_channel_client_get_base(mcc)->client,
                                                 num_tokens);
 }
@@ -995,9 +995,9 @@ uint8_t *reds_get_agent_data_buffer(RedsState *reds, MainChannelClient *mcc, siz
 
     spice_assert(dev_state->recv_from_client_buf == NULL);
     client = main_channel_client_get_base(mcc)->client;
-    dev_state->recv_from_client_buf = spice_char_device_write_buffer_get(dev_state->base,
-                                                                         client,
-                                                                         size + sizeof(VDIChunkHeader));
+    dev_state->recv_from_client_buf = red_char_device_write_buffer_get(dev_state->base,
+                                                                       client,
+                                                                       size + sizeof(VDIChunkHeader));
     dev_state->recv_from_client_buf_pushed = FALSE;
     return dev_state->recv_from_client_buf->buf + sizeof(VDIChunkHeader);
 }
@@ -1013,8 +1013,8 @@ void reds_release_agent_data_buffer(RedsState *reds, uint8_t *buf)
 
     spice_assert(buf == dev_state->recv_from_client_buf->buf + sizeof(VDIChunkHeader));
     if (!dev_state->recv_from_client_buf_pushed) {
-        spice_char_device_write_buffer_release(reds->agent_state.base,
-                                               dev_state->recv_from_client_buf);
+        red_char_device_write_buffer_release(reds->agent_state.base,
+                                             dev_state->recv_from_client_buf);
     }
     dev_state->recv_from_client_buf = NULL;
     dev_state->recv_from_client_buf_pushed = FALSE;
@@ -1085,7 +1085,7 @@ void reds_on_main_agent_data(RedsState *reds, MainChannelClient *mcc, void *mess
     dev_state->recv_from_client_buf->buf_used = sizeof(VDIChunkHeader) + size;
 
     dev_state->recv_from_client_buf_pushed = TRUE;
-    spice_char_device_write_buffer_add(reds->agent_state.base, dev_state->recv_from_client_buf);
+    red_char_device_write_buffer_add(reds->agent_state.base, dev_state->recv_from_client_buf);
 }
 
 void reds_on_main_migrate_connected(RedsState *reds, int seamless)
@@ -1180,7 +1180,7 @@ void reds_marshall_migrate_data(RedsState *reds, SpiceMarshaller *m)
                                              is destroyed when the agent is disconnected and
                                              there is no need to track the client tokens
                                              (see reds_reset_vdp) */
-        spice_char_device_state_migrate_data_marshall_empty(m);
+        red_char_device_migrate_data_marshall_empty(m);
         null_agent_mig_data = spice_marshaller_reserve_space(m,
                                                              sizeof(SpiceMigrateDataMain) -
                                                              sizeof(SpiceMigrateDataCharDevice));
@@ -1190,7 +1190,7 @@ void reds_marshall_migrate_data(RedsState *reds, SpiceMarshaller *m)
         return;
     }
 
-    spice_char_device_state_migrate_data_marshall(reds->agent_state.base, m);
+    red_char_device_migrate_data_marshall(reds->agent_state.base, m);
     spice_marshaller_add_uint8(m, reds->agent_state.client_agent_started);
 
     mig_data.agent2client.chunk_header = agent_state->vdi_chunk_header;
@@ -1310,7 +1310,7 @@ static int reds_agent_state_restore(RedsState *reds, SpiceMigrateDataMain *mig_d
                 agent_state->read_filter.discard_all,
                 agent_state->read_filter.msg_data_to_read,
                  agent_state->read_filter.result);
-    return spice_char_device_state_restore(agent_state->base, &mig_data->agent_base);
+    return red_char_device_restore(agent_state->base, &mig_data->agent_base);
 }
 
 /*
@@ -1340,7 +1340,7 @@ int reds_handle_migrate_data(RedsState *reds, MainChannelClient *mcc,
                 spice_debug("agent is no longer connected");
             } else {
                 if (agent_state->plug_generation > 1) {
-                    /* spice_char_device_state_reset takes care of not making the device wait for migration data */
+                    /* red_char_device_reset takes care of not making the device wait for migration data */
                     spice_debug("agent has been detached and reattached before receiving migration data");
                     main_channel_push_agent_disconnected(reds->main_channel);
                     main_channel_push_agent_connected(reds->main_channel);
@@ -1358,9 +1358,9 @@ int reds_handle_migrate_data(RedsState *reds, MainChannelClient *mcc,
     } else {
         spice_debug("agent was not attached on the source host");
         if (reds->vdagent) {
-            /* spice_char_device_client_remove disables waiting for migration data */
-            spice_char_device_client_remove(agent_state->base,
-                                            main_channel_client_get_base(mcc)->client);
+            /* red_char_device_client_remove disables waiting for migration data */
+            red_char_device_client_remove(agent_state->base,
+                                          main_channel_client_get_base(mcc)->client);
             main_channel_push_agent_connected(reds->main_channel);
         }
     }
@@ -2983,14 +2983,14 @@ static RedCharDevice *attach_to_red_agent(RedsState *reds, SpiceCharDeviceInstan
         char_dev_state_cbs.remove_client = vdi_port_remove_client;
         char_dev_state_cbs.on_free_self_token = vdi_port_on_free_self_token;
 
-        state->base = spice_char_device_state_create(sin,
-                                                     reds,
-                                                     REDS_TOKENS_TO_SEND,
-                                                     REDS_NUM_INTERNAL_AGENT_MESSAGES,
-                                                     &char_dev_state_cbs,
-                                                     reds);
+        state->base = red_char_device_create(sin,
+                                             reds,
+                                             REDS_TOKENS_TO_SEND,
+                                             REDS_NUM_INTERNAL_AGENT_MESSAGES,
+                                             &char_dev_state_cbs,
+                                             reds);
     } else {
-        spice_char_device_state_reset_dev_instance(state->base, sin);
+        red_char_device_reset_dev_instance(state->base, sin);
     }
 
     reds->vdagent = sin;
@@ -3017,16 +3017,16 @@ static RedCharDevice *attach_to_red_agent(RedsState *reds, SpiceCharDeviceInstan
          * 2.b If this happens second ==> we already have spice migrate data
          *     then restore state
          */
-        if (!spice_char_device_client_exists(reds->agent_state.base, reds_get_client(reds))) {
+        if (!red_char_device_client_exists(reds->agent_state.base, reds_get_client(reds))) {
             int client_added;
 
-            client_added = spice_char_device_client_add(reds->agent_state.base,
-                                                        reds_get_client(reds),
-                                                        TRUE, /* flow control */
-                                                        REDS_VDI_PORT_NUM_RECEIVE_BUFFS,
-                                                        REDS_AGENT_WINDOW_SIZE,
-                                                        ~0,
-                                                        TRUE);
+            client_added = red_char_device_client_add(reds->agent_state.base,
+                                                      reds_get_client(reds),
+                                                      TRUE, /* flow control */
+                                                      REDS_VDI_PORT_NUM_RECEIVE_BUFFS,
+                                                      REDS_AGENT_WINDOW_SIZE,
+                                                      ~0,
+                                                      TRUE);
 
             if (!client_added) {
                 spice_warning("failed to add client to agent");
@@ -3059,7 +3059,7 @@ SPICE_GNUC_VISIBLE void spice_server_char_device_wakeup(SpiceCharDeviceInstance*
         spice_warning("no RedCharDevice attached to instance %p", sin);
         return;
     }
-    spice_char_device_wakeup(sin->st);
+    red_char_device_wakeup(sin->st);
 }
 
 #define SUBTYPE_VDAGENT "vdagent"
@@ -3135,7 +3135,7 @@ static int spice_server_char_device_add_interface(SpiceServer *reds,
         /* setting the char_device state to "started" for backward compatibily with
          * qemu releases that don't call spice api for start/stop (not implemented yet) */
         if (reds->vm_running) {
-            spice_char_device_start(char_device->st);
+            red_char_device_start(char_device->st);
         }
         reds_add_char_device(reds, char_device->st);
     } else {
@@ -3297,7 +3297,7 @@ SPICE_GNUC_VISIBLE int spice_server_remove_interface(SpiceBaseInstance *sin)
         snd_detach_record(SPICE_CONTAINEROF(sin, SpiceRecordInstance, base));
     } else if (strcmp(interface->type, SPICE_INTERFACE_CHAR_DEVICE) == 0) {
         SpiceCharDeviceInstance *char_device = SPICE_CONTAINEROF(sin, SpiceCharDeviceInstance, base);
-        reds = spice_char_device_get_server(char_device->st);
+        reds = red_char_device_get_server(char_device->st);
         spice_server_char_device_remove_interface(reds, sin);
     } else {
         spice_warning("VD_INTERFACE_REMOVING unsupported");
@@ -3976,7 +3976,7 @@ SPICE_GNUC_VISIBLE void spice_server_vm_start(SpiceServer *reds)
 
     reds->vm_running = TRUE;
     for (it = reds->char_devices; it != NULL; it = it->next) {
-        spice_char_device_start(it->data);
+        red_char_device_start(it->data);
     }
     reds_on_vm_start(reds);
 }
@@ -3987,7 +3987,7 @@ SPICE_GNUC_VISIBLE void spice_server_vm_stop(SpiceServer *reds)
 
     reds->vm_running = FALSE;
     for (it = reds->char_devices; it != NULL; it = it->next) {
-        spice_char_device_stop(it->data);
+        red_char_device_stop(it->data);
     }
     reds_on_vm_stop(reds);
 }
diff --git a/server/smartcard.c b/server/smartcard.c
index 6e32f31..b3261d8 100644
--- a/server/smartcard.c
+++ b/server/smartcard.c
@@ -240,7 +240,7 @@ MsgItem *smartcard_char_device_on_message_from_device(SmartCardDeviceState *stat
 
 static int smartcard_char_device_add_to_readers(RedsState *reds, SpiceCharDeviceInstance *char_device)
 {
-    SmartCardDeviceState *state = spice_char_device_state_opaque_get(char_device->st);
+    SmartCardDeviceState *state = red_char_device_opaque_get(char_device->st);
 
     if (g_smartcard_readers.num >= SMARTCARD_MAX_READERS) {
         return -1;
@@ -265,7 +265,7 @@ static SpiceCharDeviceInstance *smartcard_readers_get_unattached(void)
     SmartCardDeviceState* state;
 
     for (i = 0; i < g_smartcard_readers.num; ++i) {
-        state = spice_char_device_state_opaque_get(g_smartcard_readers.sin[i]->st);
+        state = red_char_device_opaque_get(g_smartcard_readers.sin[i]->st);
         if (!state->priv->scc) {
             return g_smartcard_readers.sin[i];
         }
@@ -286,12 +286,12 @@ static SmartCardDeviceState *smartcard_device_state_new(RedsState *reds, SpiceCh
     chardev_cbs.remove_client = smartcard_remove_client;
 
     st = spice_new0(SmartCardDeviceState, 1);
-    st->priv->chardev = spice_char_device_state_create(sin,
-                                                       reds,
-                                                       0, /* tokens interval */
-                                                       ~0, /* self tokens */
-                                                       &chardev_cbs,
-                                                       st);
+    st->priv->chardev = red_char_device_create(sin,
+                                               reds,
+                                               0, /* tokens interval */
+                                               ~0, /* self tokens */
+                                               &chardev_cbs,
+                                               st);
     st->priv->reader_id = VSCARD_UNDEFINED_READER_ID;
     st->priv->reader_added = FALSE;
     st->priv->buf_size = APDUBufSize + sizeof(VSCMsgHeader);
@@ -308,13 +308,13 @@ static void smartcard_device_state_free(SmartCardDeviceState* st)
         st->priv->scc->smartcard_state = NULL;
     }
     free(st->priv->buf);
-    spice_char_device_state_destroy(st->priv->chardev);
+    red_char_device_destroy(st->priv->chardev);
     free(st);
 }
 
 void smartcard_device_disconnect(SpiceCharDeviceInstance *char_device)
 {
-    SmartCardDeviceState *st = spice_char_device_state_opaque_get(char_device->st);
+    SmartCardDeviceState *st = red_char_device_opaque_get(char_device->st);
 
     smartcard_device_state_free(st);
 }
@@ -336,7 +336,7 @@ static void smartcard_char_device_notify_reader_add(SmartCardDeviceState *st)
     RedCharDeviceWriteBuffer *write_buf;
     VSCMsgHeader *vheader;
 
-    write_buf = spice_char_device_write_buffer_get(st->priv->chardev, NULL, sizeof(vheader));
+    write_buf = red_char_device_write_buffer_get(st->priv->chardev, NULL, sizeof(vheader));
     if (!write_buf) {
         spice_error("failed to allocate write buffer");
         return;
@@ -352,20 +352,20 @@ static void smartcard_char_device_notify_reader_add(SmartCardDeviceState *st)
 static void smartcard_char_device_attach_client(SpiceCharDeviceInstance *char_device,
                                                 SmartCardChannelClient *scc)
 {
-    SmartCardDeviceState *st = spice_char_device_state_opaque_get(char_device->st);
+    SmartCardDeviceState *st = red_char_device_opaque_get(char_device->st);
     int client_added;
 
     spice_assert(!scc->smartcard_state && !st->priv->scc);
     st->priv->scc = scc;
     scc->smartcard_state = st;
-    client_added = spice_char_device_client_add(st->priv->chardev,
-                                                scc->base.client,
-                                                FALSE, /* no flow control yet */
-                                                0, /* send queue size */
-                                                ~0,
-                                                ~0,
-                                                red_channel_client_is_waiting_for_migrate_data(
-                                                    &scc->base));
+    client_added = red_char_device_client_add(st->priv->chardev,
+                                              scc->base.client,
+                                              FALSE, /* no flow control yet */
+                                              0, /* send queue size */
+                                              ~0,
+                                              ~0,
+                                              red_channel_client_is_waiting_for_migrate_data(
+                                                  &scc->base));
     if (!client_added) {
         spice_warning("failed");
         st->priv->scc = NULL;
@@ -383,7 +383,7 @@ static void smartcard_char_device_notify_reader_remove(SmartCardDeviceState *st)
         spice_debug("reader add was never sent to the device");
         return;
     }
-    write_buf = spice_char_device_write_buffer_get(st->priv->chardev, NULL, sizeof(vheader));
+    write_buf = red_char_device_write_buffer_get(st->priv->chardev, NULL, sizeof(vheader));
     if (!write_buf) {
         spice_error("failed to allocate write buffer");
         return;
@@ -405,7 +405,7 @@ static void smartcard_char_device_detach_client(SmartCardChannelClient *scc)
     }
     st = scc->smartcard_state;
     spice_assert(st->priv->scc == scc);
-    spice_char_device_client_remove(st->priv->chardev, scc->base.client);
+    red_char_device_client_remove(st->priv->chardev, scc->base.client);
     scc->smartcard_state = NULL;
     st->priv->scc = NULL;
 }
@@ -434,7 +434,7 @@ static uint8_t *smartcard_channel_alloc_msg_rcv_buf(RedChannelClient *rcc,
         st = scc->smartcard_state;
         spice_assert(st->priv->scc || scc->smartcard_state);
         spice_assert(!scc->write_buf);
-        scc->write_buf = spice_char_device_write_buffer_get(st->priv->chardev, rcc->client, size);
+        scc->write_buf = red_char_device_write_buffer_get(st->priv->chardev, rcc->client, size);
 
         if (!scc->write_buf) {
             spice_error("failed to allocate write buffer");
@@ -464,7 +464,7 @@ static void smartcard_channel_release_msg_rcv_buf(RedChannelClient *rcc,
         if (scc->write_buf) { /* msg hasn't been pushed to the guest */
             spice_assert(scc->write_buf->buf == msg);
             dev = scc->smartcard_state ? scc->smartcard_state->priv->chardev : NULL;
-            spice_char_device_write_buffer_release(dev, scc->write_buf);
+            red_char_device_write_buffer_release(dev, scc->write_buf);
             scc->write_buf = NULL;
         }
     }
@@ -512,13 +512,13 @@ static void smartcard_channel_send_migrate_data(RedChannelClient *rcc,
     spice_marshaller_add_uint32(m, SPICE_MIGRATE_DATA_SMARTCARD_VERSION);
 
     if (!state) {
-        spice_char_device_state_migrate_data_marshall_empty(m);
+        red_char_device_migrate_data_marshall_empty(m);
         spice_marshaller_add_uint8(m, 0);
         spice_marshaller_add_uint32(m, 0);
         spice_marshaller_add_uint32(m, 0);
         spice_debug("null char dev state");
     } else {
-        spice_char_device_state_migrate_data_marshall(state->priv->chardev, m);
+        red_char_device_migrate_data_marshall(state->priv->chardev, m);
         spice_marshaller_add_uint8(m, state->priv->reader_added);
         spice_marshaller_add_uint32(m, state->priv->buf_used);
         m2 = spice_marshaller_get_ptr_submarshaller(m, 0);
@@ -628,7 +628,7 @@ static void smartcard_remove_reader(SmartCardChannelClient *scc, uint32_t reader
         return;
     }
 
-    state = spice_char_device_state_opaque_get(char_device->st);
+    state = red_char_device_opaque_get(char_device->st);
     if (state->priv->reader_added == FALSE) {
         smartcard_push_error(&scc->base, reader_id,
             VSC_GENERAL_ERROR);
@@ -669,7 +669,7 @@ static void smartcard_channel_write_to_reader(RedCharDeviceWriteBuffer *write_bu
 
     spice_assert(vheader->reader_id <= g_smartcard_readers.num);
     sin = g_smartcard_readers.sin[vheader->reader_id];
-    st = (SmartCardDeviceState *)spice_char_device_state_opaque_get(sin->st);
+    st = (SmartCardDeviceState *)red_char_device_opaque_get(sin->st);
     spice_assert(!st->priv->scc || st == st->priv->scc->smartcard_state);
     /* protocol requires messages to be in network endianess */
     vheader->type = htonl(vheader->type);
@@ -678,7 +678,7 @@ static void smartcard_channel_write_to_reader(RedCharDeviceWriteBuffer *write_bu
     write_buf->buf_used = actual_length + sizeof(VSCMsgHeader);
     /* pushing the buffer to the write queue; It will be released
      * when it will be fully consumed by the device */
-    spice_char_device_write_buffer_add(sin->st, write_buf);
+    red_char_device_write_buffer_add(sin->st, write_buf);
     if (st->priv->scc && write_buf == st->priv->scc->write_buf) {
         st->priv->scc->write_buf = NULL;
     }
@@ -746,7 +746,7 @@ static int smartcard_channel_client_handle_migrate_data(RedChannelClient *rcc,
     scc->smartcard_state->priv->reader_added = mig_data->reader_added;
 
     smartcard_device_state_restore_partial_read(scc->smartcard_state, mig_data);
-    return spice_char_device_state_restore(scc->smartcard_state->priv->chardev, &mig_data->base);
+    return red_char_device_restore(scc->smartcard_state->priv->chardev, &mig_data->base);
 }
 
 static int smartcard_channel_handle_message(RedChannelClient *rcc,
diff --git a/server/spicevmc.c b/server/spicevmc.c
index 36c5daf..d1e8222 100644
--- a/server/spicevmc.c
+++ b/server/spicevmc.c
@@ -220,13 +220,13 @@ static void spicevmc_red_channel_client_on_disconnect(RedChannelClient *rcc)
     state = SPICE_CONTAINEROF(rcc->channel, SpiceVmcState, channel);
 
     if (state->recv_from_client_buf) { /* partial message which wasn't pushed to device */
-        spice_char_device_write_buffer_release(state->chardev, state->recv_from_client_buf);
+        red_char_device_write_buffer_release(state->chardev, state->recv_from_client_buf);
         state->recv_from_client_buf = NULL;
     }
 
     if (state->chardev) {
-        if (spice_char_device_client_exists(state->chardev, rcc->client)) {
-            spice_char_device_client_remove(state->chardev, rcc->client);
+        if (red_char_device_client_exists(state->chardev, rcc->client)) {
+            red_char_device_client_remove(state->chardev, rcc->client);
         } else {
             spice_printerr("client %p have already been removed from char dev %p",
                            rcc->client, state->chardev);
@@ -275,7 +275,7 @@ static int spicevmc_channel_client_handle_migrate_data(RedChannelClient *rcc,
         spice_error("bad header");
         return FALSE;
     }
-    return spice_char_device_state_restore(state->chardev, &mig_data->base);
+    return red_char_device_restore(state->chardev, &mig_data->base);
 }
 
 static int spicevmc_red_channel_client_handle_message(RedChannelClient *rcc,
@@ -293,7 +293,7 @@ static int spicevmc_red_channel_client_handle_message(RedChannelClient *rcc,
     case SPICE_MSGC_SPICEVMC_DATA:
         spice_assert(state->recv_from_client_buf->buf == msg);
         state->recv_from_client_buf->buf_used = size;
-        spice_char_device_write_buffer_add(state->chardev, state->recv_from_client_buf);
+        red_char_device_write_buffer_add(state->chardev, state->recv_from_client_buf);
         state->recv_from_client_buf = NULL;
         break;
     case SPICE_MSGC_PORT_EVENT:
@@ -323,9 +323,9 @@ static uint8_t *spicevmc_red_channel_alloc_msg_rcv_buf(RedChannelClient *rcc,
     case SPICE_MSGC_SPICEVMC_DATA:
         assert(!state->recv_from_client_buf);
 
-        state->recv_from_client_buf = spice_char_device_write_buffer_get(state->chardev,
-                                                                         rcc->client,
-                                                                         size);
+        state->recv_from_client_buf = red_char_device_write_buffer_get(state->chardev,
+                                                                       rcc->client,
+                                                                       size);
         if (!state->recv_from_client_buf) {
             spice_error("failed to allocate write buffer");
             return NULL;
@@ -350,7 +350,7 @@ static void spicevmc_red_channel_release_msg_rcv_buf(RedChannelClient *rcc,
     switch (type) {
     case SPICE_MSGC_SPICEVMC_DATA:
         if (state->recv_from_client_buf) { /* buffer wasn't pushed to device */
-            spice_char_device_write_buffer_release(state->chardev, state->recv_from_client_buf);
+            red_char_device_write_buffer_release(state->chardev, state->recv_from_client_buf);
             state->recv_from_client_buf = NULL;
         }
         break;
@@ -386,7 +386,7 @@ static void spicevmc_red_channel_send_migrate_data(RedChannelClient *rcc,
     spice_marshaller_add_uint32(m, SPICE_MIGRATE_DATA_SPICEVMC_MAGIC);
     spice_marshaller_add_uint32(m, SPICE_MIGRATE_DATA_SPICEVMC_VERSION);
 
-    spice_char_device_state_migrate_data_marshall(state->chardev, m);
+    red_char_device_migrate_data_marshall(state->chardev, m);
 }
 
 static void spicevmc_red_channel_send_port_init(RedChannelClient *rcc,
@@ -486,8 +486,8 @@ static void spicevmc_connect(RedChannel *channel, RedClient *client,
         spicevmc_port_send_init(rcc);
     }
 
-    if (!spice_char_device_client_add(state->chardev, client, FALSE, 0, ~0, ~0,
-                                      red_channel_client_is_waiting_for_migrate_data(rcc))) {
+    if (!red_char_device_client_add(state->chardev, client, FALSE, 0, ~0, ~0,
+                                    red_channel_client_is_waiting_for_migrate_data(rcc))) {
         spice_warning("failed to add client to spicevmc");
         red_channel_client_disconnect(rcc);
         return;
@@ -537,12 +537,12 @@ RedCharDevice *spicevmc_device_connect(RedsState *reds,
     char_dev_cbs.send_tokens_to_client = spicevmc_char_dev_send_tokens_to_client;
     char_dev_cbs.remove_client = spicevmc_char_dev_remove_client;
 
-    state->chardev = spice_char_device_state_create(sin,
-                                                    reds,
-                                                    0, /* tokens interval */
-                                                    ~0, /* self tokens */
-                                                    &char_dev_cbs,
-                                                    state);
+    state->chardev = red_char_device_create(sin,
+                                            reds,
+                                            0, /* tokens interval */
+                                            ~0, /* self tokens */
+                                            &char_dev_cbs,
+                                            state);
     state->chardev_sin = sin;
 
     reds_register_channel(reds, &state->channel);
@@ -555,13 +555,13 @@ void spicevmc_device_disconnect(RedsState *reds, SpiceCharDeviceInstance *sin)
     SpiceVmcState *state;
 
     /* FIXME */
-    state = (SpiceVmcState *)spice_char_device_state_opaque_get((RedCharDevice*)sin->st);
+    state = (SpiceVmcState *)red_char_device_opaque_get((RedCharDevice*)sin->st);
 
     if (state->recv_from_client_buf) {
-        spice_char_device_write_buffer_release(state->chardev, state->recv_from_client_buf);
+        red_char_device_write_buffer_release(state->chardev, state->recv_from_client_buf);
     }
     /* FIXME */
-    spice_char_device_state_destroy((RedCharDevice*)sin->st);
+    red_char_device_destroy((RedCharDevice*)sin->st);
     state->chardev = NULL;
     sin->st = NULL;
 
@@ -580,7 +580,7 @@ SPICE_GNUC_VISIBLE void spice_server_port_event(SpiceCharDeviceInstance *sin, ui
     }
 
     /* FIXME */
-    state = (SpiceVmcState *)spice_char_device_state_opaque_get((RedCharDevice*)sin->st);
+    state = (SpiceVmcState *)red_char_device_opaque_get((RedCharDevice*)sin->st);
     if (event == SPICE_PORT_EVENT_OPENED) {
         state->port_opened = TRUE;
     } else if (event == SPICE_PORT_EVENT_CLOSED) {
commit 0fd5b56be795a8b89c125e89721b4363ef7067e6
Author: Jonathon Jongsma <jjongsma at redhat.com>
Date:   Thu Mar 31 16:07:02 2016 -0500

    Rename SpiceCharDeviceClientState to RedCharDeviceClient
    
    Make it consistent with the renamed RedCharDevice and the convention of
    using 'Red' namespaces for internal types
    
    Acked-by: Frediano Ziglio <fziglio at redhat.com>

diff --git a/server/char-device.c b/server/char-device.c
index 5b1cc4e..d5f203f 100644
--- a/server/char-device.c
+++ b/server/char-device.c
@@ -30,8 +30,8 @@
 #define SPICE_CHAR_DEVICE_WAIT_TOKENS_TIMEOUT 30000
 #define MAX_POOL_SIZE (10 * 64 * 1024)
 
-typedef struct SpiceCharDeviceClientState SpiceCharDeviceClientState;
-struct SpiceCharDeviceClientState {
+typedef struct RedCharDeviceClient RedCharDeviceClient;
+struct RedCharDeviceClient {
     RingItem link;
     RedCharDevice *dev;
     RedClient *client;
@@ -60,7 +60,7 @@ struct RedCharDevicePrivate {
     SpiceTimer *write_to_dev_timer;
     uint64_t num_self_tokens;
 
-    Ring clients; /* list of SpiceCharDeviceClientState */
+    Ring clients; /* list of RedCharDeviceClient */
     uint32_t num_clients;
 
     uint64_t client_tokens_interval; /* frequency of returning tokens to the client */
@@ -188,7 +188,7 @@ static void spice_char_device_write_buffer_pool_add(RedCharDevice *dev,
 }
 
 static void spice_char_device_client_send_queue_free(RedCharDevice *dev,
-                                                     SpiceCharDeviceClientState *dev_client)
+                                                     RedCharDeviceClient *dev_client)
 {
     spice_debug("send_queue_empty %d", ring_is_empty(&dev_client->send_queue));
     while (!ring_is_empty(&dev_client->send_queue)) {
@@ -206,7 +206,7 @@ static void spice_char_device_client_send_queue_free(RedCharDevice *dev,
 }
 
 static void spice_char_device_client_free(RedCharDevice *dev,
-                                          SpiceCharDeviceClientState *dev_client)
+                                          RedCharDeviceClient *dev_client)
 {
     RingItem *item, *next;
 
@@ -241,22 +241,22 @@ static void spice_char_device_client_free(RedCharDevice *dev,
     free(dev_client);
 }
 
-static void spice_char_device_handle_client_overflow(SpiceCharDeviceClientState *dev_client)
+static void spice_char_device_handle_client_overflow(RedCharDeviceClient *dev_client)
 {
     RedCharDevice *dev = dev_client->dev;
     spice_printerr("dev %p client %p ", dev, dev_client);
     spice_char_device_remove_client(dev, dev_client->client);
 }
 
-static SpiceCharDeviceClientState *spice_char_device_client_find(RedCharDevice *dev,
-                                                                 RedClient *client)
+static RedCharDeviceClient *spice_char_device_client_find(RedCharDevice *dev,
+                                                          RedClient *client)
 {
     RingItem *item;
 
     RING_FOREACH(item, &dev->priv->clients) {
-        SpiceCharDeviceClientState *dev_client;
+        RedCharDeviceClient *dev_client;
 
-        dev_client = SPICE_CONTAINEROF(item, SpiceCharDeviceClientState, link);
+        dev_client = SPICE_CONTAINEROF(item, RedCharDeviceClient, link);
         if (dev_client->client == client) {
             return dev_client;
         }
@@ -270,12 +270,12 @@ static SpiceCharDeviceClientState *spice_char_device_client_find(RedCharDevice *
 
 static void device_client_wait_for_tokens_timeout(void *opaque)
 {
-    SpiceCharDeviceClientState *dev_client = opaque;
+    RedCharDeviceClient *dev_client = opaque;
 
     spice_char_device_handle_client_overflow(dev_client);
 }
 
-static int spice_char_device_can_send_to_client(SpiceCharDeviceClientState *dev_client)
+static int spice_char_device_can_send_to_client(RedCharDeviceClient *dev_client)
 {
     return !dev_client->do_flow_control || dev_client->num_send_tokens;
 }
@@ -286,9 +286,9 @@ static uint64_t spice_char_device_max_send_tokens(RedCharDevice *dev)
     uint64_t max = 0;
 
     RING_FOREACH(item, &dev->priv->clients) {
-        SpiceCharDeviceClientState *dev_client;
+        RedCharDeviceClient *dev_client;
 
-        dev_client = SPICE_CONTAINEROF(item, SpiceCharDeviceClientState, link);
+        dev_client = SPICE_CONTAINEROF(item, RedCharDeviceClient, link);
 
         if (!dev_client->do_flow_control) {
             max = ~0;
@@ -302,7 +302,7 @@ static uint64_t spice_char_device_max_send_tokens(RedCharDevice *dev)
     return max;
 }
 
-static void spice_char_device_add_msg_to_client_queue(SpiceCharDeviceClientState *dev_client,
+static void spice_char_device_add_msg_to_client_queue(RedCharDeviceClient *dev_client,
                                                       RedCharDeviceMsgToClient *msg)
 {
     RedCharDevice *dev = dev_client->dev;
@@ -330,9 +330,9 @@ static void spice_char_device_send_msg_to_clients(RedCharDevice *dev,
     RingItem *item, *next;
 
     RING_FOREACH_SAFE(item, next, &dev->priv->clients) {
-        SpiceCharDeviceClientState *dev_client;
+        RedCharDeviceClient *dev_client;
 
-        dev_client = SPICE_CONTAINEROF(item, SpiceCharDeviceClientState, link);
+        dev_client = SPICE_CONTAINEROF(item, RedCharDeviceClient, link);
         if (spice_char_device_can_send_to_client(dev_client)) {
             dev_client->num_send_tokens--;
             spice_assert(ring_is_empty(&dev_client->send_queue));
@@ -395,7 +395,7 @@ static int spice_char_device_read_from_device(RedCharDevice *dev)
     return did_read;
 }
 
-static void spice_char_device_client_send_queue_push(SpiceCharDeviceClientState *dev_client)
+static void spice_char_device_client_send_queue_push(RedCharDeviceClient *dev_client)
 {
     RingItem *item;
     while ((item = ring_get_tail(&dev_client->send_queue)) &&
@@ -415,7 +415,7 @@ static void spice_char_device_client_send_queue_push(SpiceCharDeviceClientState
     }
 }
 
-static void spice_char_device_send_to_client_tokens_absorb(SpiceCharDeviceClientState *dev_client,
+static void spice_char_device_send_to_client_tokens_absorb(RedCharDeviceClient *dev_client,
                                                            uint32_t tokens)
 {
     RedCharDevice *dev = dev_client->dev;
@@ -441,7 +441,7 @@ void spice_char_device_send_to_client_tokens_add(RedCharDevice *dev,
                                                  RedClient *client,
                                                  uint32_t tokens)
 {
-    SpiceCharDeviceClientState *dev_client;
+    RedCharDeviceClient *dev_client;
 
     dev_client = spice_char_device_client_find(dev, client);
 
@@ -456,7 +456,7 @@ void spice_char_device_send_to_client_tokens_set(RedCharDevice *dev,
                                                  RedClient *client,
                                                  uint32_t tokens)
 {
-    SpiceCharDeviceClientState *dev_client;
+    RedCharDeviceClient *dev_client;
 
     dev_client = spice_char_device_client_find(dev, client);
 
@@ -474,7 +474,7 @@ void spice_char_device_send_to_client_tokens_set(RedCharDevice *dev,
 ***************************/
 
 static void spice_char_device_client_tokens_add(RedCharDevice *dev,
-                                                SpiceCharDeviceClientState *dev_client,
+                                                RedCharDeviceClient *dev_client,
                                                 uint32_t num_tokens)
 {
     if (!dev_client->do_flow_control) {
@@ -605,7 +605,7 @@ static RedCharDeviceWriteBuffer *__spice_char_device_write_buffer_get(
 
     if (origin == WRITE_BUFFER_ORIGIN_CLIENT) {
        spice_assert(client);
-       SpiceCharDeviceClientState *dev_client = spice_char_device_client_find(dev, client);
+       RedCharDeviceClient *dev_client = spice_char_device_client_find(dev, client);
        if (dev_client) {
             if (!migrated_data_tokens &&
                 dev_client->do_flow_control && !dev_client->num_client_tokens) {
@@ -703,7 +703,7 @@ void spice_char_device_write_buffer_release(RedCharDevice *dev,
 
     spice_char_device_write_buffer_pool_add(dev, write_buf);
     if (buf_origin == WRITE_BUFFER_ORIGIN_CLIENT) {
-        SpiceCharDeviceClientState *dev_client;
+        RedCharDeviceClient *dev_client;
 
         spice_assert(client);
         dev_client = spice_char_device_client_find(dev, client);
@@ -809,9 +809,9 @@ void spice_char_device_state_destroy(RedCharDevice *char_dev)
 
     while (!ring_is_empty(&char_dev->priv->clients)) {
         RingItem *item = ring_get_tail(&char_dev->priv->clients);
-        SpiceCharDeviceClientState *dev_client;
+        RedCharDeviceClient *dev_client;
 
-        dev_client = SPICE_CONTAINEROF(item, SpiceCharDeviceClientState, link);
+        dev_client = SPICE_CONTAINEROF(item, RedCharDeviceClient, link);
         spice_char_device_client_free(char_dev, dev_client);
     }
     char_dev->priv->running = FALSE;
@@ -819,15 +819,15 @@ void spice_char_device_state_destroy(RedCharDevice *char_dev)
     spice_char_device_state_unref(char_dev);
 }
 
-static SpiceCharDeviceClientState *red_char_device_client_new(RedClient *client,
-                                                              int do_flow_control,
-                                                              uint32_t max_send_queue_size,
-                                                              uint32_t num_client_tokens,
-                                                              uint32_t num_send_tokens)
+static RedCharDeviceClient *red_char_device_client_new(RedClient *client,
+                                                       int do_flow_control,
+                                                       uint32_t max_send_queue_size,
+                                                       uint32_t num_client_tokens,
+                                                       uint32_t num_send_tokens)
 {
-    SpiceCharDeviceClientState *dev_client;
+    RedCharDeviceClient *dev_client;
 
-    dev_client = spice_new0(SpiceCharDeviceClientState, 1);
+    dev_client = spice_new0(RedCharDeviceClient, 1);
     dev_client->client = client;
     ring_init(&dev_client->send_queue);
     dev_client->send_queue_size = 0;
@@ -858,7 +858,7 @@ int spice_char_device_client_add(RedCharDevice *dev,
                                  uint32_t num_send_tokens,
                                  int wait_for_migrate_data)
 {
-    SpiceCharDeviceClientState *dev_client;
+    RedCharDeviceClient *dev_client;
 
     spice_assert(dev);
     spice_assert(client);
@@ -887,7 +887,7 @@ int spice_char_device_client_add(RedCharDevice *dev,
 void spice_char_device_client_remove(RedCharDevice *dev,
                                      RedClient *client)
 {
-    SpiceCharDeviceClientState *dev_client;
+    RedCharDeviceClient *dev_client;
 
     spice_debug("dev_state %p client %p", dev, client);
     dev_client = spice_char_device_client_find(dev, client);
@@ -960,9 +960,9 @@ void spice_char_device_reset(RedCharDevice *dev)
     }
 
     RING_FOREACH(client_item, &dev->priv->clients) {
-        SpiceCharDeviceClientState *dev_client;
+        RedCharDeviceClient *dev_client;
 
-        dev_client = SPICE_CONTAINEROF(client_item, SpiceCharDeviceClientState, link);
+        dev_client = SPICE_CONTAINEROF(client_item, RedCharDeviceClient, link);
         spice_char_device_client_send_queue_free(dev, dev_client);
     }
     dev->priv->sin = NULL;
@@ -1000,7 +1000,7 @@ static void migrate_data_marshaller_write_buffer_free(uint8_t *data, void *opaqu
 void spice_char_device_state_migrate_data_marshall(RedCharDevice *dev,
                                                    SpiceMarshaller *m)
 {
-    SpiceCharDeviceClientState *client_state;
+    RedCharDeviceClient *dev_client;
     RingItem *item;
     uint32_t *write_to_dev_size_ptr;
     uint32_t *write_to_dev_tokens_ptr;
@@ -1008,17 +1008,17 @@ void spice_char_device_state_migrate_data_marshall(RedCharDevice *dev,
 
     /* multi-clients are not supported */
     spice_assert(dev->priv->num_clients == 1);
-    client_state = SPICE_CONTAINEROF(ring_get_tail(&dev->priv->clients),
-                                     SpiceCharDeviceClientState,
-                                     link);
+    dev_client = SPICE_CONTAINEROF(ring_get_tail(&dev->priv->clients),
+                                   RedCharDeviceClient,
+                                   link);
     /* FIXME: if there were more than one client before the marshalling,
      * it is possible that the send_queue_size > 0, and the send data
      * should be migrated as well */
-    spice_assert(client_state->send_queue_size == 0);
+    spice_assert(dev_client->send_queue_size == 0);
     spice_marshaller_add_uint32(m, SPICE_MIGRATE_DATA_CHAR_DEVICE_VERSION);
     spice_marshaller_add_uint8(m, 1); /* connected */
-    spice_marshaller_add_uint32(m, client_state->num_client_tokens);
-    spice_marshaller_add_uint32(m, client_state->num_send_tokens);
+    spice_marshaller_add_uint32(m, dev_client->num_client_tokens);
+    spice_marshaller_add_uint32(m, dev_client->num_send_tokens);
     write_to_dev_size_ptr = (uint32_t *)spice_marshaller_reserve_space(m, sizeof(uint32_t));
     write_to_dev_tokens_ptr = (uint32_t *)spice_marshaller_reserve_space(m, sizeof(uint32_t));
     *write_to_dev_size_ptr = 0;
@@ -1034,7 +1034,7 @@ void spice_char_device_state_migrate_data_marshall(RedCharDevice *dev,
                                       );
         *write_to_dev_size_ptr += buf_remaining;
         if (dev->priv->cur_write_buf->origin == WRITE_BUFFER_ORIGIN_CLIENT) {
-            spice_assert(dev->priv->cur_write_buf->client == client_state->client);
+            spice_assert(dev->priv->cur_write_buf->client == dev_client->client);
             (*write_to_dev_tokens_ptr) += dev->priv->cur_write_buf->token_price;
         }
     }
@@ -1049,7 +1049,7 @@ void spice_char_device_state_migrate_data_marshall(RedCharDevice *dev,
                                       );
         *write_to_dev_size_ptr += write_buf->buf_used;
         if (write_buf->origin == WRITE_BUFFER_ORIGIN_CLIENT) {
-            spice_assert(write_buf->client == client_state->client);
+            spice_assert(write_buf->client == dev_client->client);
             (*write_to_dev_tokens_ptr) += write_buf->token_price;
         }
     }
@@ -1060,13 +1060,13 @@ void spice_char_device_state_migrate_data_marshall(RedCharDevice *dev,
 int spice_char_device_state_restore(RedCharDevice *dev,
                                     SpiceMigrateDataCharDevice *mig_data)
 {
-    SpiceCharDeviceClientState *client_state;
+    RedCharDeviceClient *dev_client;
     uint32_t client_tokens_window;
 
     spice_assert(dev->priv->num_clients == 1 && dev->priv->wait_for_migrate_data);
 
-    client_state = SPICE_CONTAINEROF(ring_get_tail(&dev->priv->clients),
-                                     SpiceCharDeviceClientState,
+    dev_client = SPICE_CONTAINEROF(ring_get_tail(&dev->priv->clients),
+                                     RedCharDeviceClient,
                                      link);
     if (mig_data->version > SPICE_MIGRATE_DATA_CHAR_DEVICE_VERSION) {
         spice_error("dev %p error: migration data version %u is bigger than self %u",
@@ -1076,18 +1076,18 @@ int spice_char_device_state_restore(RedCharDevice *dev,
     spice_assert(!dev->priv->cur_write_buf && ring_is_empty(&dev->priv->write_queue));
     spice_assert(mig_data->connected);
 
-    client_tokens_window = client_state->num_client_tokens; /* initial state of tokens */
-    client_state->num_client_tokens = mig_data->num_client_tokens;
+    client_tokens_window = dev_client->num_client_tokens; /* initial state of tokens */
+    dev_client->num_client_tokens = mig_data->num_client_tokens;
     /* assumption: client_tokens_window stays the same across severs */
-    client_state->num_client_tokens_free = client_tokens_window -
+    dev_client->num_client_tokens_free = client_tokens_window -
                                            mig_data->num_client_tokens -
                                            mig_data->write_num_client_tokens;
-    client_state->num_send_tokens = mig_data->num_send_tokens;
+    dev_client->num_send_tokens = mig_data->num_send_tokens;
 
     if (mig_data->write_size > 0) {
         if (mig_data->write_num_client_tokens) {
             dev->priv->cur_write_buf =
-                __spice_char_device_write_buffer_get(dev, client_state->client,
+                __spice_char_device_write_buffer_get(dev, dev_client->client,
                     mig_data->write_size, WRITE_BUFFER_ORIGIN_CLIENT,
                     mig_data->write_num_client_tokens);
         } else {
commit b693eae58016e858c1a71132415225500a396473
Author: Jonathon Jongsma <jjongsma at redhat.com>
Date:   Thu Mar 31 16:07:01 2016 -0500

    Rename SpiceCharDeviceState to RedCharDevice
    
    This is more consistent with internal type naming convention, and it
    paves the way for a new char device GObject heirarchy
    
    Acked-by: Frediano Ziglio <fziglio at redhat.com>

diff --git a/server/char-device.c b/server/char-device.c
index 49f95ef..5b1cc4e 100644
--- a/server/char-device.c
+++ b/server/char-device.c
@@ -33,7 +33,7 @@
 typedef struct SpiceCharDeviceClientState SpiceCharDeviceClientState;
 struct SpiceCharDeviceClientState {
     RingItem link;
-    SpiceCharDeviceState *dev;
+    RedCharDevice *dev;
     RedClient *client;
     int do_flow_control;
     uint64_t num_client_tokens;
@@ -74,6 +74,7 @@ struct RedCharDevicePrivate {
     SpiceServer *reds;
 };
 
+/* typedef'ed as RedCharDevice */
 struct SpiceCharDeviceState {
     struct RedCharDevicePrivate priv[1];
 };
@@ -87,8 +88,8 @@ enum {
 
 /* Holding references for avoiding access violation if the char device was
  * destroyed during a callback */
-static void spice_char_device_state_ref(SpiceCharDeviceState *char_dev);
-static void spice_char_device_state_unref(SpiceCharDeviceState *char_dev);
+static void spice_char_device_state_ref(RedCharDevice *char_dev);
+static void spice_char_device_state_unref(RedCharDevice *char_dev);
 static void red_char_device_write_buffer_unref(RedCharDeviceWriteBuffer *write_buf);
 
 static void spice_char_dev_write_retry(void *opaque);
@@ -99,27 +100,27 @@ typedef struct RedCharDeviceMsgToClientItem {
 } RedCharDeviceMsgToClientItem;
 
 static RedCharDeviceMsgToClient *
-spice_char_device_read_one_msg_from_device(SpiceCharDeviceState *dev)
+spice_char_device_read_one_msg_from_device(RedCharDevice *dev)
 {
    return dev->priv->cbs.read_one_msg_from_device(dev->priv->sin, dev->priv->opaque);
 }
 
 static RedCharDeviceMsgToClient *
-spice_char_device_ref_msg_to_client(SpiceCharDeviceState *dev,
+spice_char_device_ref_msg_to_client(RedCharDevice *dev,
                                     RedCharDeviceMsgToClient *msg)
 {
    return dev->priv->cbs.ref_msg_to_client(msg, dev->priv->opaque);
 }
 
 static void
-spice_char_device_unref_msg_to_client(SpiceCharDeviceState *dev,
+spice_char_device_unref_msg_to_client(RedCharDevice *dev,
                                       RedCharDeviceMsgToClient *msg)
 {
    dev->priv->cbs.unref_msg_to_client(msg, dev->priv->opaque);
 }
 
 static void
-spice_char_device_send_msg_to_client(SpiceCharDeviceState *dev,
+spice_char_device_send_msg_to_client(RedCharDevice *dev,
                                      RedCharDeviceMsgToClient *msg,
                                      RedClient *client)
 {
@@ -127,7 +128,7 @@ spice_char_device_send_msg_to_client(SpiceCharDeviceState *dev,
 }
 
 static void
-spice_char_device_send_tokens_to_client(SpiceCharDeviceState *dev,
+spice_char_device_send_tokens_to_client(RedCharDevice *dev,
                                         RedClient *client,
                                         uint32_t tokens)
 {
@@ -135,7 +136,7 @@ spice_char_device_send_tokens_to_client(SpiceCharDeviceState *dev,
 }
 
 static void
-spice_char_device_on_free_self_token(SpiceCharDeviceState *dev)
+spice_char_device_on_free_self_token(RedCharDevice *dev)
 {
    if (dev->priv->cbs.on_free_self_token != NULL) {
        dev->priv->cbs.on_free_self_token(dev->priv->opaque);
@@ -143,7 +144,7 @@ spice_char_device_on_free_self_token(SpiceCharDeviceState *dev)
 }
 
 static void
-spice_char_device_remove_client(SpiceCharDeviceState *dev, RedClient *client)
+spice_char_device_remove_client(RedCharDevice *dev, RedClient *client)
 {
    dev->priv->cbs.remove_client(client, dev->priv->opaque);
 }
@@ -169,7 +170,7 @@ static void write_buffers_queue_free(Ring *write_queue)
     }
 }
 
-static void spice_char_device_write_buffer_pool_add(SpiceCharDeviceState *dev,
+static void spice_char_device_write_buffer_pool_add(RedCharDevice *dev,
                                                     RedCharDeviceWriteBuffer *buf)
 {
     if (buf->refs == 1 &&
@@ -186,7 +187,7 @@ static void spice_char_device_write_buffer_pool_add(SpiceCharDeviceState *dev,
     red_char_device_write_buffer_unref(buf);
 }
 
-static void spice_char_device_client_send_queue_free(SpiceCharDeviceState *dev,
+static void spice_char_device_client_send_queue_free(RedCharDevice *dev,
                                                      SpiceCharDeviceClientState *dev_client)
 {
     spice_debug("send_queue_empty %d", ring_is_empty(&dev_client->send_queue));
@@ -204,7 +205,7 @@ static void spice_char_device_client_send_queue_free(SpiceCharDeviceState *dev,
     dev_client->send_queue_size = 0;
 }
 
-static void spice_char_device_client_free(SpiceCharDeviceState *dev,
+static void spice_char_device_client_free(RedCharDevice *dev,
                                           SpiceCharDeviceClientState *dev_client)
 {
     RingItem *item, *next;
@@ -242,12 +243,12 @@ static void spice_char_device_client_free(SpiceCharDeviceState *dev,
 
 static void spice_char_device_handle_client_overflow(SpiceCharDeviceClientState *dev_client)
 {
-    SpiceCharDeviceState *dev = dev_client->dev;
+    RedCharDevice *dev = dev_client->dev;
     spice_printerr("dev %p client %p ", dev, dev_client);
     spice_char_device_remove_client(dev, dev_client->client);
 }
 
-static SpiceCharDeviceClientState *spice_char_device_client_find(SpiceCharDeviceState *dev,
+static SpiceCharDeviceClientState *spice_char_device_client_find(RedCharDevice *dev,
                                                                  RedClient *client)
 {
     RingItem *item;
@@ -279,7 +280,7 @@ static int spice_char_device_can_send_to_client(SpiceCharDeviceClientState *dev_
     return !dev_client->do_flow_control || dev_client->num_send_tokens;
 }
 
-static uint64_t spice_char_device_max_send_tokens(SpiceCharDeviceState *dev)
+static uint64_t spice_char_device_max_send_tokens(RedCharDevice *dev)
 {
     RingItem *item;
     uint64_t max = 0;
@@ -304,7 +305,7 @@ static uint64_t spice_char_device_max_send_tokens(SpiceCharDeviceState *dev)
 static void spice_char_device_add_msg_to_client_queue(SpiceCharDeviceClientState *dev_client,
                                                       RedCharDeviceMsgToClient *msg)
 {
-    SpiceCharDeviceState *dev = dev_client->dev;
+    RedCharDevice *dev = dev_client->dev;
     RedCharDeviceMsgToClientItem *msg_item;
 
     if (dev_client->send_queue_size >= dev_client->max_send_queue_size) {
@@ -323,7 +324,7 @@ static void spice_char_device_add_msg_to_client_queue(SpiceCharDeviceClientState
     }
 }
 
-static void spice_char_device_send_msg_to_clients(SpiceCharDeviceState *dev,
+static void spice_char_device_send_msg_to_clients(RedCharDevice *dev,
                                                   RedCharDeviceMsgToClient *msg)
 {
     RingItem *item, *next;
@@ -344,7 +345,7 @@ static void spice_char_device_send_msg_to_clients(SpiceCharDeviceState *dev,
     }
 }
 
-static int spice_char_device_read_from_device(SpiceCharDeviceState *dev)
+static int spice_char_device_read_from_device(RedCharDevice *dev)
 {
     uint64_t max_send_tokens;
     int did_read = FALSE;
@@ -417,7 +418,7 @@ static void spice_char_device_client_send_queue_push(SpiceCharDeviceClientState
 static void spice_char_device_send_to_client_tokens_absorb(SpiceCharDeviceClientState *dev_client,
                                                            uint32_t tokens)
 {
-    SpiceCharDeviceState *dev = dev_client->dev;
+    RedCharDevice *dev = dev_client->dev;
     dev_client->num_send_tokens += tokens;
 
     if (dev_client->send_queue_size) {
@@ -436,7 +437,7 @@ static void spice_char_device_send_to_client_tokens_absorb(SpiceCharDeviceClient
     }
 }
 
-void spice_char_device_send_to_client_tokens_add(SpiceCharDeviceState *dev,
+void spice_char_device_send_to_client_tokens_add(RedCharDevice *dev,
                                                  RedClient *client,
                                                  uint32_t tokens)
 {
@@ -451,7 +452,7 @@ void spice_char_device_send_to_client_tokens_add(SpiceCharDeviceState *dev,
     spice_char_device_send_to_client_tokens_absorb(dev_client, tokens);
 }
 
-void spice_char_device_send_to_client_tokens_set(SpiceCharDeviceState *dev,
+void spice_char_device_send_to_client_tokens_set(RedCharDevice *dev,
                                                  RedClient *client,
                                                  uint32_t tokens)
 {
@@ -472,7 +473,7 @@ void spice_char_device_send_to_client_tokens_set(SpiceCharDeviceState *dev,
  * Writing to the device  *
 ***************************/
 
-static void spice_char_device_client_tokens_add(SpiceCharDeviceState *dev,
+static void spice_char_device_client_tokens_add(RedCharDevice *dev,
                                                 SpiceCharDeviceClientState *dev_client,
                                                 uint32_t num_tokens)
 {
@@ -492,7 +493,7 @@ static void spice_char_device_client_tokens_add(SpiceCharDeviceState *dev,
     }
 }
 
-static int spice_char_device_write_to_device(SpiceCharDeviceState *dev)
+static int spice_char_device_write_to_device(RedCharDevice *dev)
 {
     SpiceCharDeviceInterface *sif;
     int total = 0;
@@ -567,7 +568,7 @@ static int spice_char_device_write_to_device(SpiceCharDeviceState *dev)
 
 static void spice_char_dev_write_retry(void *opaque)
 {
-    SpiceCharDeviceState *dev = opaque;
+    RedCharDevice *dev = opaque;
 
     if (dev->priv->write_to_dev_timer) {
         reds_core_timer_cancel(dev->priv->reds, dev->priv->write_to_dev_timer);
@@ -576,7 +577,7 @@ static void spice_char_dev_write_retry(void *opaque)
 }
 
 static RedCharDeviceWriteBuffer *__spice_char_device_write_buffer_get(
-    SpiceCharDeviceState *dev, RedClient *client,
+    RedCharDevice *dev, RedClient *client,
     int size, int origin, int migrated_data_tokens)
 {
     RingItem *item;
@@ -635,7 +636,7 @@ error:
     return NULL;
 }
 
-RedCharDeviceWriteBuffer *spice_char_device_write_buffer_get(SpiceCharDeviceState *dev,
+RedCharDeviceWriteBuffer *spice_char_device_write_buffer_get(RedCharDevice *dev,
                                                              RedClient *client,
                                                              int size)
 {
@@ -645,7 +646,7 @@ RedCharDeviceWriteBuffer *spice_char_device_write_buffer_get(SpiceCharDeviceStat
 }
 
 RedCharDeviceWriteBuffer *spice_char_device_write_buffer_get_server_no_token(
-    SpiceCharDeviceState *dev, int size)
+    RedCharDevice *dev, int size)
 {
    return  __spice_char_device_write_buffer_get(dev, NULL, size,
              WRITE_BUFFER_ORIGIN_SERVER_NO_TOKEN, 0);
@@ -668,7 +669,7 @@ static void red_char_device_write_buffer_unref(RedCharDeviceWriteBuffer *write_b
         red_char_device_write_buffer_free(write_buf);
 }
 
-void spice_char_device_write_buffer_add(SpiceCharDeviceState *dev,
+void spice_char_device_write_buffer_add(RedCharDevice *dev,
                                         RedCharDeviceWriteBuffer *write_buf)
 {
     spice_assert(dev);
@@ -684,7 +685,7 @@ void spice_char_device_write_buffer_add(SpiceCharDeviceState *dev,
     spice_char_device_write_to_device(dev);
 }
 
-void spice_char_device_write_buffer_release(SpiceCharDeviceState *dev,
+void spice_char_device_write_buffer_release(RedCharDevice *dev,
                                             RedCharDeviceWriteBuffer *write_buf)
 {
     int buf_origin = write_buf->origin;
@@ -719,14 +720,14 @@ void spice_char_device_write_buffer_release(SpiceCharDeviceState *dev,
  * char_device_state management *
  ********************************/
 
-SpiceCharDeviceState *spice_char_device_state_create(SpiceCharDeviceInstance *sin,
-                                                     RedsState *reds,
-                                                     uint32_t client_tokens_interval,
-                                                     uint32_t self_tokens,
-                                                     SpiceCharDeviceCallbacks *cbs,
-                                                     void *opaque)
+RedCharDevice *spice_char_device_state_create(SpiceCharDeviceInstance *sin,
+                                              RedsState *reds,
+                                              uint32_t client_tokens_interval,
+                                              uint32_t self_tokens,
+                                              SpiceCharDeviceCallbacks *cbs,
+                                              void *opaque)
 {
-    SpiceCharDeviceState *char_dev;
+    RedCharDevice *char_dev;
     SpiceCharDeviceInterface *sif;
 
     spice_assert(sin);
@@ -734,7 +735,7 @@ SpiceCharDeviceState *spice_char_device_state_create(SpiceCharDeviceInstance *si
                  cbs->unref_msg_to_client && cbs->send_msg_to_client &&
                  cbs->send_tokens_to_client && cbs->remove_client);
 
-    char_dev = spice_new0(SpiceCharDeviceState, 1);
+    char_dev = spice_new0(RedCharDevice, 1);
     char_dev->priv->sin = sin;
     char_dev->priv->reds = reds;
     char_dev->priv->cbs = *cbs;
@@ -761,7 +762,7 @@ SpiceCharDeviceState *spice_char_device_state_create(SpiceCharDeviceInstance *si
     return char_dev;
 }
 
-void spice_char_device_state_reset_dev_instance(SpiceCharDeviceState *state,
+void spice_char_device_state_reset_dev_instance(RedCharDevice *state,
                                                 SpiceCharDeviceInstance *sin)
 {
     spice_debug("sin %p dev_state %p", sin, state);
@@ -769,17 +770,17 @@ void spice_char_device_state_reset_dev_instance(SpiceCharDeviceState *state,
     sin->st = state;
 }
 
-void *spice_char_device_state_opaque_get(SpiceCharDeviceState *dev)
+void *spice_char_device_state_opaque_get(RedCharDevice *dev)
 {
     return dev->priv->opaque;
 }
 
-static void spice_char_device_state_ref(SpiceCharDeviceState *char_dev)
+static void spice_char_device_state_ref(RedCharDevice *char_dev)
 {
     char_dev->priv->refs++;
 }
 
-static void spice_char_device_state_unref(SpiceCharDeviceState *char_dev)
+static void spice_char_device_state_unref(RedCharDevice *char_dev)
 {
     /* The refs field protects the char_dev from being deallocated in
      * case spice_char_device_state_destroy has been called
@@ -793,7 +794,7 @@ static void spice_char_device_state_unref(SpiceCharDeviceState *char_dev)
     }
 }
 
-void spice_char_device_state_destroy(SpiceCharDeviceState *char_dev)
+void spice_char_device_state_destroy(RedCharDevice *char_dev)
 {
     reds_on_char_device_state_destroy(char_dev->priv->reds, char_dev);
     if (char_dev->priv->write_to_dev_timer) {
@@ -849,7 +850,7 @@ static SpiceCharDeviceClientState *red_char_device_client_new(RedClient *client,
     return dev_client;
 }
 
-int spice_char_device_client_add(SpiceCharDeviceState *dev,
+int spice_char_device_client_add(RedCharDevice *dev,
                                  RedClient *client,
                                  int do_flow_control,
                                  uint32_t max_send_queue_size,
@@ -883,7 +884,7 @@ int spice_char_device_client_add(SpiceCharDeviceState *dev,
     return TRUE;
 }
 
-void spice_char_device_client_remove(SpiceCharDeviceState *dev,
+void spice_char_device_client_remove(RedCharDevice *dev,
                                      RedClient *client)
 {
     SpiceCharDeviceClientState *dev_client;
@@ -909,13 +910,13 @@ void spice_char_device_client_remove(SpiceCharDeviceState *dev,
     }
 }
 
-int spice_char_device_client_exists(SpiceCharDeviceState *dev,
+int spice_char_device_client_exists(RedCharDevice *dev,
                                     RedClient *client)
 {
     return (spice_char_device_client_find(dev, client) != NULL);
 }
 
-void spice_char_device_start(SpiceCharDeviceState *dev)
+void spice_char_device_start(RedCharDevice *dev)
 {
     spice_debug("dev_state %p", dev);
     dev->priv->running = TRUE;
@@ -925,7 +926,7 @@ void spice_char_device_start(SpiceCharDeviceState *dev)
     spice_char_device_state_unref(dev);
 }
 
-void spice_char_device_stop(SpiceCharDeviceState *dev)
+void spice_char_device_stop(RedCharDevice *dev)
 {
     spice_debug("dev_state %p", dev);
     dev->priv->running = FALSE;
@@ -935,7 +936,7 @@ void spice_char_device_stop(SpiceCharDeviceState *dev)
     }
 }
 
-void spice_char_device_reset(SpiceCharDeviceState *dev)
+void spice_char_device_reset(RedCharDevice *dev)
 {
     RingItem *client_item;
 
@@ -967,7 +968,7 @@ void spice_char_device_reset(SpiceCharDeviceState *dev)
     dev->priv->sin = NULL;
 }
 
-void spice_char_device_wakeup(SpiceCharDeviceState *dev)
+void spice_char_device_wakeup(RedCharDevice *dev)
 {
     spice_char_device_write_to_device(dev);
     spice_char_device_read_from_device(dev);
@@ -996,7 +997,7 @@ static void migrate_data_marshaller_write_buffer_free(uint8_t *data, void *opaqu
     red_char_device_write_buffer_unref(write_buf);
 }
 
-void spice_char_device_state_migrate_data_marshall(SpiceCharDeviceState *dev,
+void spice_char_device_state_migrate_data_marshall(RedCharDevice *dev,
                                                    SpiceMarshaller *m)
 {
     SpiceCharDeviceClientState *client_state;
@@ -1056,7 +1057,7 @@ void spice_char_device_state_migrate_data_marshall(SpiceCharDeviceState *dev,
                 dev, *write_to_dev_size_ptr, *write_to_dev_tokens_ptr);
 }
 
-int spice_char_device_state_restore(SpiceCharDeviceState *dev,
+int spice_char_device_state_restore(RedCharDevice *dev,
                                     SpiceMigrateDataCharDevice *mig_data)
 {
     SpiceCharDeviceClientState *client_state;
@@ -1107,7 +1108,7 @@ int spice_char_device_state_restore(SpiceCharDeviceState *dev,
     return TRUE;
 }
 
-SpiceServer* spice_char_device_get_server(SpiceCharDeviceState *dev)
+SpiceServer* spice_char_device_get_server(RedCharDevice *dev)
 {
     return dev->priv->reds;
 }
diff --git a/server/char-device.h b/server/char-device.h
index 1076e07..86bf1b9 100644
--- a/server/char-device.h
+++ b/server/char-device.h
@@ -80,6 +80,8 @@
  * */
 
 struct RedsState;
+/* SpiceCharDeviceState is public API, but internally we use RedCharDevice */
+typedef struct SpiceCharDeviceState RedCharDevice;
 
 /* buffer that is used for writing to the device */
 typedef struct RedCharDeviceWriteBuffer {
@@ -129,25 +131,25 @@ typedef struct SpiceCharDeviceCallbacks {
     void (*remove_client)(RedClient *client, void *opaque);
 } SpiceCharDeviceCallbacks;
 
-SpiceCharDeviceState *spice_char_device_state_create(SpiceCharDeviceInstance *sin,
-                                                     struct RedsState *reds,
-                                                     uint32_t client_tokens_interval,
-                                                     uint32_t self_tokens,
-                                                     SpiceCharDeviceCallbacks *cbs,
-                                                     void *opaque);
+RedCharDevice *spice_char_device_state_create(SpiceCharDeviceInstance *sin,
+                                              struct RedsState *reds,
+                                              uint32_t client_tokens_interval,
+                                              uint32_t self_tokens,
+                                              SpiceCharDeviceCallbacks *cbs,
+                                              void *opaque);
 
-void spice_char_device_state_reset_dev_instance(SpiceCharDeviceState *dev,
+void spice_char_device_state_reset_dev_instance(RedCharDevice *dev,
                                                 SpiceCharDeviceInstance *sin);
-void spice_char_device_state_destroy(SpiceCharDeviceState *dev);
+void spice_char_device_state_destroy(RedCharDevice *dev);
 
-void *spice_char_device_state_opaque_get(SpiceCharDeviceState *dev);
+void *spice_char_device_state_opaque_get(RedCharDevice *dev);
 
 /* only one client is supported */
-void spice_char_device_state_migrate_data_marshall(SpiceCharDeviceState *dev,
+void spice_char_device_state_migrate_data_marshall(RedCharDevice *dev,
                                                   SpiceMarshaller *m);
 void spice_char_device_state_migrate_data_marshall_empty(SpiceMarshaller *m);
 
-int spice_char_device_state_restore(SpiceCharDeviceState *dev,
+int spice_char_device_state_restore(RedCharDevice *dev,
                                     SpiceMigrateDataCharDevice *mig_data);
 
 /*
@@ -165,11 +167,11 @@ int spice_char_device_state_restore(SpiceCharDeviceState *dev,
  *
  *  todo: change AGENT_CONNECT msg to contain tokens count.
  */
-void spice_char_device_reset(SpiceCharDeviceState *dev);
+void spice_char_device_reset(RedCharDevice *dev);
 
 /* max_send_queue_size = how many messages we can read from the device and enqueue for this client,
  * when we have tokens for other clients and no tokens for this one */
-int spice_char_device_client_add(SpiceCharDeviceState *dev,
+int spice_char_device_client_add(RedCharDevice *dev,
                                  RedClient *client,
                                  int do_flow_control,
                                  uint32_t max_send_queue_size,
@@ -177,45 +179,45 @@ int spice_char_device_client_add(SpiceCharDeviceState *dev,
                                  uint32_t num_send_tokens,
                                  int wait_for_migrate_data);
 
-void spice_char_device_client_remove(SpiceCharDeviceState *dev,
+void spice_char_device_client_remove(RedCharDevice *dev,
                                      RedClient *client);
-int spice_char_device_client_exists(SpiceCharDeviceState *dev,
+int spice_char_device_client_exists(RedCharDevice *dev,
                                     RedClient *client);
 
-void spice_char_device_start(SpiceCharDeviceState *dev);
-void spice_char_device_stop(SpiceCharDeviceState *dev);
-SpiceServer* spice_char_device_get_server(SpiceCharDeviceState *dev);
+void spice_char_device_start(RedCharDevice *dev);
+void spice_char_device_stop(RedCharDevice *dev);
+SpiceServer* spice_char_device_get_server(RedCharDevice *dev);
 
 /** Read from device **/
 
-void spice_char_device_wakeup(SpiceCharDeviceState *dev);
+void spice_char_device_wakeup(RedCharDevice *dev);
 
-void spice_char_device_send_to_client_tokens_add(SpiceCharDeviceState *dev,
+void spice_char_device_send_to_client_tokens_add(RedCharDevice *dev,
                                                  RedClient *client,
                                                  uint32_t tokens);
 
 
-void spice_char_device_send_to_client_tokens_set(SpiceCharDeviceState *dev,
+void spice_char_device_send_to_client_tokens_set(RedCharDevice *dev,
                                                  RedClient *client,
                                                  uint32_t tokens);
 /** Write to device **/
 
-RedCharDeviceWriteBuffer *spice_char_device_write_buffer_get(SpiceCharDeviceState *dev,
+RedCharDeviceWriteBuffer *spice_char_device_write_buffer_get(RedCharDevice *dev,
                                                              RedClient *client, int size);
 RedCharDeviceWriteBuffer *spice_char_device_write_buffer_get_server_no_token(
-    SpiceCharDeviceState *dev, int size);
+    RedCharDevice *dev, int size);
 
 /* Either add the buffer to the write queue or release it */
-void spice_char_device_write_buffer_add(SpiceCharDeviceState *dev,
+void spice_char_device_write_buffer_add(RedCharDevice *dev,
                                         RedCharDeviceWriteBuffer *write_buf);
-void spice_char_device_write_buffer_release(SpiceCharDeviceState *dev,
+void spice_char_device_write_buffer_release(RedCharDevice *dev,
                                             RedCharDeviceWriteBuffer *write_buf);
 
 /* api for specific char devices */
 
-SpiceCharDeviceState *spicevmc_device_connect(struct RedsState *reds,
-                                              SpiceCharDeviceInstance *sin,
-                                              uint8_t channel_type);
+RedCharDevice *spicevmc_device_connect(struct RedsState *reds,
+                                       SpiceCharDeviceInstance *sin,
+                                       uint8_t channel_type);
 void spicevmc_device_disconnect(struct RedsState *reds,
                                 SpiceCharDeviceInstance *char_device);
 
diff --git a/server/reds-private.h b/server/reds-private.h
index 560a21b..b78e25d 100644
--- a/server/reds-private.h
+++ b/server/reds-private.h
@@ -58,7 +58,7 @@ enum {
 };
 
 struct VDIPortState {
-    SpiceCharDeviceState *base;
+    RedCharDevice *base;
     uint32_t plug_generation;
     int client_agent_started;
 
diff --git a/server/reds.c b/server/reds.c
index 1776186..bb96d09 100644
--- a/server/reds.c
+++ b/server/reds.c
@@ -171,8 +171,8 @@ static RedsMigTargetClient* reds_mig_target_client_find(RedsState *reds, RedClie
 static void reds_mig_target_client_free(RedsMigTargetClient *mig_client);
 static void reds_mig_cleanup_wait_disconnect(RedsState *reds);
 static void reds_mig_remove_wait_disconnect_client(RedsState *reds, RedClient *client);
-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_add_char_device(RedsState *reds, RedCharDevice *dev);
+static void reds_remove_char_device(RedsState *reds, RedCharDevice *dev);
 static void reds_send_mm_time(RedsState *reds);
 static void reds_on_ic_change(RedsState *reds);
 static void reds_on_sv_change(RedsState *reds);
@@ -922,7 +922,7 @@ void reds_fill_channels(RedsState *reds, SpiceMsgChannels *channels_info)
 
 void reds_on_main_agent_start(RedsState *reds, MainChannelClient *mcc, uint32_t num_tokens)
 {
-    SpiceCharDeviceState *dev_state = reds->agent_state.base;
+    RedCharDevice *dev_state = reds->agent_state.base;
     RedChannelClient *rcc;
 
     if (!reds->vdagent) {
@@ -1176,7 +1176,7 @@ void reds_marshall_migrate_data(RedsState *reds, SpiceMarshaller *m)
         uint8_t *null_agent_mig_data;
 
         spice_assert(!agent_state->base); /* MSG_AGENT_CONNECTED_TOKENS is supported by the client
-                                             (see spice_server_migrate_connect), so SpiceCharDeviceState
+                                             (see spice_server_migrate_connect), so RedCharDevice
                                              is destroyed when the agent is disconnected and
                                              there is no need to track the client tokens
                                              (see reds_reset_vdp) */
@@ -2968,7 +2968,7 @@ void reds_disable_mm_time(RedsState *reds)
     reds->mm_time_enabled = FALSE;
 }
 
-static SpiceCharDeviceState *attach_to_red_agent(RedsState *reds, SpiceCharDeviceInstance *sin)
+static RedCharDevice *attach_to_red_agent(RedsState *reds, SpiceCharDeviceInstance *sin)
 {
     VDIPortState *state = &reds->agent_state;
     SpiceCharDeviceInterface *sif;
@@ -3056,7 +3056,7 @@ static SpiceCharDeviceState *attach_to_red_agent(RedsState *reds, SpiceCharDevic
 SPICE_GNUC_VISIBLE void spice_server_char_device_wakeup(SpiceCharDeviceInstance* sin)
 {
     if (!sin->st) {
-        spice_warning("no SpiceCharDeviceState attached to instance %p", sin);
+        spice_warning("no RedCharDevice attached to instance %p", sin);
         return;
     }
     spice_char_device_wakeup(sin->st);
@@ -3081,20 +3081,20 @@ SPICE_GNUC_VISIBLE const char** spice_server_char_device_recognized_subtypes(voi
     return spice_server_char_device_recognized_subtypes_list;
 }
 
-static void reds_char_device_add_state(RedsState *reds, SpiceCharDeviceState *st)
+static void reds_add_char_device(RedsState *reds, RedCharDevice *dev)
 {
-    reds->char_devices = g_list_append(reds->char_devices, st);
+    reds->char_devices = g_list_append(reds->char_devices, dev);
 }
 
-static void reds_char_device_remove_state(RedsState *reds, SpiceCharDeviceState *st)
+static void reds_remove_char_device(RedsState *reds, RedCharDevice *dev)
 {
-    g_warn_if_fail(g_list_find(reds->char_devices, st) != NULL);
-    reds->char_devices = g_list_remove(reds->char_devices, st);
+    g_warn_if_fail(g_list_find(reds->char_devices, dev) != NULL);
+    reds->char_devices = g_list_remove(reds->char_devices, dev);
 }
 
-void reds_on_char_device_state_destroy(RedsState *reds, SpiceCharDeviceState *dev)
+void reds_on_char_device_state_destroy(RedsState *reds, RedCharDevice *dev)
 {
-    reds_char_device_remove_state(reds, dev);
+    reds_remove_char_device(reds, dev);
 }
 
 static int spice_server_char_device_add_interface(SpiceServer *reds,
@@ -3102,7 +3102,7 @@ static int spice_server_char_device_add_interface(SpiceServer *reds,
 {
     SpiceCharDeviceInstance* char_device =
             SPICE_CONTAINEROF(sin, SpiceCharDeviceInstance, base);
-    SpiceCharDeviceState *dev_state = NULL;
+    RedCharDevice *dev_state = NULL;
 
     spice_info("CHAR_DEVICE %s", char_device->subtype);
     if (strcmp(char_device->subtype, SUBTYPE_VDAGENT) == 0) {
@@ -3137,7 +3137,7 @@ static int spice_server_char_device_add_interface(SpiceServer *reds,
         if (reds->vm_running) {
             spice_char_device_start(char_device->st);
         }
-        reds_char_device_add_state(reds, char_device->st);
+        reds_add_char_device(reds, char_device->st);
     } else {
         spice_warning("failed to create device state for %s", char_device->subtype);
         return -1;
@@ -3976,7 +3976,7 @@ SPICE_GNUC_VISIBLE void spice_server_vm_start(SpiceServer *reds)
 
     reds->vm_running = TRUE;
     for (it = reds->char_devices; it != NULL; it = it->next) {
-        spice_char_device_start((SpiceCharDeviceState *)it->data);
+        spice_char_device_start(it->data);
     }
     reds_on_vm_start(reds);
 }
@@ -3987,7 +3987,7 @@ SPICE_GNUC_VISIBLE void spice_server_vm_stop(SpiceServer *reds)
 
     reds->vm_running = FALSE;
     for (it = reds->char_devices; it != NULL; it = it->next) {
-        spice_char_device_stop((SpiceCharDeviceState *)it->data);
+        spice_char_device_stop(it->data);
     }
     reds_on_vm_stop(reds);
 }
diff --git a/server/reds.h b/server/reds.h
index 5966dc3..83618e9 100644
--- a/server/reds.h
+++ b/server/reds.h
@@ -26,6 +26,7 @@
 
 #include "common/marshaller.h"
 #include "common/messages.h"
+#include "char-device.h"
 #include "spice.h"
 #include "red-channel.h"
 #include "main-dispatcher.h"
@@ -101,7 +102,7 @@ int reds_on_migrate_dst_set_seamless(RedsState *reds, MainChannelClient *mcc, ui
 void reds_on_client_semi_seamless_migrate_complete(RedsState *reds, RedClient *client);
 void reds_on_client_seamless_migrate_complete(RedsState *reds, RedClient *client);
 void reds_on_main_channel_migrate(RedsState *reds, MainChannelClient *mcc);
-void reds_on_char_device_state_destroy(RedsState *reds, SpiceCharDeviceState *dev);
+void reds_on_char_device_state_destroy(RedsState *reds, RedCharDevice *dev);
 
 void reds_set_client_mm_time_latency(RedsState *reds, RedClient *client, uint32_t latency);
 uint32_t reds_get_streaming_video(const RedsState *reds);
diff --git a/server/smartcard.c b/server/smartcard.c
index af282a1..6e32f31 100644
--- a/server/smartcard.c
+++ b/server/smartcard.c
@@ -63,7 +63,7 @@ typedef struct SmartCardChannelClient {
 } SmartCardChannelClient;
 
 struct RedCharDeviceSmartcardPrivate {
-    SpiceCharDeviceState *chardev_st;
+    RedCharDevice       *chardev;
     uint32_t             reader_id;
     /* read_from_device buffer */
     uint8_t             *buf;
@@ -286,12 +286,12 @@ static SmartCardDeviceState *smartcard_device_state_new(RedsState *reds, SpiceCh
     chardev_cbs.remove_client = smartcard_remove_client;
 
     st = spice_new0(SmartCardDeviceState, 1);
-    st->priv->chardev_st = spice_char_device_state_create(sin,
-                                                    reds,
-                                                    0, /* tokens interval */
-                                                    ~0, /* self tokens */
-                                                    &chardev_cbs,
-                                                    st);
+    st->priv->chardev = spice_char_device_state_create(sin,
+                                                       reds,
+                                                       0, /* tokens interval */
+                                                       ~0, /* self tokens */
+                                                       &chardev_cbs,
+                                                       st);
     st->priv->reader_id = VSCARD_UNDEFINED_READER_ID;
     st->priv->reader_added = FALSE;
     st->priv->buf_size = APDUBufSize + sizeof(VSCMsgHeader);
@@ -308,7 +308,7 @@ static void smartcard_device_state_free(SmartCardDeviceState* st)
         st->priv->scc->smartcard_state = NULL;
     }
     free(st->priv->buf);
-    spice_char_device_state_destroy(st->priv->chardev_st);
+    spice_char_device_state_destroy(st->priv->chardev);
     free(st);
 }
 
@@ -319,7 +319,7 @@ void smartcard_device_disconnect(SpiceCharDeviceInstance *char_device)
     smartcard_device_state_free(st);
 }
 
-SpiceCharDeviceState *smartcard_device_connect(RedsState *reds, SpiceCharDeviceInstance *char_device)
+RedCharDevice *smartcard_device_connect(RedsState *reds, SpiceCharDeviceInstance *char_device)
 {
     SmartCardDeviceState *st;
 
@@ -328,7 +328,7 @@ SpiceCharDeviceState *smartcard_device_connect(RedsState *reds, SpiceCharDeviceI
         smartcard_device_state_free(st);
         return NULL;
     }
-    return st->priv->chardev_st;
+    return st->priv->chardev;
 }
 
 static void smartcard_char_device_notify_reader_add(SmartCardDeviceState *st)
@@ -336,7 +336,7 @@ static void smartcard_char_device_notify_reader_add(SmartCardDeviceState *st)
     RedCharDeviceWriteBuffer *write_buf;
     VSCMsgHeader *vheader;
 
-    write_buf = spice_char_device_write_buffer_get(st->priv->chardev_st, NULL, sizeof(vheader));
+    write_buf = spice_char_device_write_buffer_get(st->priv->chardev, NULL, sizeof(vheader));
     if (!write_buf) {
         spice_error("failed to allocate write buffer");
         return;
@@ -358,7 +358,7 @@ static void smartcard_char_device_attach_client(SpiceCharDeviceInstance *char_de
     spice_assert(!scc->smartcard_state && !st->priv->scc);
     st->priv->scc = scc;
     scc->smartcard_state = st;
-    client_added = spice_char_device_client_add(st->priv->chardev_st,
+    client_added = spice_char_device_client_add(st->priv->chardev,
                                                 scc->base.client,
                                                 FALSE, /* no flow control yet */
                                                 0, /* send queue size */
@@ -383,7 +383,7 @@ static void smartcard_char_device_notify_reader_remove(SmartCardDeviceState *st)
         spice_debug("reader add was never sent to the device");
         return;
     }
-    write_buf = spice_char_device_write_buffer_get(st->priv->chardev_st, NULL, sizeof(vheader));
+    write_buf = spice_char_device_write_buffer_get(st->priv->chardev, NULL, sizeof(vheader));
     if (!write_buf) {
         spice_error("failed to allocate write buffer");
         return;
@@ -405,7 +405,7 @@ static void smartcard_char_device_detach_client(SmartCardChannelClient *scc)
     }
     st = scc->smartcard_state;
     spice_assert(st->priv->scc == scc);
-    spice_char_device_client_remove(st->priv->chardev_st, scc->base.client);
+    spice_char_device_client_remove(st->priv->chardev, scc->base.client);
     scc->smartcard_state = NULL;
     st->priv->scc = NULL;
 }
@@ -434,7 +434,7 @@ static uint8_t *smartcard_channel_alloc_msg_rcv_buf(RedChannelClient *rcc,
         st = scc->smartcard_state;
         spice_assert(st->priv->scc || scc->smartcard_state);
         spice_assert(!scc->write_buf);
-        scc->write_buf = spice_char_device_write_buffer_get(st->priv->chardev_st, rcc->client, size);
+        scc->write_buf = spice_char_device_write_buffer_get(st->priv->chardev, rcc->client, size);
 
         if (!scc->write_buf) {
             spice_error("failed to allocate write buffer");
@@ -460,11 +460,11 @@ static void smartcard_channel_release_msg_rcv_buf(RedChannelClient *rcc,
         spice_assert(!scc->write_buf);
         free(msg);
     } else {
-        SpiceCharDeviceState *dev_st;
+        RedCharDevice *dev;
         if (scc->write_buf) { /* msg hasn't been pushed to the guest */
             spice_assert(scc->write_buf->buf == msg);
-            dev_st = scc->smartcard_state ? scc->smartcard_state->priv->chardev_st : NULL;
-            spice_char_device_write_buffer_release(dev_st, scc->write_buf);
+            dev = scc->smartcard_state ? scc->smartcard_state->priv->chardev : NULL;
+            spice_char_device_write_buffer_release(dev, scc->write_buf);
             scc->write_buf = NULL;
         }
     }
@@ -518,7 +518,7 @@ static void smartcard_channel_send_migrate_data(RedChannelClient *rcc,
         spice_marshaller_add_uint32(m, 0);
         spice_debug("null char dev state");
     } else {
-        spice_char_device_state_migrate_data_marshall(state->priv->chardev_st, m);
+        spice_char_device_state_migrate_data_marshall(state->priv->chardev, m);
         spice_marshaller_add_uint8(m, state->priv->reader_added);
         spice_marshaller_add_uint32(m, state->priv->buf_used);
         m2 = spice_marshaller_get_ptr_submarshaller(m, 0);
@@ -746,7 +746,7 @@ static int smartcard_channel_client_handle_migrate_data(RedChannelClient *rcc,
     scc->smartcard_state->priv->reader_added = mig_data->reader_added;
 
     smartcard_device_state_restore_partial_read(scc->smartcard_state, mig_data);
-    return spice_char_device_state_restore(scc->smartcard_state->priv->chardev_st, &mig_data->base);
+    return spice_char_device_state_restore(scc->smartcard_state->priv->chardev, &mig_data->base);
 }
 
 static int smartcard_channel_handle_message(RedChannelClient *rcc,
diff --git a/server/smartcard.h b/server/smartcard.h
index 32d2367..9900287 100644
--- a/server/smartcard.h
+++ b/server/smartcard.h
@@ -21,7 +21,7 @@
 /*
  * connect to smartcard interface, used by smartcard channel
  */
-SpiceCharDeviceState *smartcard_device_connect(RedsState *reds, SpiceCharDeviceInstance *char_device);
+RedCharDevice *smartcard_device_connect(RedsState *reds, SpiceCharDeviceInstance *char_device);
 void smartcard_device_disconnect(SpiceCharDeviceInstance *char_device);
 
 #endif // __SMART_CARD_H__
diff --git a/server/spicevmc.c b/server/spicevmc.c
index f263a3d..36c5daf 100644
--- a/server/spicevmc.c
+++ b/server/spicevmc.c
@@ -54,7 +54,7 @@ typedef struct SpiceVmcPipeItem {
 typedef struct SpiceVmcState {
     RedChannel channel; /* Must be the first item */
     RedChannelClient *rcc;
-    SpiceCharDeviceState *chardev_st;
+    RedCharDevice *chardev;
     SpiceCharDeviceInstance *chardev_sin;
     SpiceVmcPipeItem *pipe_item;
     RedCharDeviceWriteBuffer *recv_from_client_buf;
@@ -220,16 +220,16 @@ static void spicevmc_red_channel_client_on_disconnect(RedChannelClient *rcc)
     state = SPICE_CONTAINEROF(rcc->channel, SpiceVmcState, channel);
 
     if (state->recv_from_client_buf) { /* partial message which wasn't pushed to device */
-        spice_char_device_write_buffer_release(state->chardev_st, state->recv_from_client_buf);
+        spice_char_device_write_buffer_release(state->chardev, state->recv_from_client_buf);
         state->recv_from_client_buf = NULL;
     }
 
-    if (state->chardev_st) {
-        if (spice_char_device_client_exists(state->chardev_st, rcc->client)) {
-            spice_char_device_client_remove(state->chardev_st, rcc->client);
+    if (state->chardev) {
+        if (spice_char_device_client_exists(state->chardev, rcc->client)) {
+            spice_char_device_client_remove(state->chardev, rcc->client);
         } else {
             spice_printerr("client %p have already been removed from char dev %p",
-                           rcc->client, state->chardev_st);
+                           rcc->client, state->chardev);
         }
     }
 
@@ -275,7 +275,7 @@ static int spicevmc_channel_client_handle_migrate_data(RedChannelClient *rcc,
         spice_error("bad header");
         return FALSE;
     }
-    return spice_char_device_state_restore(state->chardev_st, &mig_data->base);
+    return spice_char_device_state_restore(state->chardev, &mig_data->base);
 }
 
 static int spicevmc_red_channel_client_handle_message(RedChannelClient *rcc,
@@ -293,7 +293,7 @@ static int spicevmc_red_channel_client_handle_message(RedChannelClient *rcc,
     case SPICE_MSGC_SPICEVMC_DATA:
         spice_assert(state->recv_from_client_buf->buf == msg);
         state->recv_from_client_buf->buf_used = size;
-        spice_char_device_write_buffer_add(state->chardev_st, state->recv_from_client_buf);
+        spice_char_device_write_buffer_add(state->chardev, state->recv_from_client_buf);
         state->recv_from_client_buf = NULL;
         break;
     case SPICE_MSGC_PORT_EVENT:
@@ -323,7 +323,7 @@ static uint8_t *spicevmc_red_channel_alloc_msg_rcv_buf(RedChannelClient *rcc,
     case SPICE_MSGC_SPICEVMC_DATA:
         assert(!state->recv_from_client_buf);
 
-        state->recv_from_client_buf = spice_char_device_write_buffer_get(state->chardev_st,
+        state->recv_from_client_buf = spice_char_device_write_buffer_get(state->chardev,
                                                                          rcc->client,
                                                                          size);
         if (!state->recv_from_client_buf) {
@@ -350,7 +350,7 @@ static void spicevmc_red_channel_release_msg_rcv_buf(RedChannelClient *rcc,
     switch (type) {
     case SPICE_MSGC_SPICEVMC_DATA:
         if (state->recv_from_client_buf) { /* buffer wasn't pushed to device */
-            spice_char_device_write_buffer_release(state->chardev_st, state->recv_from_client_buf);
+            spice_char_device_write_buffer_release(state->chardev, state->recv_from_client_buf);
             state->recv_from_client_buf = NULL;
         }
         break;
@@ -386,7 +386,7 @@ static void spicevmc_red_channel_send_migrate_data(RedChannelClient *rcc,
     spice_marshaller_add_uint32(m, SPICE_MIGRATE_DATA_SPICEVMC_MAGIC);
     spice_marshaller_add_uint32(m, SPICE_MIGRATE_DATA_SPICEVMC_VERSION);
 
-    spice_char_device_state_migrate_data_marshall(state->chardev_st, m);
+    spice_char_device_state_migrate_data_marshall(state->chardev, m);
 }
 
 static void spicevmc_red_channel_send_port_init(RedChannelClient *rcc,
@@ -486,7 +486,7 @@ static void spicevmc_connect(RedChannel *channel, RedClient *client,
         spicevmc_port_send_init(rcc);
     }
 
-    if (!spice_char_device_client_add(state->chardev_st, client, FALSE, 0, ~0, ~0,
+    if (!spice_char_device_client_add(state->chardev, client, FALSE, 0, ~0, ~0,
                                       red_channel_client_is_waiting_for_migrate_data(rcc))) {
         spice_warning("failed to add client to spicevmc");
         red_channel_client_disconnect(rcc);
@@ -499,9 +499,9 @@ static void spicevmc_connect(RedChannel *channel, RedClient *client,
     }
 }
 
-SpiceCharDeviceState *spicevmc_device_connect(RedsState *reds,
-                                              SpiceCharDeviceInstance *sin,
-                                              uint8_t channel_type)
+RedCharDevice *spicevmc_device_connect(RedsState *reds,
+                                       SpiceCharDeviceInstance *sin,
+                                       uint8_t channel_type)
 {
     static uint8_t id[256] = { 0, };
     SpiceVmcState *state;
@@ -537,16 +537,16 @@ SpiceCharDeviceState *spicevmc_device_connect(RedsState *reds,
     char_dev_cbs.send_tokens_to_client = spicevmc_char_dev_send_tokens_to_client;
     char_dev_cbs.remove_client = spicevmc_char_dev_remove_client;
 
-    state->chardev_st = spice_char_device_state_create(sin,
-                                                       reds,
-                                                       0, /* tokens interval */
-                                                       ~0, /* self tokens */
-                                                       &char_dev_cbs,
-                                                       state);
+    state->chardev = spice_char_device_state_create(sin,
+                                                    reds,
+                                                    0, /* tokens interval */
+                                                    ~0, /* self tokens */
+                                                    &char_dev_cbs,
+                                                    state);
     state->chardev_sin = sin;
 
     reds_register_channel(reds, &state->channel);
-    return state->chardev_st;
+    return state->chardev;
 }
 
 /* Must be called from RedClient handling thread. */
@@ -554,13 +554,15 @@ void spicevmc_device_disconnect(RedsState *reds, SpiceCharDeviceInstance *sin)
 {
     SpiceVmcState *state;
 
-    state = (SpiceVmcState *)spice_char_device_state_opaque_get(sin->st);
+    /* FIXME */
+    state = (SpiceVmcState *)spice_char_device_state_opaque_get((RedCharDevice*)sin->st);
 
     if (state->recv_from_client_buf) {
-        spice_char_device_write_buffer_release(state->chardev_st, state->recv_from_client_buf);
+        spice_char_device_write_buffer_release(state->chardev, state->recv_from_client_buf);
     }
-    spice_char_device_state_destroy(sin->st);
-    state->chardev_st = NULL;
+    /* FIXME */
+    spice_char_device_state_destroy((RedCharDevice*)sin->st);
+    state->chardev = NULL;
     sin->st = NULL;
 
     reds_unregister_channel(reds, &state->channel);
@@ -577,7 +579,8 @@ SPICE_GNUC_VISIBLE void spice_server_port_event(SpiceCharDeviceInstance *sin, ui
         return;
     }
 
-    state = (SpiceVmcState *)spice_char_device_state_opaque_get(sin->st);
+    /* FIXME */
+    state = (SpiceVmcState *)spice_char_device_state_opaque_get((RedCharDevice*)sin->st);
     if (event == SPICE_PORT_EVENT_OPENED) {
         state->port_opened = TRUE;
     } else if (event == SPICE_PORT_EVENT_CLOSED) {
commit f3028e9adabee7b7dde7d8901a03cbd6ca4d7e54
Author: Jonathon Jongsma <jjongsma at redhat.com>
Date:   Thu Mar 31 16:07:00 2016 -0500

    Rename SpiceCharDeviceWriteBuffer to RedCharDeviceWriteBuffer
    
    Internal types should use 'Red' namespace for consistency
    
    Acked-by: Frediano Ziglio <fziglio at redhat.com>

diff --git a/server/char-device.c b/server/char-device.c
index daca4fa..49f95ef 100644
--- a/server/char-device.c
+++ b/server/char-device.c
@@ -55,7 +55,7 @@ struct RedCharDevicePrivate {
     Ring write_queue;
     Ring write_bufs_pool;
     uint64_t cur_pool_size;
-    SpiceCharDeviceWriteBuffer *cur_write_buf;
+    RedCharDeviceWriteBuffer *cur_write_buf;
     uint8_t *cur_write_buf_pos;
     SpiceTimer *write_to_dev_timer;
     uint64_t num_self_tokens;
@@ -89,7 +89,7 @@ enum {
  * destroyed during a callback */
 static void spice_char_device_state_ref(SpiceCharDeviceState *char_dev);
 static void spice_char_device_state_unref(SpiceCharDeviceState *char_dev);
-static void spice_char_device_write_buffer_unref(SpiceCharDeviceWriteBuffer *write_buf);
+static void red_char_device_write_buffer_unref(RedCharDeviceWriteBuffer *write_buf);
 
 static void spice_char_dev_write_retry(void *opaque);
 
@@ -148,7 +148,7 @@ spice_char_device_remove_client(SpiceCharDeviceState *dev, RedClient *client)
    dev->priv->cbs.remove_client(client, dev->priv->opaque);
 }
 
-static void spice_char_device_write_buffer_free(SpiceCharDeviceWriteBuffer *buf)
+static void red_char_device_write_buffer_free(RedCharDeviceWriteBuffer *buf)
 {
     if (buf == NULL)
         return;
@@ -161,16 +161,16 @@ static void write_buffers_queue_free(Ring *write_queue)
 {
     while (!ring_is_empty(write_queue)) {
         RingItem *item = ring_get_tail(write_queue);
-        SpiceCharDeviceWriteBuffer *buf;
+        RedCharDeviceWriteBuffer *buf;
 
         ring_remove(item);
-        buf = SPICE_CONTAINEROF(item, SpiceCharDeviceWriteBuffer, link);
-        spice_char_device_write_buffer_free(buf);
+        buf = SPICE_CONTAINEROF(item, RedCharDeviceWriteBuffer, link);
+        red_char_device_write_buffer_free(buf);
     }
 }
 
 static void spice_char_device_write_buffer_pool_add(SpiceCharDeviceState *dev,
-                                                    SpiceCharDeviceWriteBuffer *buf)
+                                                    RedCharDeviceWriteBuffer *buf)
 {
     if (buf->refs == 1 &&
         dev->priv->cur_pool_size < MAX_POOL_SIZE) {
@@ -183,7 +183,7 @@ static void spice_char_device_write_buffer_pool_add(SpiceCharDeviceState *dev,
     }
 
     /* Buffer still being used - just unref for the caller */
-    spice_char_device_write_buffer_unref(buf);
+    red_char_device_write_buffer_unref(buf);
 }
 
 static void spice_char_device_client_send_queue_free(SpiceCharDeviceState *dev,
@@ -219,9 +219,9 @@ static void spice_char_device_client_free(SpiceCharDeviceState *dev,
     /* remove write buffers that are associated with the client */
     spice_debug("write_queue_is_empty %d", ring_is_empty(&dev->priv->write_queue) && !dev->priv->cur_write_buf);
     RING_FOREACH_SAFE(item, next, &dev->priv->write_queue) {
-        SpiceCharDeviceWriteBuffer *write_buf;
+        RedCharDeviceWriteBuffer *write_buf;
 
-        write_buf = SPICE_CONTAINEROF(item, SpiceCharDeviceWriteBuffer, link);
+        write_buf = SPICE_CONTAINEROF(item, RedCharDeviceWriteBuffer, link);
         if (write_buf->origin == WRITE_BUFFER_ORIGIN_CLIENT &&
             write_buf->client == dev_client->client) {
             ring_remove(item);
@@ -522,7 +522,7 @@ static int spice_char_device_write_to_device(SpiceCharDeviceState *dev)
             if (!item) {
                 break;
             }
-            dev->priv->cur_write_buf = SPICE_CONTAINEROF(item, SpiceCharDeviceWriteBuffer, link);
+            dev->priv->cur_write_buf = SPICE_CONTAINEROF(item, RedCharDeviceWriteBuffer, link);
             dev->priv->cur_write_buf_pos = dev->priv->cur_write_buf->buf;
             ring_remove(item);
         }
@@ -541,7 +541,7 @@ static int spice_char_device_write_to_device(SpiceCharDeviceState *dev)
         total += n;
         write_len -= n;
         if (!write_len) {
-            SpiceCharDeviceWriteBuffer *release_buf = dev->priv->cur_write_buf;
+            RedCharDeviceWriteBuffer *release_buf = dev->priv->cur_write_buf;
             dev->priv->cur_write_buf = NULL;
             spice_char_device_write_buffer_release(dev, release_buf);
             continue;
@@ -575,23 +575,23 @@ static void spice_char_dev_write_retry(void *opaque)
     spice_char_device_write_to_device(dev);
 }
 
-static SpiceCharDeviceWriteBuffer *__spice_char_device_write_buffer_get(
+static RedCharDeviceWriteBuffer *__spice_char_device_write_buffer_get(
     SpiceCharDeviceState *dev, RedClient *client,
     int size, int origin, int migrated_data_tokens)
 {
     RingItem *item;
-    SpiceCharDeviceWriteBuffer *ret;
+    RedCharDeviceWriteBuffer *ret;
 
     if (origin == WRITE_BUFFER_ORIGIN_SERVER && !dev->priv->num_self_tokens) {
         return NULL;
     }
 
     if ((item = ring_get_tail(&dev->priv->write_bufs_pool))) {
-        ret = SPICE_CONTAINEROF(item, SpiceCharDeviceWriteBuffer, link);
+        ret = SPICE_CONTAINEROF(item, RedCharDeviceWriteBuffer, link);
         ring_remove(item);
         dev->priv->cur_pool_size -= ret->buf_size;
     } else {
-        ret = spice_new0(SpiceCharDeviceWriteBuffer, 1);
+        ret = spice_new0(RedCharDeviceWriteBuffer, 1);
     }
 
     spice_assert(!ret->buf_used);
@@ -635,23 +635,23 @@ error:
     return NULL;
 }
 
-SpiceCharDeviceWriteBuffer *spice_char_device_write_buffer_get(SpiceCharDeviceState *dev,
-                                                               RedClient *client,
-                                                               int size)
+RedCharDeviceWriteBuffer *spice_char_device_write_buffer_get(SpiceCharDeviceState *dev,
+                                                             RedClient *client,
+                                                             int size)
 {
    return  __spice_char_device_write_buffer_get(dev, client, size,
              client ? WRITE_BUFFER_ORIGIN_CLIENT : WRITE_BUFFER_ORIGIN_SERVER,
              0);
 }
 
-SpiceCharDeviceWriteBuffer *spice_char_device_write_buffer_get_server_no_token(
+RedCharDeviceWriteBuffer *spice_char_device_write_buffer_get_server_no_token(
     SpiceCharDeviceState *dev, int size)
 {
    return  __spice_char_device_write_buffer_get(dev, NULL, size,
              WRITE_BUFFER_ORIGIN_SERVER_NO_TOKEN, 0);
 }
 
-static SpiceCharDeviceWriteBuffer *spice_char_device_write_buffer_ref(SpiceCharDeviceWriteBuffer *write_buf)
+static RedCharDeviceWriteBuffer *red_char_device_write_buffer_ref(RedCharDeviceWriteBuffer *write_buf)
 {
     spice_assert(write_buf);
 
@@ -659,17 +659,17 @@ static SpiceCharDeviceWriteBuffer *spice_char_device_write_buffer_ref(SpiceCharD
     return write_buf;
 }
 
-static void spice_char_device_write_buffer_unref(SpiceCharDeviceWriteBuffer *write_buf)
+static void red_char_device_write_buffer_unref(RedCharDeviceWriteBuffer *write_buf)
 {
     spice_assert(write_buf);
 
     write_buf->refs--;
     if (write_buf->refs == 0)
-        spice_char_device_write_buffer_free(write_buf);
+        red_char_device_write_buffer_free(write_buf);
 }
 
 void spice_char_device_write_buffer_add(SpiceCharDeviceState *dev,
-                                        SpiceCharDeviceWriteBuffer *write_buf)
+                                        RedCharDeviceWriteBuffer *write_buf)
 {
     spice_assert(dev);
     /* caller shouldn't add buffers for client that was removed */
@@ -685,7 +685,7 @@ void spice_char_device_write_buffer_add(SpiceCharDeviceState *dev,
 }
 
 void spice_char_device_write_buffer_release(SpiceCharDeviceState *dev,
-                                            SpiceCharDeviceWriteBuffer *write_buf)
+                                            RedCharDeviceWriteBuffer *write_buf)
 {
     int buf_origin = write_buf->origin;
     uint32_t buf_token_price = write_buf->token_price;
@@ -694,7 +694,7 @@ void spice_char_device_write_buffer_release(SpiceCharDeviceState *dev,
     spice_assert(!ring_item_is_linked(&write_buf->link));
     if (!dev) {
         spice_printerr("no device. write buffer is freed");
-        spice_char_device_write_buffer_free(write_buf);
+        red_char_device_write_buffer_free(write_buf);
         return;
     }
 
@@ -803,7 +803,7 @@ void spice_char_device_state_destroy(SpiceCharDeviceState *char_dev)
     write_buffers_queue_free(&char_dev->priv->write_queue);
     write_buffers_queue_free(&char_dev->priv->write_bufs_pool);
     char_dev->priv->cur_pool_size = 0;
-    spice_char_device_write_buffer_free(char_dev->priv->cur_write_buf);
+    red_char_device_write_buffer_free(char_dev->priv->cur_write_buf);
     char_dev->priv->cur_write_buf = NULL;
 
     while (!ring_is_empty(&char_dev->priv->clients)) {
@@ -944,15 +944,15 @@ void spice_char_device_reset(SpiceCharDeviceState *dev)
     spice_debug("dev_state %p", dev);
     while (!ring_is_empty(&dev->priv->write_queue)) {
         RingItem *item = ring_get_tail(&dev->priv->write_queue);
-        SpiceCharDeviceWriteBuffer *buf;
+        RedCharDeviceWriteBuffer *buf;
 
         ring_remove(item);
-        buf = SPICE_CONTAINEROF(item, SpiceCharDeviceWriteBuffer, link);
+        buf = SPICE_CONTAINEROF(item, RedCharDeviceWriteBuffer, link);
         /* tracking the tokens */
         spice_char_device_write_buffer_release(dev, buf);
     }
     if (dev->priv->cur_write_buf) {
-        SpiceCharDeviceWriteBuffer *release_buf = dev->priv->cur_write_buf;
+        RedCharDeviceWriteBuffer *release_buf = dev->priv->cur_write_buf;
 
         dev->priv->cur_write_buf = NULL;
         spice_char_device_write_buffer_release(dev, release_buf);
@@ -991,9 +991,9 @@ void spice_char_device_state_migrate_data_marshall_empty(SpiceMarshaller *m)
 
 static void migrate_data_marshaller_write_buffer_free(uint8_t *data, void *opaque)
 {
-    SpiceCharDeviceWriteBuffer *write_buf = (SpiceCharDeviceWriteBuffer *)opaque;
+    RedCharDeviceWriteBuffer *write_buf = (RedCharDeviceWriteBuffer *)opaque;
 
-    spice_char_device_write_buffer_unref(write_buf);
+    red_char_device_write_buffer_unref(write_buf);
 }
 
 void spice_char_device_state_migrate_data_marshall(SpiceCharDeviceState *dev,
@@ -1029,7 +1029,7 @@ void spice_char_device_state_migrate_data_marshall(SpiceCharDeviceState *dev,
                                  dev->priv->cur_write_buf_pos;
         spice_marshaller_add_ref_full(m2, dev->priv->cur_write_buf_pos, buf_remaining,
                                       migrate_data_marshaller_write_buffer_free,
-                                      spice_char_device_write_buffer_ref(dev->priv->cur_write_buf)
+                                      red_char_device_write_buffer_ref(dev->priv->cur_write_buf)
                                       );
         *write_to_dev_size_ptr += buf_remaining;
         if (dev->priv->cur_write_buf->origin == WRITE_BUFFER_ORIGIN_CLIENT) {
@@ -1039,12 +1039,12 @@ void spice_char_device_state_migrate_data_marshall(SpiceCharDeviceState *dev,
     }
 
     RING_FOREACH_REVERSED(item, &dev->priv->write_queue) {
-        SpiceCharDeviceWriteBuffer *write_buf;
+        RedCharDeviceWriteBuffer *write_buf;
 
-        write_buf = SPICE_CONTAINEROF(item, SpiceCharDeviceWriteBuffer, link);
+        write_buf = SPICE_CONTAINEROF(item, RedCharDeviceWriteBuffer, link);
         spice_marshaller_add_ref_full(m2, write_buf->buf, write_buf->buf_used,
                                       migrate_data_marshaller_write_buffer_free,
-                                      spice_char_device_write_buffer_ref(write_buf)
+                                      red_char_device_write_buffer_ref(write_buf)
                                       );
         *write_to_dev_size_ptr += write_buf->buf_used;
         if (write_buf->origin == WRITE_BUFFER_ORIGIN_CLIENT) {
diff --git a/server/char-device.h b/server/char-device.h
index f352396..1076e07 100644
--- a/server/char-device.h
+++ b/server/char-device.h
@@ -35,7 +35,7 @@
  *
  * Writing to the device
  * ---------------------
- * Write the data into SpiceCharDeviceWriteBuffer:
+ * Write the data into RedCharDeviceWriteBuffer:
  * call spice_char_device_write_buffer_get in order to get an appropriate buffer.
  * call spice_char_device_write_buffer_add in order to push the buffer to the write queue.
  * If you choose not to push the buffer to the device, call
@@ -82,7 +82,7 @@
 struct RedsState;
 
 /* buffer that is used for writing to the device */
-typedef struct SpiceCharDeviceWriteBuffer {
+typedef struct RedCharDeviceWriteBuffer {
     RingItem link;
     int origin;
     RedClient *client; /* The client that sent the message to the device.
@@ -93,7 +93,7 @@ typedef struct SpiceCharDeviceWriteBuffer {
     uint32_t buf_used;
     uint32_t token_price;
     uint32_t refs;
-} SpiceCharDeviceWriteBuffer;
+} RedCharDeviceWriteBuffer;
 
 typedef void RedCharDeviceMsgToClient;
 
@@ -200,16 +200,16 @@ void spice_char_device_send_to_client_tokens_set(SpiceCharDeviceState *dev,
                                                  uint32_t tokens);
 /** Write to device **/
 
-SpiceCharDeviceWriteBuffer *spice_char_device_write_buffer_get(SpiceCharDeviceState *dev,
-                                                               RedClient *client, int size);
-SpiceCharDeviceWriteBuffer *spice_char_device_write_buffer_get_server_no_token(
+RedCharDeviceWriteBuffer *spice_char_device_write_buffer_get(SpiceCharDeviceState *dev,
+                                                             RedClient *client, int size);
+RedCharDeviceWriteBuffer *spice_char_device_write_buffer_get_server_no_token(
     SpiceCharDeviceState *dev, int size);
 
 /* Either add the buffer to the write queue or release it */
 void spice_char_device_write_buffer_add(SpiceCharDeviceState *dev,
-                                        SpiceCharDeviceWriteBuffer *write_buf);
+                                        RedCharDeviceWriteBuffer *write_buf);
 void spice_char_device_write_buffer_release(SpiceCharDeviceState *dev,
-                                            SpiceCharDeviceWriteBuffer *write_buf);
+                                            RedCharDeviceWriteBuffer *write_buf);
 
 /* api for specific char devices */
 
diff --git a/server/reds-private.h b/server/reds-private.h
index 3001990..560a21b 100644
--- a/server/reds-private.h
+++ b/server/reds-private.h
@@ -63,7 +63,7 @@ struct VDIPortState {
     int client_agent_started;
 
     /* write to agent */
-    SpiceCharDeviceWriteBuffer *recv_from_client_buf;
+    RedCharDeviceWriteBuffer *recv_from_client_buf;
     int recv_from_client_buf_pushed;
     AgentMsgFilter write_filter;
 
diff --git a/server/reds.c b/server/reds.c
index eb13cd3..1776186 100644
--- a/server/reds.c
+++ b/server/reds.c
@@ -502,7 +502,7 @@ void reds_client_disconnect(RedsState *reds, RedClient *client)
     if (reds->num_clients == 0) {
         /* Let the agent know the client is disconnected */
         if (reds->agent_state.base) {
-            SpiceCharDeviceWriteBuffer *char_dev_buf;
+            RedCharDeviceWriteBuffer *char_dev_buf;
             VDInternalBuf *internal_buf;
             uint32_t total_msg_size;
 
@@ -835,7 +835,7 @@ int reds_has_vdagent(RedsState *reds)
 
 void reds_handle_agent_mouse_event(RedsState *reds, const VDAgentMouseState *mouse_state)
 {
-    SpiceCharDeviceWriteBuffer *char_dev_buf;
+    RedCharDeviceWriteBuffer *char_dev_buf;
     VDInternalBuf *internal_buf;
     uint32_t total_msg_size;
 
diff --git a/server/smartcard.c b/server/smartcard.c
index 20d7261..af282a1 100644
--- a/server/smartcard.c
+++ b/server/smartcard.c
@@ -57,8 +57,8 @@ typedef struct SmartCardChannelClient {
 
     /* read_from_client/write_to_device buffer.
      * The beginning of the buffer should always be VSCMsgHeader*/
-    SpiceCharDeviceWriteBuffer *write_buf;
-    int msg_in_write_buf; /* was the client msg received into a SpiceCharDeviceWriteBuffer
+    RedCharDeviceWriteBuffer *write_buf;
+    int msg_in_write_buf; /* was the client msg received into a RedCharDeviceWriteBuffer
                            * or was it explicitly malloced */
 } SmartCardChannelClient;
 
@@ -117,7 +117,7 @@ static SpiceCharDeviceInstance* smartcard_readers_get(uint32_t reader_id);
 static int smartcard_char_device_add_to_readers(RedsState *reds, SpiceCharDeviceInstance *sin);
 static void smartcard_char_device_attach_client(
     SpiceCharDeviceInstance *char_device, SmartCardChannelClient *scc);
-static void smartcard_channel_write_to_reader(SpiceCharDeviceWriteBuffer *write_buf);
+static void smartcard_channel_write_to_reader(RedCharDeviceWriteBuffer *write_buf);
 
 static MsgItem *smartcard_char_device_on_message_from_device(
     SmartCardDeviceState *state, VSCMsgHeader *header);
@@ -333,7 +333,7 @@ SpiceCharDeviceState *smartcard_device_connect(RedsState *reds, SpiceCharDeviceI
 
 static void smartcard_char_device_notify_reader_add(SmartCardDeviceState *st)
 {
-    SpiceCharDeviceWriteBuffer *write_buf;
+    RedCharDeviceWriteBuffer *write_buf;
     VSCMsgHeader *vheader;
 
     write_buf = spice_char_device_write_buffer_get(st->priv->chardev_st, NULL, sizeof(vheader));
@@ -376,7 +376,7 @@ static void smartcard_char_device_attach_client(SpiceCharDeviceInstance *char_de
 
 static void smartcard_char_device_notify_reader_remove(SmartCardDeviceState *st)
 {
-    SpiceCharDeviceWriteBuffer *write_buf;
+    RedCharDeviceWriteBuffer *write_buf;
     VSCMsgHeader *vheader;
 
     if (!st->priv->reader_added) {
@@ -657,7 +657,7 @@ static void smartcard_add_reader(SmartCardChannelClient *scc, uint8_t *name)
     // our SmartCardDeviceState.
 }
 
-static void smartcard_channel_write_to_reader(SpiceCharDeviceWriteBuffer *write_buf)
+static void smartcard_channel_write_to_reader(RedCharDeviceWriteBuffer *write_buf)
 {
     SpiceCharDeviceInstance *sin;
     SmartCardDeviceState *st;
diff --git a/server/spicevmc.c b/server/spicevmc.c
index c67b408..f263a3d 100644
--- a/server/spicevmc.c
+++ b/server/spicevmc.c
@@ -57,7 +57,7 @@ typedef struct SpiceVmcState {
     SpiceCharDeviceState *chardev_st;
     SpiceCharDeviceInstance *chardev_sin;
     SpiceVmcPipeItem *pipe_item;
-    SpiceCharDeviceWriteBuffer *recv_from_client_buf;
+    RedCharDeviceWriteBuffer *recv_from_client_buf;
     uint8_t port_opened;
 } SpiceVmcState;
 
commit f02b66a22583cdc4efb85b8086759fc926f108f5
Author: Jonathon Jongsma <jjongsma at redhat.com>
Date:   Thu Mar 31 16:06:59 2016 -0500

    Rename SpiceCharDeviceMsgToClient to RedCharDeviceMsgToClient
    
    Internal types should use Red namespace for consistency
    
    Acked-by: Frediano Ziglio <fziglio at redhat.com>

diff --git a/server/char-device.c b/server/char-device.c
index 53bfe82..daca4fa 100644
--- a/server/char-device.c
+++ b/server/char-device.c
@@ -93,34 +93,34 @@ static void spice_char_device_write_buffer_unref(SpiceCharDeviceWriteBuffer *wri
 
 static void spice_char_dev_write_retry(void *opaque);
 
-typedef struct SpiceCharDeviceMsgToClientItem {
+typedef struct RedCharDeviceMsgToClientItem {
     RingItem link;
-    SpiceCharDeviceMsgToClient *msg;
-} SpiceCharDeviceMsgToClientItem;
+    RedCharDeviceMsgToClient *msg;
+} RedCharDeviceMsgToClientItem;
 
-static SpiceCharDeviceMsgToClient *
+static RedCharDeviceMsgToClient *
 spice_char_device_read_one_msg_from_device(SpiceCharDeviceState *dev)
 {
    return dev->priv->cbs.read_one_msg_from_device(dev->priv->sin, dev->priv->opaque);
 }
 
-static SpiceCharDeviceMsgToClient *
+static RedCharDeviceMsgToClient *
 spice_char_device_ref_msg_to_client(SpiceCharDeviceState *dev,
-                                    SpiceCharDeviceMsgToClient *msg)
+                                    RedCharDeviceMsgToClient *msg)
 {
    return dev->priv->cbs.ref_msg_to_client(msg, dev->priv->opaque);
 }
 
 static void
 spice_char_device_unref_msg_to_client(SpiceCharDeviceState *dev,
-                                      SpiceCharDeviceMsgToClient *msg)
+                                      RedCharDeviceMsgToClient *msg)
 {
    dev->priv->cbs.unref_msg_to_client(msg, dev->priv->opaque);
 }
 
 static void
 spice_char_device_send_msg_to_client(SpiceCharDeviceState *dev,
-                                     SpiceCharDeviceMsgToClient *msg,
+                                     RedCharDeviceMsgToClient *msg,
                                      RedClient *client)
 {
    dev->priv->cbs.send_msg_to_client(msg, client, dev->priv->opaque);
@@ -192,9 +192,9 @@ static void spice_char_device_client_send_queue_free(SpiceCharDeviceState *dev,
     spice_debug("send_queue_empty %d", ring_is_empty(&dev_client->send_queue));
     while (!ring_is_empty(&dev_client->send_queue)) {
         RingItem *item = ring_get_tail(&dev_client->send_queue);
-        SpiceCharDeviceMsgToClientItem *msg_item = SPICE_CONTAINEROF(item,
-                                                                     SpiceCharDeviceMsgToClientItem,
-                                                                     link);
+        RedCharDeviceMsgToClientItem *msg_item = SPICE_CONTAINEROF(item,
+                                                                   RedCharDeviceMsgToClientItem,
+                                                                   link);
 
         ring_remove(item);
         spice_char_device_unref_msg_to_client(dev, msg_item->msg);
@@ -302,17 +302,17 @@ static uint64_t spice_char_device_max_send_tokens(SpiceCharDeviceState *dev)
 }
 
 static void spice_char_device_add_msg_to_client_queue(SpiceCharDeviceClientState *dev_client,
-                                                      SpiceCharDeviceMsgToClient *msg)
+                                                      RedCharDeviceMsgToClient *msg)
 {
     SpiceCharDeviceState *dev = dev_client->dev;
-    SpiceCharDeviceMsgToClientItem *msg_item;
+    RedCharDeviceMsgToClientItem *msg_item;
 
     if (dev_client->send_queue_size >= dev_client->max_send_queue_size) {
         spice_char_device_handle_client_overflow(dev_client);
         return;
     }
 
-    msg_item = spice_new0(SpiceCharDeviceMsgToClientItem, 1);
+    msg_item = spice_new0(RedCharDeviceMsgToClientItem, 1);
     msg_item->msg = spice_char_device_ref_msg_to_client(dev, msg);
     ring_add(&dev_client->send_queue, &msg_item->link);
     dev_client->send_queue_size++;
@@ -324,7 +324,7 @@ static void spice_char_device_add_msg_to_client_queue(SpiceCharDeviceClientState
 }
 
 static void spice_char_device_send_msg_to_clients(SpiceCharDeviceState *dev,
-                                                  SpiceCharDeviceMsgToClient *msg)
+                                                  RedCharDeviceMsgToClient *msg)
 {
     RingItem *item, *next;
 
@@ -370,7 +370,7 @@ static int spice_char_device_read_from_device(SpiceCharDeviceState *dev)
      * All messages will be discarded if no client is attached to the device
      */
     while ((max_send_tokens || ring_is_empty(&dev->priv->clients)) && dev->priv->running) {
-        SpiceCharDeviceMsgToClient *msg;
+        RedCharDeviceMsgToClient *msg;
 
         msg = spice_char_device_read_one_msg_from_device(dev);
         if (!msg) {
@@ -399,9 +399,9 @@ static void spice_char_device_client_send_queue_push(SpiceCharDeviceClientState
     RingItem *item;
     while ((item = ring_get_tail(&dev_client->send_queue)) &&
            spice_char_device_can_send_to_client(dev_client)) {
-        SpiceCharDeviceMsgToClientItem *msg_item;
+        RedCharDeviceMsgToClientItem *msg_item;
 
-        msg_item = SPICE_CONTAINEROF(item, SpiceCharDeviceMsgToClientItem, link);
+        msg_item = SPICE_CONTAINEROF(item, RedCharDeviceMsgToClientItem, link);
         ring_remove(item);
 
         dev_client->num_send_tokens--;
diff --git a/server/char-device.h b/server/char-device.h
index 7c78524..f352396 100644
--- a/server/char-device.h
+++ b/server/char-device.h
@@ -95,7 +95,7 @@ typedef struct SpiceCharDeviceWriteBuffer {
     uint32_t refs;
 } SpiceCharDeviceWriteBuffer;
 
-typedef void SpiceCharDeviceMsgToClient;
+typedef void RedCharDeviceMsgToClient;
 
 typedef struct SpiceCharDeviceCallbacks {
     /*
@@ -105,13 +105,13 @@ typedef struct SpiceCharDeviceCallbacks {
 
     /* reads from the device till reaching a msg that should be sent to the client,
      * or till the reading fails */
-    SpiceCharDeviceMsgToClient* (*read_one_msg_from_device)(SpiceCharDeviceInstance *sin,
+    RedCharDeviceMsgToClient* (*read_one_msg_from_device)(SpiceCharDeviceInstance *sin,
                                                             void *opaque);
-    SpiceCharDeviceMsgToClient* (*ref_msg_to_client)(SpiceCharDeviceMsgToClient *msg,
-                                                     void *opaque);
-    void (*unref_msg_to_client)(SpiceCharDeviceMsgToClient *msg,
+    RedCharDeviceMsgToClient* (*ref_msg_to_client)(RedCharDeviceMsgToClient *msg,
+                                                   void *opaque);
+    void (*unref_msg_to_client)(RedCharDeviceMsgToClient *msg,
                                 void *opaque);
-    void (*send_msg_to_client)(SpiceCharDeviceMsgToClient *msg,
+    void (*send_msg_to_client)(RedCharDeviceMsgToClient *msg,
                                RedClient *client,
                                void *opaque); /* after this call, the message is unreferenced */
 
diff --git a/server/reds.c b/server/reds.c
index 8942258..eb13cd3 100644
--- a/server/reds.c
+++ b/server/reds.c
@@ -706,8 +706,8 @@ static void vdi_port_read_buf_unref(VDIReadBuf *buf)
 
 /* reads from the device till completes reading a message that is addressed to the client,
  * or otherwise, when reading from the device fails */
-static SpiceCharDeviceMsgToClient *vdi_port_read_one_msg_from_device(SpiceCharDeviceInstance *sin,
-                                                                     void *opaque)
+static RedCharDeviceMsgToClient *vdi_port_read_one_msg_from_device(SpiceCharDeviceInstance *sin,
+                                                                   void *opaque)
 {
     RedsState *reds = opaque;
     VDIPortState *state = &reds->agent_state;
@@ -778,20 +778,20 @@ static SpiceCharDeviceMsgToClient *vdi_port_read_one_msg_from_device(SpiceCharDe
     return NULL;
 }
 
-static SpiceCharDeviceMsgToClient *vdi_port_ref_msg_to_client(SpiceCharDeviceMsgToClient *msg,
-                                                              void *opaque)
+static RedCharDeviceMsgToClient *vdi_port_ref_msg_to_client(RedCharDeviceMsgToClient *msg,
+                                                            void *opaque)
 {
     return vdi_port_read_buf_ref(msg);
 }
 
-static void vdi_port_unref_msg_to_client(SpiceCharDeviceMsgToClient *msg,
+static void vdi_port_unref_msg_to_client(RedCharDeviceMsgToClient *msg,
                                          void *opaque)
 {
     vdi_port_read_buf_unref(msg);
 }
 
 /* after calling this, we unref the message, and the ref is in the instance side */
-static void vdi_port_send_msg_to_client(SpiceCharDeviceMsgToClient *msg,
+static void vdi_port_send_msg_to_client(RedCharDeviceMsgToClient *msg,
                                         RedClient *client,
                                         void *opaque)
 {
diff --git a/server/smartcard.c b/server/smartcard.c
index d34fa05..20d7261 100644
--- a/server/smartcard.c
+++ b/server/smartcard.c
@@ -136,8 +136,8 @@ static void smartcard_read_buf_prepare(SmartCardDeviceState *state, VSCMsgHeader
     }
 }
 
-static SpiceCharDeviceMsgToClient *smartcard_read_msg_from_device(SpiceCharDeviceInstance *sin,
-                                                                  void *opaque)
+static RedCharDeviceMsgToClient *smartcard_read_msg_from_device(SpiceCharDeviceInstance *sin,
+                                                                void *opaque)
 {
     SmartCardDeviceState *state = opaque;
     SpiceCharDeviceInterface *sif = spice_char_device_get_interface(sin);
@@ -173,19 +173,19 @@ static SpiceCharDeviceMsgToClient *smartcard_read_msg_from_device(SpiceCharDevic
     return NULL;
 }
 
-static SpiceCharDeviceMsgToClient *smartcard_ref_msg_to_client(SpiceCharDeviceMsgToClient *msg,
-                                                               void *opaque)
+static RedCharDeviceMsgToClient *smartcard_ref_msg_to_client(RedCharDeviceMsgToClient *msg,
+                                                             void *opaque)
 {
     return smartcard_ref_vsc_msg_item((MsgItem *)msg);
 }
 
-static void smartcard_unref_msg_to_client(SpiceCharDeviceMsgToClient *msg,
+static void smartcard_unref_msg_to_client(RedCharDeviceMsgToClient *msg,
                                           void *opaque)
 {
     smartcard_unref_vsc_msg_item((MsgItem *)msg);
 }
 
-static void smartcard_send_msg_to_client(SpiceCharDeviceMsgToClient *msg,
+static void smartcard_send_msg_to_client(RedCharDeviceMsgToClient *msg,
                                          RedClient *client,
                                          void *opaque)
 {
diff --git a/server/spicevmc.c b/server/spicevmc.c
index 367132c..c67b408 100644
--- a/server/spicevmc.c
+++ b/server/spicevmc.c
@@ -92,20 +92,20 @@ static void spicevmc_pipe_item_unref(SpiceVmcPipeItem *item)
     }
 }
 
-static SpiceCharDeviceMsgToClient *spicevmc_chardev_ref_msg_to_client(SpiceCharDeviceMsgToClient *msg,
-                                                                      void *opaque)
+static RedCharDeviceMsgToClient *spicevmc_chardev_ref_msg_to_client(RedCharDeviceMsgToClient *msg,
+                                                                    void *opaque)
 {
     return spicevmc_pipe_item_ref((SpiceVmcPipeItem *)msg);
 }
 
-static void spicevmc_chardev_unref_msg_to_client(SpiceCharDeviceMsgToClient *msg,
+static void spicevmc_chardev_unref_msg_to_client(RedCharDeviceMsgToClient *msg,
                                                  void *opaque)
 {
     spicevmc_pipe_item_unref((SpiceVmcPipeItem *)msg);
 }
 
-static SpiceCharDeviceMsgToClient *spicevmc_chardev_read_msg_from_dev(SpiceCharDeviceInstance *sin,
-                                                                      void *opaque)
+static RedCharDeviceMsgToClient *spicevmc_chardev_read_msg_from_dev(SpiceCharDeviceInstance *sin,
+                                                                    void *opaque)
 {
     SpiceVmcState *state = opaque;
     SpiceCharDeviceInterface *sif;
@@ -140,9 +140,9 @@ static SpiceCharDeviceMsgToClient *spicevmc_chardev_read_msg_from_dev(SpiceCharD
     }
 }
 
-static void spicevmc_chardev_send_msg_to_client(SpiceCharDeviceMsgToClient *msg,
-                                                 RedClient *client,
-                                                 void *opaque)
+static void spicevmc_chardev_send_msg_to_client(RedCharDeviceMsgToClient *msg,
+                                                RedClient *client,
+                                                void *opaque)
 {
     SpiceVmcState *state = opaque;
     SpiceVmcPipeItem *vmc_msg = msg;


More information about the Spice-commits mailing list