Re: [Spice-devel] [PATCH 2/3] char-device: add 'self' param to vfuncs

2016-11-03 Thread Pavel Grunt
On Thu, 2016-11-03 at 06:43 -0400, Frediano Ziglio wrote:
> > 
> > Hi, it looks good to me, just an extra line addition in
> > red_vmc_channel_class_init
> > 
> > Ack
> > 
> > Pavel
> > 
> 
> Guy, how do you test? I just launched a VM and got 3, not 1
> critical messages...
> 
I got one


> Frediano
> 
> > On Wed, 2016-11-02 at 16:25 -0500, Jonathon Jongsma wrote:
> > > Add a 'self' parameter to all of the char device virtual
> > > functions
> > > so
> > > that we don't have to play games with the 'opaque' pointer.
> > > ---
> > >  server/char-device.c  | 31 ++---
> > >  server/char-device.h  | 20 
> > >  server/reds.c | 23 ++
> > >  server/smartcard-channel-client.c |  2 +-
> > >  server/smartcard.c| 32 ++---
> > >  server/spicevmc.c | 96
> > > ---
> > >  6 files changed, 124 insertions(+), 80 deletions(-)
> > > 
> > > diff --git a/server/char-device.c b/server/char-device.c
> > > index 318bf3c..3b70066 100644
> > > --- a/server/char-device.c
> > > +++ b/server/char-device.c
> > > @@ -66,7 +66,6 @@ struct RedCharDevicePrivate {
> > >  int during_read_from_device;
> > >  int during_write_to_device;
> > >  
> > > -void *opaque;
> > >  SpiceServer *reds;
> > >  };
> > >  
> > > @@ -88,7 +87,6 @@ enum {
> > >  PROP_SPICE_SERVER,
> > >  PROP_CLIENT_TOKENS_INTERVAL,
> > >  PROP_SELF_TOKENS,
> > > -PROP_OPAQUE
> > >  };
> > >  
> > >  static void
> > > red_char_device_write_buffer_unref(RedCharDeviceWriteBuffer
> > > *write_buf);
> > > @@ -99,7 +97,7 @@
> > > red_char_device_read_one_msg_from_device(RedCharDevice *dev)
> > >  {
> > > RedCharDeviceClass *klass = RED_CHAR_DEVICE_GET_CLASS(dev);
> > >  
> > > -   return klass->read_one_msg_from_device(dev->priv->sin, dev-
> > > > priv->opaque);
> > > 
> > > +   return klass->read_one_msg_from_device(dev, dev->priv->sin);
> > >  }
> > >  
> > >  static void
> > > @@ -109,7 +107,7 @@
> > > red_char_device_send_msg_to_client(RedCharDevice
> > > *dev,
> > >  {
> > > RedCharDeviceClass *klass = RED_CHAR_DEVICE_GET_CLASS(dev);
> > >  
> > > -   klass->send_msg_to_client(msg, client, dev->priv->opaque);
> > > +   klass->send_msg_to_client(dev, msg, client);
> > >  }
> > >  
> > >  static void
> > > @@ -119,7 +117,7 @@
> > > red_char_device_send_tokens_to_client(RedCharDevice *dev,
> > >  {
> > > RedCharDeviceClass *klass = RED_CHAR_DEVICE_GET_CLASS(dev);
> > >  
> > > -   klass->send_tokens_to_client(client, tokens, dev->priv-
> > > >opaque);
> > > +   klass->send_tokens_to_client(dev, client, tokens);
> > >  }
> > >  
> > >  static void
> > > @@ -128,7 +126,7 @@
> > > red_char_device_on_free_self_token(RedCharDevice
> > > *dev)
> > > RedCharDeviceClass *klass = RED_CHAR_DEVICE_GET_CLASS(dev);
> > >  
> > > if (klass->on_free_self_token != NULL) {
> > > -   klass->on_free_self_token(dev->priv->opaque);
> > > +   klass->on_free_self_token(dev);
> > > }
> > >  }
> > >  
> > > @@ -137,7 +135,7 @@ red_char_device_remove_client(RedCharDevice
> > > *dev, RedClient *client)
> > >  {
> > > RedCharDeviceClass *klass = RED_CHAR_DEVICE_GET_CLASS(dev);
> > >  
> > > -   klass->remove_client(client, dev->priv->opaque);
> > > +   klass->remove_client(dev, client);
> > >  }
> > >  
> > >  static void
> > > red_char_device_write_buffer_free(RedCharDeviceWriteBuffer *buf)
> > > @@ -686,11 +684,6 @@ void
> > > red_char_device_reset_dev_instance(RedCharDevice *dev,
> > >  g_object_notify(G_OBJECT(dev), "sin");
> > >  }
> > >  
> > > -void *red_char_device_opaque_get(RedCharDevice *dev)
> > > -{
> > > -return dev->priv->opaque;
> > > -}
> > > -
> > >  void red_char_device_destroy(RedCharDevice *char_dev)
> > >  {
> > >  g_return_if_fail(RED_IS_CHAR_DEVICE(char_dev));
> > > @@ -1041,9 +1034,6 @@
> > > red_char_device_get_property(GObject*object,
> > >  case PROP_SELF_TOKENS:
> > >  g_value_set_uint64(value, self->priv-
> > > >num_self_tokens);
> > >  break;
> > > -case PROP_OPAQUE:
> > > -g_value_set_pointer(value, self->priv->opaque);
> > > -break;
> > >  default:
> > >  G_OBJECT_WARN_INVALID_PROPERTY_ID(object,
> > > property_id,
> > > pspec);
> > >  }
> > > @@ -1071,9 +1061,6 @@
> > > red_char_device_set_property(GObject  *object,
> > >  case PROP_SELF_TOKENS:
> > >  self->priv->num_self_tokens =
> > > g_value_get_uint64(value);
> > >  break;
> > > -case PROP_OPAQUE:
> > > -self->priv->opaque = g_value_get_pointer(value);
> > > -break;
> > >  default:
> > >  G_OBJECT_WARN_INVALID_PROPERTY_ID(object,
> > > property_id,
> > > pspec);
> > >  }
> > > @@ -1156,14 +1143,6 @@
> > > red_char_device_class_init(RedCharDeviceClass
> > > *klass)
> > >   

Re: [Spice-devel] [PATCH 2/3] char-device: add 'self' param to vfuncs

2016-11-03 Thread Pavel Grunt
Hi, it looks good to me, just an extra line addition in
red_vmc_channel_class_init

Ack

Pavel

On Wed, 2016-11-02 at 16:25 -0500, Jonathon Jongsma wrote:
> Add a 'self' parameter to all of the char device virtual functions
> so
> that we don't have to play games with the 'opaque' pointer.
> ---
>  server/char-device.c  | 31 ++---
>  server/char-device.h  | 20 
>  server/reds.c | 23 ++
>  server/smartcard-channel-client.c |  2 +-
>  server/smartcard.c| 32 ++---
>  server/spicevmc.c | 96
> ---
>  6 files changed, 124 insertions(+), 80 deletions(-)
> 
> diff --git a/server/char-device.c b/server/char-device.c
> index 318bf3c..3b70066 100644
> --- a/server/char-device.c
> +++ b/server/char-device.c
> @@ -66,7 +66,6 @@ struct RedCharDevicePrivate {
>  int during_read_from_device;
>  int during_write_to_device;
>  
> -void *opaque;
>  SpiceServer *reds;
>  };
>  
> @@ -88,7 +87,6 @@ enum {
>  PROP_SPICE_SERVER,
>  PROP_CLIENT_TOKENS_INTERVAL,
>  PROP_SELF_TOKENS,
> -PROP_OPAQUE
>  };
>  
>  static void
> red_char_device_write_buffer_unref(RedCharDeviceWriteBuffer
> *write_buf);
> @@ -99,7 +97,7 @@
> red_char_device_read_one_msg_from_device(RedCharDevice *dev)
>  {
> RedCharDeviceClass *klass = RED_CHAR_DEVICE_GET_CLASS(dev);
>  
> -   return klass->read_one_msg_from_device(dev->priv->sin, dev-
> >priv->opaque);
> +   return klass->read_one_msg_from_device(dev, dev->priv->sin);
>  }
>  
>  static void
> @@ -109,7 +107,7 @@ red_char_device_send_msg_to_client(RedCharDevice
> *dev,
>  {
> RedCharDeviceClass *klass = RED_CHAR_DEVICE_GET_CLASS(dev);
>  
> -   klass->send_msg_to_client(msg, client, dev->priv->opaque);
> +   klass->send_msg_to_client(dev, msg, client);
>  }
>  
>  static void
> @@ -119,7 +117,7 @@
> red_char_device_send_tokens_to_client(RedCharDevice *dev,
>  {
> RedCharDeviceClass *klass = RED_CHAR_DEVICE_GET_CLASS(dev);
>  
> -   klass->send_tokens_to_client(client, tokens, dev->priv->opaque);
> +   klass->send_tokens_to_client(dev, client, tokens);
>  }
>  
>  static void
> @@ -128,7 +126,7 @@ red_char_device_on_free_self_token(RedCharDevice
> *dev)
> RedCharDeviceClass *klass = RED_CHAR_DEVICE_GET_CLASS(dev);
>  
> if (klass->on_free_self_token != NULL) {
> -   klass->on_free_self_token(dev->priv->opaque);
> +   klass->on_free_self_token(dev);
> }
>  }
>  
> @@ -137,7 +135,7 @@ red_char_device_remove_client(RedCharDevice
> *dev, RedClient *client)
>  {
> RedCharDeviceClass *klass = RED_CHAR_DEVICE_GET_CLASS(dev);
>  
> -   klass->remove_client(client, dev->priv->opaque);
> +   klass->remove_client(dev, client);
>  }
>  
>  static void
> red_char_device_write_buffer_free(RedCharDeviceWriteBuffer *buf)
> @@ -686,11 +684,6 @@ void
> red_char_device_reset_dev_instance(RedCharDevice *dev,
>  g_object_notify(G_OBJECT(dev), "sin");
>  }
>  
> -void *red_char_device_opaque_get(RedCharDevice *dev)
> -{
> -return dev->priv->opaque;
> -}
> -
>  void red_char_device_destroy(RedCharDevice *char_dev)
>  {
>  g_return_if_fail(RED_IS_CHAR_DEVICE(char_dev));
> @@ -1041,9 +1034,6 @@
> red_char_device_get_property(GObject*object,
>  case PROP_SELF_TOKENS:
>  g_value_set_uint64(value, self->priv->num_self_tokens);
>  break;
> -case PROP_OPAQUE:
> -g_value_set_pointer(value, self->priv->opaque);
> -break;
>  default:
>  G_OBJECT_WARN_INVALID_PROPERTY_ID(object, property_id,
> pspec);
>  }
> @@ -1071,9 +1061,6 @@
> red_char_device_set_property(GObject  *object,
>  case PROP_SELF_TOKENS:
>  self->priv->num_self_tokens =
> g_value_get_uint64(value);
>  break;
> -case PROP_OPAQUE:
> -self->priv->opaque = g_value_get_pointer(value);
> -break;
>  default:
>  G_OBJECT_WARN_INVALID_PROPERTY_ID(object, property_id,
> pspec);
>  }
> @@ -1156,14 +1143,6 @@ red_char_device_class_init(RedCharDeviceClass
> *klass)
>  0,
> G_MAXUINT64, 0,
>  G_PARAM_STA
> TIC_STRINGS |
>  G_PARAM_REA
> DWRITE));
> -g_object_class_install_property(object_class,
> -PROP_OPAQUE,
> -g_param_spec_pointer("opaque",
> - "opaque",
> - "User data
> to pass to callbacks",
> -  G_PARAM_STATI
> C_STRINGS |
> -  G_PARAM_READW
> RITE));
> -
>  }
>  
>  static void
> diff --git a/server/char-device.h 

[Spice-devel] [PATCH 2/3] char-device: add 'self' param to vfuncs

2016-11-02 Thread Jonathon Jongsma
Add a 'self' parameter to all of the char device virtual functions so
that we don't have to play games with the 'opaque' pointer.
---
 server/char-device.c  | 31 ++---
 server/char-device.h  | 20 
 server/reds.c | 23 ++
 server/smartcard-channel-client.c |  2 +-
 server/smartcard.c| 32 ++---
 server/spicevmc.c | 96 ---
 6 files changed, 124 insertions(+), 80 deletions(-)

diff --git a/server/char-device.c b/server/char-device.c
index 318bf3c..3b70066 100644
--- a/server/char-device.c
+++ b/server/char-device.c
@@ -66,7 +66,6 @@ struct RedCharDevicePrivate {
 int during_read_from_device;
 int during_write_to_device;
 
-void *opaque;
 SpiceServer *reds;
 };
 
@@ -88,7 +87,6 @@ enum {
 PROP_SPICE_SERVER,
 PROP_CLIENT_TOKENS_INTERVAL,
 PROP_SELF_TOKENS,
-PROP_OPAQUE
 };
 
 static void red_char_device_write_buffer_unref(RedCharDeviceWriteBuffer 
*write_buf);
@@ -99,7 +97,7 @@ red_char_device_read_one_msg_from_device(RedCharDevice *dev)
 {
RedCharDeviceClass *klass = RED_CHAR_DEVICE_GET_CLASS(dev);
 
-   return klass->read_one_msg_from_device(dev->priv->sin, dev->priv->opaque);
+   return klass->read_one_msg_from_device(dev, dev->priv->sin);
 }
 
 static void
@@ -109,7 +107,7 @@ red_char_device_send_msg_to_client(RedCharDevice *dev,
 {
RedCharDeviceClass *klass = RED_CHAR_DEVICE_GET_CLASS(dev);
 
-   klass->send_msg_to_client(msg, client, dev->priv->opaque);
+   klass->send_msg_to_client(dev, msg, client);
 }
 
 static void
@@ -119,7 +117,7 @@ red_char_device_send_tokens_to_client(RedCharDevice *dev,
 {
RedCharDeviceClass *klass = RED_CHAR_DEVICE_GET_CLASS(dev);
 
-   klass->send_tokens_to_client(client, tokens, dev->priv->opaque);
+   klass->send_tokens_to_client(dev, client, tokens);
 }
 
 static void
@@ -128,7 +126,7 @@ red_char_device_on_free_self_token(RedCharDevice *dev)
RedCharDeviceClass *klass = RED_CHAR_DEVICE_GET_CLASS(dev);
 
if (klass->on_free_self_token != NULL) {
-   klass->on_free_self_token(dev->priv->opaque);
+   klass->on_free_self_token(dev);
}
 }
 
@@ -137,7 +135,7 @@ red_char_device_remove_client(RedCharDevice *dev, RedClient 
*client)
 {
RedCharDeviceClass *klass = RED_CHAR_DEVICE_GET_CLASS(dev);
 
-   klass->remove_client(client, dev->priv->opaque);
+   klass->remove_client(dev, client);
 }
 
 static void red_char_device_write_buffer_free(RedCharDeviceWriteBuffer *buf)
@@ -686,11 +684,6 @@ void red_char_device_reset_dev_instance(RedCharDevice *dev,
 g_object_notify(G_OBJECT(dev), "sin");
 }
 
-void *red_char_device_opaque_get(RedCharDevice *dev)
-{
-return dev->priv->opaque;
-}
-
 void red_char_device_destroy(RedCharDevice *char_dev)
 {
 g_return_if_fail(RED_IS_CHAR_DEVICE(char_dev));
@@ -1041,9 +1034,6 @@ red_char_device_get_property(GObject*object,
 case PROP_SELF_TOKENS:
 g_value_set_uint64(value, self->priv->num_self_tokens);
 break;
-case PROP_OPAQUE:
-g_value_set_pointer(value, self->priv->opaque);
-break;
 default:
 G_OBJECT_WARN_INVALID_PROPERTY_ID(object, property_id, pspec);
 }
@@ -1071,9 +1061,6 @@ red_char_device_set_property(GObject  *object,
 case PROP_SELF_TOKENS:
 self->priv->num_self_tokens = g_value_get_uint64(value);
 break;
-case PROP_OPAQUE:
-self->priv->opaque = g_value_get_pointer(value);
-break;
 default:
 G_OBJECT_WARN_INVALID_PROPERTY_ID(object, property_id, pspec);
 }
@@ -1156,14 +1143,6 @@ red_char_device_class_init(RedCharDeviceClass *klass)
 0, G_MAXUINT64, 0,
 G_PARAM_STATIC_STRINGS 
|
 G_PARAM_READWRITE));
-g_object_class_install_property(object_class,
-PROP_OPAQUE,
-g_param_spec_pointer("opaque",
- "opaque",
- "User data to pass to 
callbacks",
-  G_PARAM_STATIC_STRINGS |
-  G_PARAM_READWRITE));
-
 }
 
 static void
diff --git a/server/char-device.h b/server/char-device.h
index 44e9504..3b87023 100644
--- a/server/char-device.h
+++ b/server/char-device.h
@@ -56,25 +56,27 @@ struct RedCharDeviceClass
 
 /* reads from the device till reaching a msg that should be sent to the 
client,
  * or till the reading fails */
-RedPipeItem* (*read_one_msg_from_device)(SpiceCharDeviceInstance *sin,
- void *opaque);
+RedPipeItem*