[Spice-commits] 4 commits - server/char-device.c server/reds.c

Jonathon Jongsma jjongsma at kemper.freedesktop.org
Wed Apr 20 19:29:58 UTC 2016


 server/char-device.c |   24 +++++++++++++-----------
 server/reds.c        |    6 ++++--
 2 files changed, 17 insertions(+), 13 deletions(-)

New commits:
commit 0f947b425cc2219f3c5a8705f4214c2deb607a5b
Author: Christophe Fergeau <cfergeau at redhat.com>
Date:   Thu Apr 7 17:11:25 2016 -0500

    Remove use of opaque from vdi_port_read_one_msg_from_device
    
    We can get 'reds' from the RedCharDevice accessible from the
    SpiceCharDeviceInstance passed as an argument.
    
    Acked-by: Pavel Grunt <pgrunt at redhat.com>
    Acked-by: Frediano Ziglio <fziglio at redhat.com>

diff --git a/server/reds.c b/server/reds.c
index 6e4fee4..440f70e 100644
--- a/server/reds.c
+++ b/server/reds.c
@@ -786,12 +786,14 @@ static void vdi_port_read_buf_free(VDIReadBuf *buf)
 static PipeItem *vdi_port_read_one_msg_from_device(SpiceCharDeviceInstance *sin,
                                                    void *opaque)
 {
-    RedsState *reds = opaque;
-    RedCharDeviceVDIPort *dev = reds->agent_dev;
+    RedsState *reds;
+    RedCharDeviceVDIPort *dev = RED_CHAR_DEVICE_VDIPORT(sin->st);
     SpiceCharDeviceInterface *sif;
     VDIReadBuf *dispatch_buf;
     int n;
 
+    g_object_get(dev, "spice-server", &reds, NULL);
+    g_assert(RED_CHAR_DEVICE(reds->agent_dev) == sin->st);
     if (!reds->vdagent) {
         return NULL;
     }
commit 39b00dc71e786f564b7de361c9710a13cd7196a1
Author: Jonathon Jongsma <jjongsma at redhat.com>
Date:   Wed Apr 13 10:46:16 2016 -0500

    char device: use _reset_dev_instance() to set 'sin'
    
    Internally, use the method to set the 'sin' member variable so that we
    don't have to duplicate the g_object_notify() calls, and there are
    consistent debug statements whenever this value is modified. This also
    means that we need to handle NULL arguments to this function.
    
    Acked-by: Frediano Ziglio <fziglio at redhat.com>

diff --git a/server/char-device.c b/server/char-device.c
index cbb139e..0495cc2 100644
--- a/server/char-device.c
+++ b/server/char-device.c
@@ -724,7 +724,8 @@ void red_char_device_reset_dev_instance(RedCharDevice *dev,
 {
     spice_debug("sin %p, char device %p", sin, dev);
     dev->priv->sin = sin;
-    sin->st = dev;
+    if (sin)
+        sin->st = dev;
     g_object_notify(G_OBJECT(dev), "sin");
 }
 
@@ -885,8 +886,7 @@ void red_char_device_reset(RedCharDevice *dev)
         dev_client = SPICE_CONTAINEROF(client_item, RedCharDeviceClient, link);
         red_char_device_client_send_queue_free(dev, dev_client);
     }
-    dev->priv->sin = NULL;
-    g_object_notify(G_OBJECT(dev), "sin");
+    red_char_device_reset_dev_instance(dev, NULL);
 }
 
 void red_char_device_wakeup(RedCharDevice *dev)
