[Spice-commits] 6 commits - server/dispatcher.c server/dispatcher.h server/main-dispatcher.c server/red-qxl.c server/red-qxl.h server/reds.c server/spice-qxl.h

Frediano Ziglio fziglio at kemper.freedesktop.org
Thu Sep 7 15:14:11 UTC 2017


 server/dispatcher.c      |   22 +----------------
 server/dispatcher.h      |    2 -
 server/main-dispatcher.c |    6 ++--
 server/red-qxl.c         |   59 +++++++++++++++++++++++------------------------
 server/red-qxl.h         |    1 
 server/reds.c            |    2 -
 server/spice-qxl.h       |    6 +++-
 7 files changed, 40 insertions(+), 58 deletions(-)

New commits:
commit 037dedf5f6d2613cc43813aeb9e354e517c38b42
Author: Frediano Ziglio <fziglio at redhat.com>
Date:   Thu Sep 7 12:32:10 2017 +0100

    main-dispatcher: Avoid type conversion in dispatcher_handle_read
    
    Pass proper type to callback to avoid having to convert to
    the right type for each call.
    
    Signed-off-by: Frediano Ziglio <fziglio at redhat.com>
    Acked-by: Christophe Fergeau <cfergeau at redhat.com>

diff --git a/server/main-dispatcher.c b/server/main-dispatcher.c
index 019bf4d3..71f8f65d 100644
--- a/server/main-dispatcher.c
+++ b/server/main-dispatcher.c
@@ -280,9 +280,9 @@ void main_dispatcher_client_disconnect(MainDispatcher *self, RedClient *client)
 
 static void dispatcher_handle_read(int fd, int event, void *opaque)
 {
-    MainDispatcher *self = opaque;
+    Dispatcher *dispatcher = opaque;
 
-    dispatcher_handle_recv_read(DISPATCHER(self));
+    dispatcher_handle_recv_read(dispatcher);
 }
 
 /*
@@ -311,7 +311,7 @@ void main_dispatcher_constructed(GObject *object)
         self->priv->core->watch_add(self->priv->core,
                                     dispatcher_get_recv_fd(DISPATCHER(self)),
                                     SPICE_WATCH_EVENT_READ, dispatcher_handle_read,
-                                    self);
+                                    DISPATCHER(self));
     dispatcher_register_handler(DISPATCHER(self), MAIN_DISPATCHER_CHANNEL_EVENT,
                                 main_dispatcher_handle_channel_event,
                                 sizeof(MainDispatcherChannelEventMessage), 0 /* no ack */);
commit 343cac8d6df6065ad9bf2fd651846051db994318
Author: Frediano Ziglio <fziglio at redhat.com>
Date:   Thu Sep 7 07:28:20 2017 +0100

    dispatcher: Remove "opaque" property
    
    Is supposed to be used during initialization but is never
    used.
    
    Signed-off-by: Frediano Ziglio <fziglio at redhat.com>
    Acked-by: Christophe Fergeau <cfergeau at redhat.com>

diff --git a/server/dispatcher.c b/server/dispatcher.c
index 6f2c4d85..9e02d901 100644
--- a/server/dispatcher.c
+++ b/server/dispatcher.c
@@ -66,8 +66,7 @@ struct DispatcherPrivate {
 
 enum {
     PROP_0,
-    PROP_MAX_MESSAGE_TYPE,
-    PROP_OPAQUE
+    PROP_MAX_MESSAGE_TYPE
 };
 
 static void
@@ -83,9 +82,6 @@ dispatcher_get_property(GObject    *object,
         case PROP_MAX_MESSAGE_TYPE:
             g_value_set_uint(value, self->priv->max_message_type);
             break;
-        case PROP_OPAQUE:
-            g_value_set_pointer(value, self->priv->opaque);
-            break;
         default:
             G_OBJECT_WARN_INVALID_PROPERTY_ID(object, property_id, pspec);
     }
@@ -104,9 +100,6 @@ dispatcher_set_property(GObject      *object,
         case PROP_MAX_MESSAGE_TYPE:
             self->priv->max_message_type = g_value_get_uint(value);
             break;
-        case PROP_OPAQUE:
-            dispatcher_set_opaque(self, g_value_get_pointer(value));
-            break;
         default:
             G_OBJECT_WARN_INVALID_PROPERTY_ID(object, property_id, pspec);
     }
@@ -168,15 +161,6 @@ dispatcher_class_init(DispatcherClass *klass)
                                                       G_PARAM_STATIC_STRINGS |
                                                       G_PARAM_READWRITE |
                                                       G_PARAM_CONSTRUCT_ONLY));
-    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 |
-                                                         G_PARAM_CONSTRUCT));
-
 }
 
 static void
@@ -186,11 +170,10 @@ dispatcher_init(Dispatcher *self)
 }
 
 Dispatcher *
