Re: [PATCH v2 03/15] Rename SpiceCharDeviceState to RedCharDevice

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

 



> 
> This is more consistent with internal type naming convention, and it
> paves the way for a new char device GObject heirarchy
> ---
>  server/char-device.c  | 107
>  +++++++++++++++++++++++++-------------------------
>  server/char-device.h  |  58 ++++++++++++++-------------
>  server/reds-private.h |   2 +-
>  server/reds.c         |  34 ++++++++--------
>  server/reds.h         |   3 +-
>  server/smartcard.c    |  40 +++++++++----------
>  server/smartcard.h    |   2 +-
>  server/spicevmc.c     |  57 ++++++++++++++-------------
>  8 files changed, 155 insertions(+), 148 deletions(-)
> 
> diff --git a/server/char-device.c b/server/char-device.c
> index ea1fb17..0ee833f 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;
> @@ -241,12 +242,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;
> @@ -278,7 +279,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;
> @@ -303,7 +304,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) {
> @@ -322,7 +323,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;
> @@ -343,7 +344,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;
> @@ -416,7 +417,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) {
> @@ -435,7 +436,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)
>  {
> @@ -450,7 +451,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)
>  {
> @@ -471,7 +472,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)
>  {
> @@ -491,7 +492,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;
> @@ -566,7 +567,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);
> @@ -575,7 +576,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;
> @@ -634,7 +635,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)
>  {
> @@ -644,7 +645,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);
> @@ -667,7 +668,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);
> @@ -683,7 +684,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;
> @@ -718,14 +719,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);
> @@ -733,7 +734,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;
> @@ -760,7 +761,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);
> @@ -768,17 +769,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
> @@ -792,7 +793,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) {
> @@ -848,7 +849,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,
> @@ -882,7 +883,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;
> @@ -908,13 +909,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;
> @@ -924,7 +925,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;
> @@ -934,7 +935,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;
>  
> @@ -966,7 +967,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);
> @@ -995,7 +996,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;
> @@ -1055,7 +1056,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;
> @@ -1106,7 +1107,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) {

Acked-by: Frediano Ziglio <fziglio@xxxxxxxxxx>

Frediano
_______________________________________________
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]