@@ -1109,7 +1109,7 @@ red_char_device_set_property(GObject      *object,
     switch (property_id)
     {
         case PROP_CHAR_DEV_INSTANCE:
-            self->priv->sin = g_value_get_pointer(value);
+            red_char_device_reset_dev_instance(self, g_value_get_pointer(value));
             break;
         case PROP_SPICE_SERVER:
             self->priv->reds = g_value_get_pointer(value);
commit 82024257b6a79744455a7c9678ce69cab5c40ccf
Author: Jonathon Jongsma <jjongsma at redhat.com>
Date:   Wed Apr 13 10:43:54 2016 -0500

    char device: use 'device' rather than 'state' for var names
    
    Since the type name was changed, use variable names / debug statements
    that are consistent with the new name.
    
    Acked-by: Frediano Ziglio <fziglio at redhat.com>

diff --git a/server/char-device.c b/server/char-device.c
index a618115..cbb139e 100644
--- a/server/char-device.c
+++ b/server/char-device.c
@@ -719,13 +719,13 @@ void red_char_device_write_buffer_release(RedCharDevice *dev,
  * char_device_state management *
  ********************************/
 
-void red_char_device_reset_dev_instance(RedCharDevice *state,
+void red_char_device_reset_dev_instance(RedCharDevice *dev,
                                         SpiceCharDeviceInstance *sin)
 {
-    spice_debug("sin %p dev_state %p", sin, state);
-    state->priv->sin = sin;
-    sin->st = state;
-    g_object_notify(G_OBJECT(state), "sin");
+    spice_debug("sin %p, char device %p", sin, dev);
+    dev->priv->sin = sin;
+    sin->st = dev;
+    g_object_notify(G_OBJECT(dev), "sin");
 }
 
 void *red_char_device_opaque_get(RedCharDevice *dev)
@@ -791,7 +791,7 @@ int red_char_device_client_add(RedCharDevice *dev,
 
     dev->priv->wait_for_migrate_data = wait_for_migrate_data;
 
-    spice_debug("dev_state %p client %p", dev, client);
+    spice_debug("char device %p, client %p", dev, client);
     dev_client = red_char_device_client_new(client, do_flow_control,
                                             max_send_queue_size,
                                             num_client_tokens,
@@ -809,7 +809,7 @@ void red_char_device_client_remove(RedCharDevice *dev,
 {
     RedCharDeviceClient *dev_client;
 
-    spice_debug("dev_state %p client %p", dev, client);
+    spice_debug("char device %p, client %p", dev, client);
     dev_client = red_char_device_client_find(dev, client);
 
     if (!dev_client) {
@@ -838,7 +838,7 @@ int red_char_device_client_exists(RedCharDevice *dev,
 
 void red_char_device_start(RedCharDevice *dev)
 {
-    spice_debug("dev_state %p", dev);
+    spice_debug("char device %p", dev);
     dev->priv->running = TRUE;
     g_object_ref(dev);
     while (red_char_device_write_to_device(dev) ||
@@ -848,7 +848,7 @@ void red_char_device_start(RedCharDevice *dev)
 
 void red_char_device_stop(RedCharDevice *dev)
 {
-    spice_debug("dev_state %p", dev);
+    spice_debug("char device %p", dev);
     dev->priv->running = FALSE;
     dev->priv->active = FALSE;
     if (dev->priv->write_to_dev_timer) {
@@ -862,7 +862,7 @@ void red_char_device_reset(RedCharDevice *dev)
 
     red_char_device_stop(dev);
     dev->priv->wait_for_migrate_data = FALSE;
-    spice_debug("dev_state %p", dev);
+    spice_debug("char device %p", dev);
     while (!ring_is_empty(&dev->priv->write_queue)) {
         RingItem *item = ring_get_tail(&dev->priv->write_queue);
         RedCharDeviceWriteBuffer *buf;
commit c28773f17aa8ce8dbf0ea97de6c07af8a1312a96
Author: Jonathon Jongsma <jjongsma at redhat.com>
Date:   Wed Apr 13 10:39:51 2016 -0500

    char-device: notify when device instance is changed
    
    Since the device instance ("sin") is a gobject property, we should make
    sure to notify when it changes, particularly since we do some
    initialization in response to the "notify::sin" signal.
    
    Acked-by: Frediano Ziglio <fziglio at redhat.com>

diff --git a/server/char-device.c b/server/char-device.c
index ebe7633..a618115 100644
--- a/server/char-device.c
+++ b/server/char-device.c
@@ -725,6 +725,7 @@ void red_char_device_reset_dev_instance(RedCharDevice *state,
     spice_debug("sin %p dev_state %p", sin, state);
     state->priv->sin = sin;
     sin->st = state;
+    g_object_notify(G_OBJECT(state), "sin");
 }
 
 void *red_char_device_opaque_get(RedCharDevice *dev)
@@ -885,6 +886,7 @@ void red_char_device_reset(RedCharDevice *dev)
         red_char_device_client_send_queue_free(dev, dev_client);
     }
     dev->priv->sin = NULL;
+    g_object_notify(G_OBJECT(dev), "sin");
 }
 
 void red_char_device_wakeup(RedCharDevice *dev)


More information about the Spice-commits mailing list