-dispatcher_new(size_t max_message_type, void *opaque)
+dispatcher_new(size_t max_message_type)
 {
     return g_object_new(TYPE_DISPATCHER,
                         "max-message-type", (guint) max_message_type,
-                        "opaque", opaque,
                         NULL);
 }
 
@@ -419,7 +402,6 @@ static void setup_dummy_signal_handler(void)
 void dispatcher_set_opaque(Dispatcher *self, void *opaque)
 {
     self->priv->opaque = opaque;
-    g_object_notify(G_OBJECT(self), "opaque");
 }
 
 int dispatcher_get_recv_fd(Dispatcher *dispatcher)
diff --git a/server/dispatcher.h b/server/dispatcher.h
index 97b01de9..00a828bd 100644
--- a/server/dispatcher.h
+++ b/server/dispatcher.h
@@ -49,7 +49,7 @@ struct DispatcherClass
 
 GType dispatcher_get_type(void) G_GNUC_CONST;
 
-Dispatcher *dispatcher_new(size_t max_message_type, void *opaque);
+Dispatcher *dispatcher_new(size_t max_message_type);
 
 
 typedef void (*dispatcher_handle_message)(void *opaque,
diff --git a/server/red-qxl.c b/server/red-qxl.c
index a619741b..4ef29306 100644
--- a/server/red-qxl.c
+++ b/server/red-qxl.c
@@ -940,7 +940,7 @@ void red_qxl_init(RedsState *reds, QXLInstance *qxl)
     pthread_mutex_init(&qxl_state->scanout_mutex, NULL);
     qxl_state->scanout.drm_dma_buf_fd = -1;
     qxl_state->gl_draw_cookie = GL_DRAW_COOKIE_INVALID;
-    qxl_state->dispatcher = dispatcher_new(RED_WORKER_MESSAGE_COUNT, NULL);
+    qxl_state->dispatcher = dispatcher_new(RED_WORKER_MESSAGE_COUNT);
     qxl_state->qxl_worker.major_version = SPICE_INTERFACE_QXL_MAJOR;
     qxl_state->qxl_worker.minor_version = SPICE_INTERFACE_QXL_MINOR;
     qxl_state->qxl_worker.wakeup = qxl_worker_wakeup;
commit dfdc8e309702a901c8469dc19ac6a4b3a25165ab
Author: Frediano Ziglio <fziglio at redhat.com>
Date:   Wed Sep 6 21:14:55 2017 +0100

    red-qxl: Avoid to use AsyncCommand for GL_DRAW_ASYNC message
    
    AsyncCommand is used to handle asynchronous messages from the
    dispatcher.
    GL_DRAW_ASYNC is mainly using it to store the cookie.
    
    The value of GL_DRAW_COOKIE_INVALID was choosen to allow implementing
    cookies (which basically are handles) either using indexes (where 0 is
    valid) or pointers (where 0 is invalid). Currently Qemu uses pointers.
    
    Signed-off-by: Frediano Ziglio <fziglio at redhat.com>
    Acked-by: Christophe Fergeau <cfergeau at redhat.com>

diff --git a/server/red-qxl.c b/server/red-qxl.c
index bec063c1..a619741b 100644
--- a/server/red-qxl.c
+++ b/server/red-qxl.c
@@ -62,9 +62,11 @@ struct QXLState {
 
     pthread_mutex_t scanout_mutex;
     SpiceMsgDisplayGlScanoutUnix scanout;
-    struct AsyncCommand *gl_draw_async;
+    uint64_t gl_draw_cookie;
 };
 
+#define GL_DRAW_COOKIE_INVALID (~((uint64_t) 0))
+
 int red_qxl_check_qxl_version(QXLInstance *qxl, int major, int minor)
 {
     int qxl_major = qxl_get_interface(qxl)->base.major_version;
@@ -833,7 +835,7 @@ void spice_qxl_gl_scanout(QXLInstance *qxl,
     spice_return_if_fail(qxl != NULL);
 
     QXLState *qxl_state = qxl->st;
-    spice_return_if_fail(qxl_state->gl_draw_async == NULL);
+    spice_return_if_fail(qxl_state->gl_draw_cookie == GL_DRAW_COOKIE_INVALID);
 
     pthread_mutex_lock(&qxl_state->scanout_mutex);
 
@@ -877,13 +879,15 @@ void spice_qxl_gl_draw_async(QXLInstance *qxl,
     spice_return_if_fail(qxl != NULL);
     qxl_state = qxl->st;
     if (qxl_state->scanout.drm_dma_buf_fd == -1) {
+        QXLInterface *interface = qxl_get_interface(qxl);
+
         spice_warning("called spice_qxl_gl_draw_async without a buffer");
-        red_qxl_async_complete(qxl, async_command_alloc(qxl_state, message, cookie));
+        interface->async_complete(qxl, cookie);
         return;
     }
-    spice_return_if_fail(qxl_state->gl_draw_async == NULL);
+    spice_return_if_fail(qxl_state->gl_draw_cookie == GL_DRAW_COOKIE_INVALID);
 
-    qxl_state->gl_draw_async = async_command_alloc(qxl_state, message, cookie);
+    qxl_state->gl_draw_cookie = cookie;
     dispatcher_send_message(qxl_state->dispatcher, message, &draw);
 }
 
@@ -899,7 +903,6 @@ void red_qxl_async_complete(QXLInstance *qxl, AsyncCommand *async_command)
     case RED_WORKER_MESSAGE_DESTROY_SURFACE_WAIT_ASYNC:
     case RED_WORKER_MESSAGE_FLUSH_SURFACES_ASYNC:
     case RED_WORKER_MESSAGE_MONITORS_CONFIG_ASYNC:
-    case RED_WORKER_MESSAGE_GL_DRAW_ASYNC:
         break;
     case RED_WORKER_MESSAGE_CREATE_PRIMARY_SURFACE_ASYNC:
         red_qxl_create_primary_surface_complete(qxl->st);
@@ -916,10 +919,11 @@ void red_qxl_async_complete(QXLInstance *qxl, AsyncCommand *async_command)
 
 void red_qxl_gl_draw_async_complete(QXLInstance *qxl)
 {
+    QXLInterface *interface = qxl_get_interface(qxl);
     /* this reset before usage prevent a possible race condition */
-    struct AsyncCommand *async = qxl->st->gl_draw_async;
-    qxl->st->gl_draw_async = NULL;
-    red_qxl_async_complete(qxl, async);
+    uint64_t cookie = qxl->st->gl_draw_cookie;
+    qxl->st->gl_draw_cookie = GL_DRAW_COOKIE_INVALID;
+    interface->async_complete(qxl, cookie);
 }
 
 void red_qxl_init(RedsState *reds, QXLInstance *qxl)
@@ -935,6 +939,7 @@ void red_qxl_init(RedsState *reds, QXLInstance *qxl)
     qxl_state->qxl = qxl;
     pthread_mutex_init(&qxl_state->scanout_mutex, NULL);
     qxl_state->scanout.drm_dma_buf_fd = -1;
+    qxl_state->gl_draw_cookie = GL_DRAW_COOKIE_INVALID;
     qxl_state->dispatcher = dispatcher_new(RED_WORKER_MESSAGE_COUNT, NULL);
     qxl_state->qxl_worker.major_version = SPICE_INTERFACE_QXL_MAJOR;
     qxl_state->qxl_worker.minor_version = SPICE_INTERFACE_QXL_MINOR;
commit 56f2a716970cf4f63e4375006106b01ca6a3d1ae
Author: Frediano Ziglio <fziglio at redhat.com>
Date:   Wed Sep 6 21:12:24 2017 +0100

    spice-qxl: Add version information
    
    Signed-off-by: Frediano Ziglio <fziglio at redhat.com>
    Acked-by: Christophe Fergeau <cfergeau at redhat.com>

diff --git a/server/spice-qxl.h b/server/spice-qxl.h
index b8910bf4..04c657c5 100644
--- a/server/spice-qxl.h
+++ b/server/spice-qxl.h
@@ -197,12 +197,14 @@ struct QXLInterface {
     void (*update_area_complete)(QXLInstance *qin, uint32_t surface_id,
                                  struct QXLRect *updated_rects,
                                  uint32_t num_updated_rects);
+    /* Available since version 3.2 */
     void (*set_client_capabilities)(QXLInstance *qin,
                                     uint8_t client_present,
                                     uint8_t caps[SPICE_CAPABILITIES_SIZE]);
-    /* returns 1 if the interface is supported, 0 otherwise.
+    /* Returns 1 if the interface is supported, 0 otherwise.
      * if monitors_config is NULL nothing is done except reporting the
-     * return code. */
+     * return code.
+     * Available since version 3.3 */
     int (*client_monitors_config)(QXLInstance *qin,
                                   VDAgentMonitorsConfig *monitors_config);
 };
commit 99d5f06f2b57e0a3496343f195c6eb8ba642a0d5
Author: Frediano Ziglio <fziglio at redhat.com>
Date:   Wed Sep 6 21:12:02 2017 +0100

    red-qxl: Move QXLInterface wrappers together
    
    Signed-off-by: Frediano Ziglio <fziglio at redhat.com>
    Acked-by: Christophe Fergeau <cfergeau at redhat.com>

diff --git a/server/red-qxl.c b/server/red-qxl.c
index 54d642ad..bec063c1 100644
--- a/server/red-qxl.c
+++ b/server/red-qxl.c
@@ -638,18 +638,6 @@ static void qxl_worker_loadvm_commands(QXLWorker *qxl_worker,
     red_qxl_loadvm_commands(qxl_state, ext, count);
 }
 
-void red_qxl_attach_worker(QXLInstance *qxl)
-{
-    QXLInterface *interface = qxl_get_interface(qxl);
-    interface->attache_worker(qxl, &qxl->st->qxl_worker);
-}
-
-void red_qxl_set_compression_level(QXLInstance *qxl, int level)
-{
-    QXLInterface *interface = qxl_get_interface(qxl);
-    interface->set_compression_level(qxl, level);
-}
-
 uint32_t red_qxl_get_ram_size(QXLInstance *qxl)
 {
     QXLDevInitInfo qxl_info;
@@ -1073,6 +1061,18 @@ RedsState* red_qxl_get_server(QXLState *qxl_state)
     return qxl_state->reds;
 }
 
+void red_qxl_attach_worker(QXLInstance *qxl)
+{
+    QXLInterface *interface = qxl_get_interface(qxl);
+    interface->attache_worker(qxl, &qxl->st->qxl_worker);
+}
+
+void red_qxl_set_compression_level(QXLInstance *qxl, int level)
+{
+    QXLInterface *interface = qxl_get_interface(qxl);
+    interface->set_compression_level(qxl, level);
+}
+
 void red_qxl_get_init_info(QXLInstance *qxl, QXLDevInitInfo *info)
 {
     QXLInterface *interface = qxl_get_interface(qxl);
commit 3a47f4e289995d0fa7124d4b82736876bead4788
Author: Frediano Ziglio <fziglio at redhat.com>
Date:   Wed Sep 6 21:08:36 2017 +0100

    red-qxl: Unify red_qxl_use_client_monitors_config and red_qxl_client_monitors_config
    
    These 2 functions were doing the same stuff, calling
    client_monitors_config callback in QXLInterface.
    The only difference was that red_qxl_use_client_monitors_config
    used a NULL value.
    Added the check for proper version, QXLInstance before 3.3
    did not have this callback.
    
    Signed-off-by: Frediano Ziglio <fziglio at redhat.com>
    Acked-by: Christophe Fergeau <cfergeau at redhat.com>

diff --git a/server/red-qxl.c b/server/red-qxl.c
index b556428d..54d642ad 100644
--- a/server/red-qxl.c
+++ b/server/red-qxl.c
@@ -195,17 +195,11 @@ static void red_qxl_update_area(QXLState *qxl_state, uint32_t surface_id,
                             &payload);
 }
 
-gboolean red_qxl_use_client_monitors_config(QXLInstance *qxl)
-{
-    return (red_qxl_check_qxl_version(qxl, 3, 3) &&
-        qxl_get_interface(qxl)->client_monitors_config &&
-        qxl_get_interface(qxl)->client_monitors_config(qxl, NULL));
-}
-
 gboolean red_qxl_client_monitors_config(QXLInstance *qxl,
                                         VDAgentMonitorsConfig *monitors_config)
 {
-    return (qxl_get_interface(qxl)->client_monitors_config &&
+    return (red_qxl_check_qxl_version(qxl, 3, 3) &&
+        qxl_get_interface(qxl)->client_monitors_config &&
         qxl_get_interface(qxl)->client_monitors_config(qxl, monitors_config));
 }
 
diff --git a/server/red-qxl.h b/server/red-qxl.h
index f925f065..5d57780a 100644
--- a/server/red-qxl.h
+++ b/server/red-qxl.h
@@ -37,7 +37,6 @@ void red_qxl_start(QXLInstance *qxl);
 uint32_t red_qxl_get_ram_size(QXLInstance *qxl);
 void red_qxl_async_complete(QXLInstance *qxl, AsyncCommand *async_command);
 struct Dispatcher *red_qxl_get_dispatcher(QXLInstance *qxl);
-gboolean red_qxl_use_client_monitors_config(QXLInstance *qxl);
 gboolean red_qxl_client_monitors_config(QXLInstance *qxl, VDAgentMonitorsConfig *monitors_config);
 gboolean red_qxl_get_primary_active(QXLInstance *qxl);
 gboolean red_qxl_get_allow_client_mouse(QXLInstance *qxl, gint *x_res, gint *y_res);
diff --git a/server/reds.c b/server/reds.c
index b6ecc6c6..24ec2bdd 100644
--- a/server/reds.c
+++ b/server/reds.c
@@ -4401,7 +4401,7 @@ static gboolean reds_use_client_monitors_config(RedsState *reds)
     }
 
     FOREACH_QXL_INSTANCE(reds, qxl) {
-        if (!red_qxl_use_client_monitors_config(qxl))
+        if (!red_qxl_client_monitors_config(qxl, NULL))
             return FALSE;
     }
     return TRUE;


More information about the Spice-commits mailing list