Re: [PATCH] Use RedCharDevice instead of SpiceCharDeviceState

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



> 
> Hi Jonathon,
> 
> On Wed, Mar 30, 2016 at 05:17:47PM -0500, Jonathon Jongsma wrote:
> > These two type names are typedefs of eachother, but it's confusing to
> > have two different typenames for the same type throughout the code.
> > Convert everythign to use RedCharDevice.
> 
> I agree with you about this.
> 
> > ---
> >
> > This patch should apply to the end of this patch series. Comments?
> 
> One question that I have is why our preference for (re)naming is towards
> the Red prefix instead of Spice prefix? I'm still unsure about the
> meaning of 'red'.
> 

I think red is an historic namespace, some kind of company/group name.

About spice and red I would put a simple rule: spice deals with public
interface, red with everything else. Does it sound reasonable?

Frediano


> cheers,
>   toso
> 
> >  server/char-device.c  | 238
> >  +++++++++++++++++++++++++-------------------------
> >  server/char-device.h  | 108 +++++++++++------------
> >  server/reds-private.h |   2 +-
> >  server/reds.c         | 142 +++++++++++++++---------------
> >  server/reds.h         |   3 +-
> >  server/smartcard.c    |  46 +++++-----
> >  server/smartcard.h    |   2 +-
> >  server/spicevmc.c     |  52 +++++------
> >  8 files changed, 297 insertions(+), 296 deletions(-)
> >
> > diff --git a/server/char-device.c b/server/char-device.c
> > index 1947890..98c50ab 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;
> > @@ -103,7 +103,7 @@ typedef struct SpiceCharDeviceMsgToClientItem {
> >  } SpiceCharDeviceMsgToClientItem;
> >
> >  static SpiceCharDeviceMsgToClient *
> > -spice_char_device_read_one_msg_from_device(SpiceCharDeviceState *dev)
> > +red_char_device_read_one_msg_from_device(RedCharDevice *dev)
> >  {
> >     RedCharDeviceClass *klass = RED_CHAR_DEVICE_GET_CLASS(dev);
> >  
> > @@ -111,8 +111,8 @@
> > spice_char_device_read_one_msg_from_device(SpiceCharDeviceState *dev)
> >  }
> >  
> >  static SpiceCharDeviceMsgToClient *
> > -spice_char_device_ref_msg_to_client(SpiceCharDeviceState *dev,
> > -                                    SpiceCharDeviceMsgToClient *msg)
> > +red_char_device_ref_msg_to_client(RedCharDevice *dev,
> > +                                  SpiceCharDeviceMsgToClient *msg)
> >  {
> >     RedCharDeviceClass *klass = RED_CHAR_DEVICE_GET_CLASS(dev);
> >  
> > @@ -120,8 +120,8 @@
> > spice_char_device_ref_msg_to_client(SpiceCharDeviceState *dev,
> >  }
> >  
> >  static void
> > -spice_char_device_unref_msg_to_client(SpiceCharDeviceState *dev,
> > -                                      SpiceCharDeviceMsgToClient *msg)
> > +red_char_device_unref_msg_to_client(RedCharDevice *dev,
> > +                                    SpiceCharDeviceMsgToClient *msg)
> >  {
> >     RedCharDeviceClass *klass = RED_CHAR_DEVICE_GET_CLASS(dev);
> >  
> > @@ -129,9 +129,9 @@
> > spice_char_device_unref_msg_to_client(SpiceCharDeviceState *dev,
> >  }
> >  
> >  static void
> > -spice_char_device_send_msg_to_client(SpiceCharDeviceState *dev,
> > -                                     SpiceCharDeviceMsgToClient *msg,
> > -                                     RedClient *client)
> > +red_char_device_send_msg_to_client(RedCharDevice *dev,
> > +                                   SpiceCharDeviceMsgToClient *msg,
> > +                                   RedClient *client)
> >  {
> >     RedCharDeviceClass *klass = RED_CHAR_DEVICE_GET_CLASS(dev);
> >  
> > @@ -139,9 +139,9 @@
> > spice_char_device_send_msg_to_client(SpiceCharDeviceState *dev,
> >  }
> >  
> >  static void
> > -spice_char_device_send_tokens_to_client(SpiceCharDeviceState *dev,
> > -                                        RedClient *client,
> > -                                        uint32_t tokens)
> > +red_char_device_send_tokens_to_client(RedCharDevice *dev,
> > +                                      RedClient *client,
> > +                                      uint32_t tokens)
> >  {
> >     RedCharDeviceClass *klass = RED_CHAR_DEVICE_GET_CLASS(dev);
> >  
> > @@ -149,7 +149,7 @@
> > spice_char_device_send_tokens_to_client(SpiceCharDeviceState *dev,
> >  }
> >  
> >  static void
> > -spice_char_device_on_free_self_token(SpiceCharDeviceState *dev)
> > +red_char_device_on_free_self_token(RedCharDevice *dev)
> >  {
> >     RedCharDeviceClass *klass = RED_CHAR_DEVICE_GET_CLASS(dev);
> >  
> > @@ -159,7 +159,7 @@
> > spice_char_device_on_free_self_token(SpiceCharDeviceState *dev)
> >  }
> >  
> >  static void
> > -spice_char_device_remove_client(SpiceCharDeviceState *dev, RedClient
> > *client)
> > +red_char_device_remove_client(RedCharDevice *dev, RedClient *client)
> >  {
> >     RedCharDeviceClass *klass = RED_CHAR_DEVICE_GET_CLASS(dev);
> >  
> > @@ -187,8 +187,8 @@ static void write_buffers_queue_free(Ring *write_queue)
> >      }
> >  }
> >  
> > -static void spice_char_device_write_buffer_pool_add(SpiceCharDeviceState
> > *dev,
> > -
> > SpiceCharDeviceWriteBuffer
> > *buf)
> > +static void red_char_device_write_buffer_pool_add(RedCharDevice *dev,
> > +
> > SpiceCharDeviceWriteBuffer
> > *buf)
> >  {
> >      if (buf->refs == 1 &&
> >          dev->priv->cur_pool_size < MAX_POOL_SIZE) {
> > @@ -204,8 +204,8 @@ static void
> > spice_char_device_write_buffer_pool_add(SpiceCharDeviceState *dev,
> >      spice_char_device_write_buffer_unref(buf);
> >  }
> >  
> > -static void spice_char_device_client_send_queue_free(SpiceCharDeviceState
> > *dev,
> > -
> > SpiceCharDeviceClientState
> > *dev_client)
> > +static void red_char_device_client_send_queue_free(RedCharDevice *dev,
> > +
> > SpiceCharDeviceClientState
> > *dev_client)
> >  {
> >      spice_debug("send_queue_empty %d",
> >      ring_is_empty(&dev_client->send_queue));
> >      while (!ring_is_empty(&dev_client->send_queue)) {
> > @@ -215,15 +215,15 @@ static void
> > spice_char_device_client_send_queue_free(SpiceCharDeviceState *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(SpiceCharDeviceState *dev,
> > -                                          SpiceCharDeviceClientState
> > *dev_client)
> > +static void red_char_device_client_free(RedCharDevice *dev,
> > +                                        SpiceCharDeviceClientState
> > *dev_client)
> >  {
> >      RingItem *item, *next;
> >  
> > @@ -232,7 +232,7 @@ static void
> > spice_char_device_client_free(SpiceCharDeviceState *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);
> > @@ -243,7 +243,7 @@ static void
> > spice_char_device_client_free(SpiceCharDeviceState *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);
> >          }
> >      }
> >  
> > @@ -260,13 +260,13 @@ 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);
> > +    red_char_device_remove_client(dev, dev_client->client);
> >  }
> >  
> > -static SpiceCharDeviceClientState
> > *spice_char_device_client_find(SpiceCharDeviceState *dev,
> > -                                                                 RedClient
> > *client)
> > +static SpiceCharDeviceClientState
> > *red_char_device_client_find(RedCharDevice *dev,
> > +                                                               RedClient
> > *client)
> >  {
> >      RingItem *item;
> >  
> > @@ -297,7 +297,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 red_char_device_max_send_tokens(RedCharDevice *dev)
> >  {
> >      RingItem *item;
> >      uint64_t max = 0;
> > @@ -322,7 +322,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,
> >                                                        SpiceCharDeviceMsgToClient
> >                                                        *msg)
> >  {
> > -    SpiceCharDeviceState *dev = dev_client->dev;
> > +    RedCharDevice *dev = dev_client->dev;
> >      SpiceCharDeviceMsgToClientItem *msg_item;
> >  
> >      if (dev_client->send_queue_size >= dev_client->max_send_queue_size) {
> > @@ -331,7 +331,7 @@ static void
> > spice_char_device_add_msg_to_client_queue(SpiceCharDeviceClientState
> >      }
> >  
> >      msg_item = spice_new0(SpiceCharDeviceMsgToClientItem, 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) {
> > @@ -341,8 +341,8 @@ static void
> > spice_char_device_add_msg_to_client_queue(SpiceCharDeviceClientState
> >      }
> >  }
> >  
> > -static void spice_char_device_send_msg_to_clients(SpiceCharDeviceState
> > *dev,
> > -
> > SpiceCharDeviceMsgToClient
> > *msg)
> > +static void red_char_device_send_msg_to_clients(RedCharDevice *dev,
> > +                                                SpiceCharDeviceMsgToClient
> > *msg)
> >  {
> >      RingItem *item, *next;
> >  
> > @@ -353,7 +353,7 @@ static void
> > spice_char_device_send_msg_to_clients(SpiceCharDeviceState *dev,
> >          if (spice_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 {
> > @@ -362,7 +362,7 @@ static void
> > spice_char_device_send_msg_to_clients(SpiceCharDeviceState *dev,
> >      }
> >  }
> >  
> > -static int spice_char_device_read_from_device(SpiceCharDeviceState *dev)
> > +static int red_char_device_read_from_device(RedCharDevice *dev)
> >  {
> >      uint64_t max_send_tokens;
> >      int did_read = FALSE;
> > @@ -381,7 +381,7 @@ static int
> > spice_char_device_read_from_device(SpiceCharDeviceState *dev)
> >          return FALSE;
> >      }
> >  
> > -    max_send_tokens = spice_char_device_max_send_tokens(dev);
> > +    max_send_tokens = red_char_device_max_send_tokens(dev);
> >      g_object_ref(dev);
> >      /*
> >       * Reading from the device only in case at least one of the clients
> >       have a free token.
> > @@ -390,7 +390,7 @@ static int
> > spice_char_device_read_from_device(SpiceCharDeviceState *dev)
> >      while ((max_send_tokens || ring_is_empty(&dev->priv->clients)) &&
> >      dev->priv->running) {
> >          SpiceCharDeviceMsgToClient *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;
> > @@ -400,8 +400,8 @@ static int
> > spice_char_device_read_from_device(SpiceCharDeviceState *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;
> > @@ -423,10 +423,10 @@ static void
> > spice_char_device_client_send_queue_push(SpiceCharDeviceClientState
> >          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);
> >      }
> > @@ -435,7 +435,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) {
> > @@ -446,7 +446,7 @@ static void
> > spice_char_device_send_to_client_tokens_absorb(SpiceCharDeviceClient
> >      if (spice_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);
> > @@ -454,13 +454,13 @@ static void
> > spice_char_device_send_to_client_tokens_absorb(SpiceCharDeviceClient
> >      }
> >  }
> >  
> > -void spice_char_device_send_to_client_tokens_add(SpiceCharDeviceState
> > *dev,
> > +void red_char_device_send_to_client_tokens_add(RedCharDevice *dev,
> >                                                   RedClient *client,
> >                                                   uint32_t tokens)
> >  {
> >      SpiceCharDeviceClientState *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);
> > @@ -469,13 +469,13 @@ 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 red_char_device_send_to_client_tokens_set(RedCharDevice *dev,
> >                                                   RedClient *client,
> >                                                   uint32_t tokens)
> >  {
> >      SpiceCharDeviceClientState *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);
> > @@ -490,9 +490,9 @@ 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,
> > -                                                SpiceCharDeviceClientState
> > *dev_client,
> > -                                                uint32_t num_tokens)
> > +static void red_char_device_client_tokens_add(RedCharDevice *dev,
> > +                                              SpiceCharDeviceClientState
> > *dev_client,
> > +                                              uint32_t num_tokens)
> >  {
> >      if (!dev_client->do_flow_control) {
> >          return;
> > @@ -506,11 +506,11 @@ static void
> > spice_char_device_client_tokens_add(SpiceCharDeviceState *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(SpiceCharDeviceState *dev)
> > +static int red_char_device_write_to_device(RedCharDevice *dev)
> >  {
> >      SpiceCharDeviceInterface *sif;
> >      int total = 0;
> > @@ -561,7 +561,7 @@ static int
> > spice_char_device_write_to_device(SpiceCharDeviceState *dev)
> >          if (!write_len) {
> >              SpiceCharDeviceWriteBuffer *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;
> > @@ -585,16 +585,16 @@ 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);
> >      }
> > -    spice_char_device_write_to_device(dev);
> > +    red_char_device_write_to_device(dev);
> >  }
> >  
> > -static SpiceCharDeviceWriteBuffer *__spice_char_device_write_buffer_get(
> > -    SpiceCharDeviceState *dev, RedClient *client,
> > +static SpiceCharDeviceWriteBuffer *__red_char_device_write_buffer_get(
> > +    RedCharDevice *dev, RedClient *client,
> >      int size, int origin, int migrated_data_tokens)
> >  {
> >      RingItem *item;
> > @@ -622,7 +622,7 @@ static SpiceCharDeviceWriteBuffer
> > *__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);
> > +       SpiceCharDeviceClientState *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) {
> > @@ -653,19 +653,19 @@ error:
> >      return NULL;
> >  }
> >  
> > -SpiceCharDeviceWriteBuffer
> > *spice_char_device_write_buffer_get(SpiceCharDeviceState *dev,
> > -                                                               RedClient
> > *client,
> > -                                                               int size)
> > +SpiceCharDeviceWriteBuffer *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);
> >  }
> >  
> > -SpiceCharDeviceWriteBuffer
> > *spice_char_device_write_buffer_get_server_no_token(
> > -    SpiceCharDeviceState *dev, int size)
> > +SpiceCharDeviceWriteBuffer
> > *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);
> >  }
> >  
> > @@ -686,24 +686,24 @@ static void
> > spice_char_device_write_buffer_unref(SpiceCharDeviceWriteBuffer *wri
> >          spice_char_device_write_buffer_free(write_buf);
> >  }
> >  
> > -void spice_char_device_write_buffer_add(SpiceCharDeviceState *dev,
> > -                                        SpiceCharDeviceWriteBuffer
> > *write_buf)
> > +void red_char_device_write_buffer_add(RedCharDevice *dev,
> > +                                      SpiceCharDeviceWriteBuffer
> > *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(SpiceCharDeviceState *dev,
> > -                                            SpiceCharDeviceWriteBuffer
> > *write_buf)
> > +void red_char_device_write_buffer_release(RedCharDevice *dev,
> > +                                          SpiceCharDeviceWriteBuffer
> > *write_buf)
> >  {
> >      int buf_origin = write_buf->origin;
> >      uint32_t buf_token_price = write_buf->token_price;
> > @@ -718,18 +718,18 @@ void
> > spice_char_device_write_buffer_release(SpiceCharDeviceState *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) {
> >          SpiceCharDeviceClientState *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);
> >      }
> >  }
> >  
> > @@ -737,20 +737,20 @@ void
> > spice_char_device_write_buffer_release(SpiceCharDeviceState *dev,
> >   * char_device_state management *
> >   ********************************/
> >  
> > -void spice_char_device_state_reset_dev_instance(SpiceCharDeviceState
> > *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(SpiceCharDeviceState *dev)
> > +void *red_char_device_opaque_get(RedCharDevice *dev)
> >  {
> >      return dev->priv->opaque;
> >  }
> >  
> > -void spice_char_device_state_destroy(SpiceCharDeviceState *char_dev)
> > +void red_char_device_destroy(RedCharDevice *char_dev)
> >  {
> >      g_return_if_fail(RED_IS_CHAR_DEVICE(char_dev));
> >      g_object_unref(char_dev);
> > @@ -787,13 +787,13 @@ static SpiceCharDeviceClientState
> > *red_char_device_client_new(RedClient *client,
> >      return dev_client;
> >  }
> >  
> > -int spice_char_device_client_add(SpiceCharDeviceState *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)
> >  {
> >      SpiceCharDeviceClientState *dev_client;
> >  
> > @@ -817,27 +817,27 @@ int spice_char_device_client_add(SpiceCharDeviceState
> > *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(SpiceCharDeviceState *dev,
> > -                                     RedClient *client)
> > +void red_char_device_client_remove(RedCharDevice *dev,
> > +                                   RedClient *client)
> >  {
> >      SpiceCharDeviceClientState *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) {
> > @@ -847,23 +847,23 @@ void
> > spice_char_device_client_remove(SpiceCharDeviceState *dev,
> >      }
> >  }
> >  
> > -int spice_char_device_client_exists(SpiceCharDeviceState *dev,
> > +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(SpiceCharDeviceState *dev)
> > +void red_char_device_start(RedCharDevice *dev)
> >  {
> >      spice_debug("dev_state %p", dev);
> >      dev->priv->running = TRUE;
> >      g_object_ref(dev);
> > -    while (spice_char_device_write_to_device(dev) ||
> > -           spice_char_device_read_from_device(dev));
> > +    while (red_char_device_write_to_device(dev) ||
> > +           red_char_device_read_from_device(dev));
> >      g_object_unref(dev);
> >  }
> >  
> > -void spice_char_device_stop(SpiceCharDeviceState *dev)
> > +void red_char_device_stop(RedCharDevice *dev)
> >  {
> >      spice_debug("dev_state %p", dev);
> >      dev->priv->running = FALSE;
> > @@ -873,11 +873,11 @@ void spice_char_device_stop(SpiceCharDeviceState
> > *dev)
> >      }
> >  }
> >  
> > -void spice_char_device_reset(SpiceCharDeviceState *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)) {
> > @@ -887,35 +887,35 @@ void spice_char_device_reset(SpiceCharDeviceState
> > *dev)
> >          ring_remove(item);
> >          buf = SPICE_CONTAINEROF(item, SpiceCharDeviceWriteBuffer, 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) {
> >          SpiceCharDeviceWriteBuffer *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) {
> >          SpiceCharDeviceClientState *dev_client;
> >  
> >          dev_client = SPICE_CONTAINEROF(client_item,
> >          SpiceCharDeviceClientState, 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(SpiceCharDeviceState *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;
> >  
> > @@ -934,8 +934,8 @@ static void
> > migrate_data_marshaller_write_buffer_free(uint8_t *data, void *opaqu
> >      spice_char_device_write_buffer_unref(write_buf);
> >  }
> >  
> > -void spice_char_device_state_migrate_data_marshall(SpiceCharDeviceState
> > *dev,
> > -                                                   SpiceMarshaller *m)
> > +void red_char_device_migrate_data_marshall(RedCharDevice *dev,
> > +                                           SpiceMarshaller *m)
> >  {
> >      SpiceCharDeviceClientState *client_state;
> >      RingItem *item;
> > @@ -994,8 +994,8 @@ 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,
> > -                                    SpiceMigrateDataCharDevice *mig_data)
> > +int red_char_device_restore(RedCharDevice *dev,
> > +                            SpiceMigrateDataCharDevice *mig_data)
> >  {
> >      SpiceCharDeviceClientState *client_state;
> >      uint32_t client_tokens_window;
> > @@ -1024,12 +1024,12 @@ int
> > spice_char_device_state_restore(SpiceCharDeviceState *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,
> > client_state->client,
> > +                __red_char_device_write_buffer_get(dev,
> > client_state->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 */
> > @@ -1040,12 +1040,12 @@ int
> > spice_char_device_state_restore(SpiceCharDeviceState *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(SpiceCharDeviceState *dev)
> > +SpiceServer* red_char_device_get_server(RedCharDevice *dev)
> >  {
> >      return dev->priv->reds;
> >  }
> > @@ -1176,7 +1176,7 @@ red_char_device_finalize(GObject *object)
> >          SpiceCharDeviceClientState *dev_client;
> >  
> >          dev_client = SPICE_CONTAINEROF(item, SpiceCharDeviceClientState,
> >          link);
> > -        spice_char_device_client_free(self, dev_client);
> > +        red_char_device_client_free(self, dev_client);
> >      }
> >      self->priv->running = FALSE;
> >  
> > diff --git a/server/char-device.h b/server/char-device.h
> > index b59e6f0..bb32649 100644
> > --- a/server/char-device.h
> > +++ b/server/char-device.h
> > @@ -89,18 +89,18 @@ GType red_char_device_get_type(void) G_GNUC_CONST;
> >   * How to use the api:
> >   * ==================
> >   * device attached: create new object instantiating a RedCharDevice child
> >   class
> > - * device detached: call spice_char_device_state_destroy/reset
> > + * 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_client_add
> > + * client disconnected: red_char_device_client_remove
> >   *
> >   * Writing to the device
> >   * ---------------------
> >   * Write the data into SpiceCharDeviceWriteBuffer:
> > - * 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_write_buffer_get in order to get an appropriate
> > buffer.
> > + * call red_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
> > - * spice_char_device_write_buffer_release
> > + * red_char_device_write_buffer_release
> >   *
> >   * reading from the device
> >   * -----------------------
> > @@ -112,12 +112,12 @@ GType red_char_device_get_type(void) G_GNUC_CONST;
> >   *
> >   * 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)
> >   */
> >  /* refcounting is used to protect 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 callback, and we might still access the char_dev afterwards.
> >   */
> >  
> > @@ -159,19 +159,19 @@ typedef struct SpiceCharDeviceWriteBuffer {
> >      uint32_t refs;
> >  } SpiceCharDeviceWriteBuffer;
> >  
> > -void spice_char_device_state_reset_dev_instance(SpiceCharDeviceState *dev,
> > -                                                SpiceCharDeviceInstance
> > *sin);
> > -void spice_char_device_state_destroy(SpiceCharDeviceState *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(SpiceCharDeviceState *dev);
> > +void *red_char_device_opaque_get(RedCharDevice *dev);
> >  
> >  /* only one client is supported */
> > -void spice_char_device_state_migrate_data_marshall(SpiceCharDeviceState
> > *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(SpiceCharDeviceState *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.
> > @@ -188,57 +188,57 @@ 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 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(SpiceCharDeviceState *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(SpiceCharDeviceState *dev,
> > -                                     RedClient *client);
> > -int spice_char_device_client_exists(SpiceCharDeviceState *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);
> > +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(SpiceCharDeviceState *dev);
> > +void red_char_device_wakeup(RedCharDevice *dev);
> >  
> > -void spice_char_device_send_to_client_tokens_add(SpiceCharDeviceState
> > *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(SpiceCharDeviceState
> > *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 **/
> >  
> > -SpiceCharDeviceWriteBuffer
> > *spice_char_device_write_buffer_get(SpiceCharDeviceState *dev,
> > -                                                               RedClient
> > *client, int size);
> > -SpiceCharDeviceWriteBuffer
> > *spice_char_device_write_buffer_get_server_no_token(
> > -    SpiceCharDeviceState *dev, int size);
> > +SpiceCharDeviceWriteBuffer *red_char_device_write_buffer_get(RedCharDevice
> > *dev,
> > +                                                             RedClient
> > *client, int size);
> > +SpiceCharDeviceWriteBuffer
> > *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(SpiceCharDeviceState *dev,
> > -                                        SpiceCharDeviceWriteBuffer
> > *write_buf);
> > -void spice_char_device_write_buffer_release(SpiceCharDeviceState *dev,
> > -                                            SpiceCharDeviceWriteBuffer
> > *write_buf);
> > +void red_char_device_write_buffer_add(RedCharDevice *dev,
> > +                                      SpiceCharDeviceWriteBuffer
> > *write_buf);
> > +void red_char_device_write_buffer_release(RedCharDevice *dev,
> > +                                          SpiceCharDeviceWriteBuffer
> > *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 b3dac6d..97c689b 100644
> > --- a/server/reds-private.h
> > +++ b/server/reds-private.h
> > @@ -128,7 +128,7 @@ struct RedsState {
> >      SpiceTimer *mig_timer;
> >  
> >      int vm_running;
> > -    GList *char_devices; /* list of SpiceCharDeviceState */
> > +    GList *char_devices; /* list of RedCharDevice */
> >      int seamless_migration_enabled; /* command line arg */
> >  
> >      SSL_CTX *ctx;
> > diff --git a/server/reds.c b/server/reds.c
> > index 3d83841..ebb3c00 100644
> > --- a/server/reds.c
> > +++ b/server/reds.c
> > @@ -253,8 +253,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);
> > @@ -518,7 +518,7 @@ static void reds_reset_vdp(RedsState *reds)
> >                                      SPICE_MAIN_CAP_AGENT_CONNECTED_TOKENS))
> >                                      {
> >          state->priv->agent_attached = FALSE;
> >      } else {
> > -        spice_char_device_reset(RED_CHAR_DEVICE(state));
> > +        red_char_device_reset(RED_CHAR_DEVICE(state));
> >      }
> >  
> >      sif = spice_char_device_get_interface(reds->vdagent);
> > @@ -569,8 +569,8 @@ void reds_client_disconnect(RedsState *reds, RedClient
> > *client)
> >      if (reds->agent_state->priv->agent_attached) {
> >          /* note that vdagent might be NULL, if the vdagent was once
> >           * up and than was removed */
> > -        if
> > (spice_char_device_client_exists(RED_CHAR_DEVICE(reds->agent_state),
> > client)) {
> > -
> > spice_char_device_client_remove(RED_CHAR_DEVICE(reds->agent_state),
> > client);
> > +        if
> > (red_char_device_client_exists(RED_CHAR_DEVICE(reds->agent_state),
> > client)) {
> > +
> > red_char_device_client_remove(RED_CHAR_DEVICE(reds->agent_state),
> > client);
> >          }
> >      }
> >  
> > @@ -588,7 +588,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(
> >                                 RED_CHAR_DEVICE(reds->agent_state),
> >                                 total_msg_size);
> >              char_dev_buf->buf_used = total_msg_size;
> >              internal_buf = (VDInternalBuf *)char_dev_buf->buf;
> > @@ -599,8 +599,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(RED_CHAR_DEVICE(reds->agent_state),
> > -                                               char_dev_buf);
> > +
> > red_char_device_write_buffer_add(RED_CHAR_DEVICE(reds->agent_state),
> > +                                             char_dev_buf);
> >          }
> >  
> >          /* Reset write filter to start with clean state on client
> >          reconnect */
> > @@ -780,7 +780,7 @@ static void vdi_port_read_buf_unref(VDIReadBuf *buf)
> >          necessary. Note that since we can be called from
> >          spice_char_device_wakeup
> >          this can cause recursion, but we have protection for that */
> >          if (buf->state->priv->agent_attached) {
> > -            spice_char_device_wakeup(RED_CHAR_DEVICE(buf->state));
> > +            red_char_device_wakeup(RED_CHAR_DEVICE(buf->state));
> >          }
> >      }
> >  }
> > @@ -926,9 +926,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(RED_CHAR_DEVICE(reds->agent_state),
> > -                                                      NULL,
> > -                                                      total_msg_size);
> > +    char_dev_buf =
> > red_char_device_write_buffer_get(RED_CHAR_DEVICE(reds->agent_state),
> > +                                                    NULL,
> > +                                                    total_msg_size);
> >  
> >      if (!char_dev_buf) {
> >          reds->pending_mouse_event = TRUE;
> > @@ -947,7 +947,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(RED_CHAR_DEVICE(reds->agent_state),
> > char_dev_buf);
> > +    red_char_device_write_buffer_add(RED_CHAR_DEVICE(reds->agent_state),
> > char_dev_buf);
> >  }
> >  
> >  int reds_get_n_channels(RedsState *reds)
> > @@ -1003,13 +1003,13 @@ 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 = RED_CHAR_DEVICE(reds->agent_state);
> > +    RedCharDevice *dev = RED_CHAR_DEVICE(reds->agent_state);
> >      RedChannelClient *rcc;
> >  
> >      if (!reds->vdagent) {
> >          return;
> >      }
> > -    spice_assert(reds->vdagent->st && reds->vdagent->st == dev_state);
> > +    spice_assert(reds->vdagent->st && reds->vdagent->st == dev);
> >      rcc = main_channel_client_get_base(mcc);
> >      reds->agent_state->priv->client_agent_started = TRUE;
> >      /*
> > @@ -1019,16 +1019,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, 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,
> > +                                                  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");
> > @@ -1036,9 +1036,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,
> > +                                                  rcc->client,
> > +                                                  num_tokens);
> >      }
> >  
> >      agent_msg_filter_config(&reds->agent_state->priv->write_filter,
> >      reds->agent_copypaste,
> > @@ -1053,9 +1053,9 @@ 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,
> > -
> > main_channel_client_get_base(mcc)->client,
> > -                                                num_tokens);
> > +    red_char_device_send_to_client_tokens_add(reds->vdagent->st,
> > +
> > main_channel_client_get_base(mcc)->client,
> > +                                              num_tokens);
> >  }
> >  
> >  uint8_t *reds_get_agent_data_buffer(RedsState *reds, MainChannelClient
> >  *mcc, size_t size)
> > @@ -1076,9 +1076,9 @@ uint8_t *reds_get_agent_data_buffer(RedsState *reds,
> > MainChannelClient *mcc, siz
> >  
> >      spice_assert(dev_state->priv->recv_from_client_buf == NULL);
> >      client = main_channel_client_get_base(mcc)->client;
> > -    dev_state->priv->recv_from_client_buf =
> > spice_char_device_write_buffer_get(RED_CHAR_DEVICE(dev_state),
> > -
> > client,
> > -
> > size
> > + sizeof(VDIChunkHeader));
> > +    dev_state->priv->recv_from_client_buf =
> > red_char_device_write_buffer_get(RED_CHAR_DEVICE(dev_state),
> > +
> > client,
> > +
> > size
> > + sizeof(VDIChunkHeader));
> >      dev_state->priv->recv_from_client_buf_pushed = FALSE;
> >      return dev_state->priv->recv_from_client_buf->buf +
> >      sizeof(VDIChunkHeader);
> >  }
> > @@ -1094,8 +1094,8 @@ void reds_release_agent_data_buffer(RedsState *reds,
> > uint8_t *buf)
> >  
> >      spice_assert(buf == dev_state->priv->recv_from_client_buf->buf +
> >      sizeof(VDIChunkHeader));
> >      if (!dev_state->priv->recv_from_client_buf_pushed) {
> > -
> > spice_char_device_write_buffer_release(RED_CHAR_DEVICE(reds->agent_state),
> > -
> > dev_state->priv->recv_from_client_buf);
> > +
> > red_char_device_write_buffer_release(RED_CHAR_DEVICE(reds->agent_state),
> > +
> > dev_state->priv->recv_from_client_buf);
> >      }
> >      dev_state->priv->recv_from_client_buf = NULL;
> >      dev_state->priv->recv_from_client_buf_pushed = FALSE;
> > @@ -1166,7 +1166,7 @@ void reds_on_main_agent_data(RedsState *reds,
> > MainChannelClient *mcc, void *mess
> >      dev_state->priv->recv_from_client_buf->buf_used =
> >      sizeof(VDIChunkHeader) + size;
> >  
> >      dev_state->priv->recv_from_client_buf_pushed = TRUE;
> > -    spice_char_device_write_buffer_add(RED_CHAR_DEVICE(reds->agent_state),
> > dev_state->priv->recv_from_client_buf);
> > +    red_char_device_write_buffer_add(RED_CHAR_DEVICE(reds->agent_state),
> > dev_state->priv->recv_from_client_buf);
> >  }
> >  
> >  void reds_on_main_migrate_connected(RedsState *reds, int seamless)
> > @@ -1262,7 +1262,7 @@ void reds_marshall_migrate_data(RedsState *reds,
> > SpiceMarshaller *m)
> >             there is no need to track the client tokens
> >             (see reds_reset_vdp) */
> >          spice_assert(!agent_state->priv->agent_attached);
> > -        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));
> > @@ -1272,7 +1272,7 @@ void reds_marshall_migrate_data(RedsState *reds,
> > SpiceMarshaller *m)
> >          return;
> >      }
> >  
> > -
> > spice_char_device_state_migrate_data_marshall(RED_CHAR_DEVICE(reds->agent_state),
> > m);
> > +
> > red_char_device_migrate_data_marshall(RED_CHAR_DEVICE(reds->agent_state),
> > m);
> >      spice_marshaller_add_uint8(m,
> >      reds->agent_state->priv->client_agent_started);
> >  
> >      mig_data.agent2client.chunk_header =
> >      agent_state->priv->vdi_chunk_header;
> > @@ -1392,7 +1392,7 @@ static int reds_agent_state_restore(RedsState *reds,
> > SpiceMigrateDataMain *mig_d
> >                  agent_state->priv->read_filter.discard_all,
> >                  agent_state->priv->read_filter.msg_data_to_read,
> >                   agent_state->priv->read_filter.result);
> > -    return spice_char_device_state_restore(RED_CHAR_DEVICE(agent_state),
> > &mig_data->agent_base);
> > +    return red_char_device_restore(RED_CHAR_DEVICE(agent_state),
> > &mig_data->agent_base);
> >  }
> >  
> >  /*
> > @@ -1441,8 +1441,8 @@ int reds_handle_migrate_data(RedsState *reds,
> > MainChannelClient *mcc,
> >          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(RED_CHAR_DEVICE(agent_state),
> > -
> > main_channel_client_get_base(mcc)->client);
> > +            red_char_device_client_remove(RED_CHAR_DEVICE(agent_state),
> > +
> > main_channel_client_get_base(mcc)->client);
> >              main_channel_push_agent_connected(reds->main_channel);
> >          }
> >      }
> > @@ -3050,13 +3050,13 @@ 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;
> >  
> >      if (state->priv->agent_attached) {
> > -        spice_char_device_state_reset_dev_instance(RED_CHAR_DEVICE(state),
> > sin);
> > +        red_char_device_reset_dev_instance(RED_CHAR_DEVICE(state), sin);
> >      } else {
> >          state->priv->agent_attached = TRUE;
> >          g_object_set(G_OBJECT(state), "sin", sin, NULL);
> > @@ -3086,16 +3086,16 @@ static SpiceCharDeviceState
> > *attach_to_red_agent(RedsState *reds, SpiceCharDevic
> >           * 2.b If this happens second ==> we already have spice migrate
> >           data
> >           *     then restore state
> >           */
> > -        if (!spice_char_device_client_exists(RED_CHAR_DEVICE(state),
> > reds_get_client(reds))) {
> > +        if (!red_char_device_client_exists(RED_CHAR_DEVICE(state),
> > reds_get_client(reds))) {
> >              int client_added;
> >  
> > -            client_added =
> > spice_char_device_client_add(RED_CHAR_DEVICE(state),
> > -
> > 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(RED_CHAR_DEVICE(state),
> > +
> > 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");
> > @@ -3125,10 +3125,10 @@ 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);
> > +    red_char_device_wakeup(sin->st);
> >  }
> >  
> >  #define SUBTYPE_VDAGENT "vdagent"
> > @@ -3150,20 +3150,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,
> > @@ -3171,7 +3171,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 = NULL;
> >  
> >      spice_info("CHAR_DEVICE %s", char_device->subtype);
> >      if (strcmp(char_device->subtype, SUBTYPE_VDAGENT) == 0) {
> > @@ -3179,34 +3179,34 @@ static int
> > spice_server_char_device_add_interface(SpiceServer *reds,
> >              spice_warning("vdagent already attached");
> >              return -1;
> >          }
> > -        dev_state = attach_to_red_agent(reds, char_device);
> > +        dev = attach_to_red_agent(reds, char_device);
> >      }
> >  #ifdef USE_SMARTCARD
> >      else if (strcmp(char_device->subtype, SUBTYPE_SMARTCARD) == 0) {
> > -        if (!(dev_state = smartcard_device_connect(reds, char_device))) {
> > +        if (!(dev = smartcard_device_connect(reds, char_device))) {
> >              return -1;
> >          }
> >      }
> >  #endif
> >      else if (strcmp(char_device->subtype, SUBTYPE_USBREDIR) == 0) {
> > -        dev_state = spicevmc_device_connect(reds, char_device,
> > SPICE_CHANNEL_USBREDIR);
> > +        dev = spicevmc_device_connect(reds, char_device,
> > SPICE_CHANNEL_USBREDIR);
> >      }
> >      else if (strcmp(char_device->subtype, SUBTYPE_PORT) == 0) {
> >          if (strcmp(char_device->portname, "org.spice-space.webdav.0") ==
> >          0) {
> > -            dev_state = spicevmc_device_connect(reds, char_device,
> > SPICE_CHANNEL_WEBDAV);
> > +            dev = spicevmc_device_connect(reds, char_device,
> > SPICE_CHANNEL_WEBDAV);
> >          } else {
> > -            dev_state = spicevmc_device_connect(reds, char_device,
> > SPICE_CHANNEL_PORT);
> > +            dev = spicevmc_device_connect(reds, char_device,
> > SPICE_CHANNEL_PORT);
> >          }
> >      }
> >  
> > -    if (dev_state) {
> > +    if (dev) {
> >          spice_assert(char_device->st);
> >          /* 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_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;
> > @@ -3366,7 +3366,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");
> > @@ -4020,7 +4020,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);
> > +        red_char_device_start(it->data);
> >      }
> >      reds_on_vm_start(reds);
> >  }
> > @@ -4031,7 +4031,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);
> > +        red_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 3d40f59..228e2b9 100644
> > --- a/server/smartcard.c
> > +++ b/server/smartcard.c
> > @@ -238,7 +238,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;
> > @@ -263,7 +263,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];
> >          }
> > @@ -294,7 +294,7 @@ void
> > smartcard_device_disconnect(SpiceCharDeviceInstance *char_device)
> >      g_object_unref(char_device);
> >  }
> >  
> > -SpiceCharDeviceState *smartcard_device_connect(RedsState *reds,
> > SpiceCharDeviceInstance *char_device)
> > +RedCharDevice *smartcard_device_connect(RedsState *reds,
> > SpiceCharDeviceInstance *char_device)
> >  {
> >      SmartCardDeviceState *st;
> >  
> > @@ -311,7 +311,7 @@ static void
> > smartcard_char_device_notify_reader_add(SmartCardDeviceState *st)
> >      SpiceCharDeviceWriteBuffer *write_buf;
> >      VSCMsgHeader *vheader;
> >  
> > -    write_buf = spice_char_device_write_buffer_get(RED_CHAR_DEVICE(st),
> > NULL, sizeof(vheader));
> > +    write_buf = red_char_device_write_buffer_get(RED_CHAR_DEVICE(st),
> > NULL, sizeof(vheader));
> >      if (!write_buf) {
> >          spice_error("failed to allocate write buffer");
> >          return;
> > @@ -327,20 +327,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(RED_CHAR_DEVICE(st),
> > -                                                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(RED_CHAR_DEVICE(st),
> > +                                              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;
> > @@ -358,7 +358,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(RED_CHAR_DEVICE(st),
> > NULL, sizeof(vheader));
> > +    write_buf = red_char_device_write_buffer_get(RED_CHAR_DEVICE(st),
> > NULL, sizeof(vheader));
> >      if (!write_buf) {
> >          spice_error("failed to allocate write buffer");
> >          return;
> > @@ -380,7 +380,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, scc->base.client);
> > +    red_char_device_client_remove(RED_CHAR_DEVICE(st), scc->base.client);
> >      scc->smartcard_state = NULL;
> >      st->priv->scc = NULL;
> >  }
> > @@ -409,7 +409,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(RED_CHAR_DEVICE(st), rcc->client,
> > size);
> > +        scc->write_buf =
> > red_char_device_write_buffer_get(RED_CHAR_DEVICE(st), rcc->client, size);
> >  
> >          if (!scc->write_buf) {
> >              spice_error("failed to allocate write buffer");
> > @@ -437,7 +437,7 @@ static void
> > smartcard_channel_release_msg_rcv_buf(RedChannelClient *rcc,
> >      } else {
> >          if (scc->write_buf) { /* msg hasn't been pushed to the guest */
> >              spice_assert(scc->write_buf->buf == msg);
> > -
> > spice_char_device_write_buffer_release(RED_CHAR_DEVICE(scc->smartcard_state),
> > scc->write_buf);
> > +
> > red_char_device_write_buffer_release(RED_CHAR_DEVICE(scc->smartcard_state),
> > scc->write_buf);
> >              scc->write_buf = NULL;
> >          }
> >      }
> > @@ -485,13 +485,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(RED_CHAR_DEVICE(state),
> > m);
> > +        red_char_device_migrate_data_marshall(RED_CHAR_DEVICE(state), 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);
> > @@ -601,7 +601,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);
> > @@ -642,7 +642,7 @@ static void
> > smartcard_channel_write_to_reader(SpiceCharDeviceWriteBuffer *write_
> >  
> >      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);
> > @@ -651,7 +651,7 @@ static void
> > smartcard_channel_write_to_reader(SpiceCharDeviceWriteBuffer *write_
> >      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;
> >      }
> > @@ -719,7 +719,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(RED_CHAR_DEVICE(scc->smartcard_state),
> > &mig_data->base);
> > +    return red_char_device_restore(RED_CHAR_DEVICE(scc->smartcard_state),
> > &mig_data->base);
> >  }
> >  
> >  static int smartcard_channel_handle_message(RedChannelClient *rcc,
> > diff --git a/server/smartcard.h b/server/smartcard.h
> > index 4b00433..d266ce2 100644
> > --- a/server/smartcard.h
> > +++ b/server/smartcard.h
> > @@ -49,7 +49,7 @@ GType red_char_device_smartcard_get_type(void)
> > G_GNUC_CONST;
> >  /*
> >   * 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 3c446a4..0d53285 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;
> >      SpiceCharDeviceWriteBuffer *recv_from_client_buf;
> >      uint8_t port_opened;
> > @@ -255,16 +255,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);
> > +        red_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 (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_st);
> > +                           rcc->client, state->chardev);
> >          }
> >      }
> >  
> > @@ -310,7 +310,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 red_char_device_restore(state->chardev, &mig_data->base);
> >  }
> >  
> >  static int spicevmc_red_channel_client_handle_message(RedChannelClient
> >  *rcc,
> > @@ -328,7 +328,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);
> > +        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:
> > @@ -358,9 +358,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_st,
> > -
> > 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;
> > @@ -385,7 +385,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);
> > +            red_char_device_write_buffer_release(state->chardev,
> > state->recv_from_client_buf);
> >              state->recv_from_client_buf = NULL;
> >          }
> >          break;
> > @@ -421,7 +421,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);
> > +    red_char_device_migrate_data_marshall(state->chardev, m);
> >  }
> >  
> >  static void spicevmc_red_channel_send_port_init(RedChannelClient *rcc,
> > @@ -521,8 +521,8 @@ 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,
> > -
> > 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;
> > @@ -534,9 +534,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;
> > @@ -564,11 +564,11 @@ SpiceCharDeviceState
> > *spicevmc_device_connect(RedsState *reds,
> >      client_cbs.connect = spicevmc_connect;
> >      red_channel_register_client_cbs(&state->channel, &client_cbs, NULL);
> >  
> > -    state->chardev_st = red_char_device_spicevmc_new(sin, reds, state);
> > +    state->chardev = red_char_device_spicevmc_new(sin, reds, 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. */
> > @@ -576,13 +576,13 @@ void spicevmc_device_disconnect(RedsState *reds,
> > SpiceCharDeviceInstance *sin)
> >  {
> >      SpiceVmcState *state;
> >  
> > -    state = (SpiceVmcState *)spice_char_device_state_opaque_get(sin->st);
> > +    state = (SpiceVmcState *)red_char_device_opaque_get(sin->st);
> >  
> >      if (state->recv_from_client_buf) {
> > -        spice_char_device_write_buffer_release(state->chardev_st,
> > state->recv_from_client_buf);
> > +        red_char_device_write_buffer_release(state->chardev,
> > state->recv_from_client_buf);
> >      }
> > -    spice_char_device_state_destroy(sin->st);
> > -    state->chardev_st = NULL;
> > +    red_char_device_destroy(sin->st);
> > +    state->chardev = NULL;
> >      sin->st = NULL;
> >  
> >      reds_unregister_channel(reds, &state->channel);
> > @@ -594,11 +594,11 @@ SPICE_GNUC_VISIBLE void
> > spice_server_port_event(SpiceCharDeviceInstance *sin, ui
> >      SpiceVmcState *state;
> >  
> >      if (sin->st == NULL) {
> > -        spice_warning("no SpiceCharDeviceState attached to instance %p",
> > sin);
> > +        spice_warning("no RedCharDevice attached to instance %p", sin);
> >          return;
> >      }
> >  
> > -    state = (SpiceVmcState *)spice_char_device_state_opaque_get(sin->st);
> > +    state = (SpiceVmcState *)red_char_device_opaque_get(sin->st);
> >      if (event == SPICE_PORT_EVENT_OPENED) {
> >          state->port_opened = TRUE;
> >      } else if (event == SPICE_PORT_EVENT_CLOSED) {
> > --
> > 2.4.3
> > 
> > _______________________________________________
> > Spice-devel mailing list
> > Spice-devel@xxxxxxxxxxxxxxxxxxxxx
> > https://lists.freedesktop.org/mailman/listinfo/spice-devel
> _______________________________________________
> Spice-devel mailing list
> Spice-devel@xxxxxxxxxxxxxxxxxxxxx
> https://lists.freedesktop.org/mailman/listinfo/spice-devel
> 
_______________________________________________
Spice-devel mailing list
Spice-devel@xxxxxxxxxxxxxxxxxxxxx
https://lists.freedesktop.org/mailman/listinfo/spice-devel




[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Security]     [Bugtraq]     [Linux]     [Linux OMAP]     [Linux MIPS]     [ECOS]     [Asterisk Internet PBX]     [Linux API]     [Monitors]