[Spice-devel] [PATCH 2/7] server/spice.h: add spice_qxl_guest_capabilities_set

Alon Levy alevy at redhat.com
Mon Sep 10 08:43:57 PDT 2012


Allow spice to know about guest driver capabilities.

Implements spice api complement to qemu QXL_IO_CAPABILITIES_SET.

Implementation in red_dispatcher. Stores a copy of guest capabilities.
---
 server/red_dispatcher.c  | 20 ++++++++++++++++++++
 server/spice-server.syms |  1 +
 server/spice.h           |  2 ++
 3 files changed, 23 insertions(+)

diff --git a/server/red_dispatcher.c b/server/red_dispatcher.c
index 3a4229e..8e44674 100644
--- a/server/red_dispatcher.c
+++ b/server/red_dispatcher.c
@@ -64,6 +64,8 @@ struct RedDispatcher {
     Ring async_commands;
     pthread_mutex_t  async_lock;
     QXLDevSurfaceCreate surface_create;
+    size_t guest_capabilities_size;
+    uint8_t *guest_capabilities;
 };
 
 typedef struct RedWorkeState {
@@ -952,6 +954,24 @@ void spice_qxl_monitors_config_async(QXLInstance *instance, QXLPHYSICAL monitors
     red_dispatcher_monitors_config_async(instance->st->dispatcher, monitors_config, group_id, cookie);
 }
 
+SPICE_GNUC_VISIBLE
+void spice_qxl_guest_capabilities_set(QXLInstance *instance, size_t caps_length,
+                                      uint8_t *new_caps)
+{
+    RedDispatcher *dispatcher = instance->st->dispatcher;
+
+    printf("%s: caps_length=%zd, new_caps=%p, new_caps[0]=%u\n",
+           __func__, caps_length, new_caps, new_caps ? new_caps[0] : -1);
+
+    if (dispatcher->guest_capabilities) {
+        free(dispatcher->guest_capabilities);
+    }
+    dispatcher->guest_capabilities_size = caps_length;
+    dispatcher->guest_capabilities = malloc(dispatcher->guest_capabilities_size);
+    memcpy(dispatcher->guest_capabilities, new_caps,
+           dispatcher->guest_capabilities_size);
+}
+
 void red_dispatcher_async_complete(struct RedDispatcher *dispatcher,
                                    AsyncCommand *async_command)
 {
diff --git a/server/spice-server.syms b/server/spice-server.syms
index fd2a423..b6fc7e6 100644
--- a/server/spice-server.syms
+++ b/server/spice-server.syms
@@ -126,4 +126,5 @@ global:
 
 SPICE_SERVER_0.11.4 {
     spice_server_set_exit_on_disconnect;
+    spice_qxl_guest_capabilities_set;
 } SPICE_SERVER_0.11.2;
diff --git a/server/spice.h b/server/spice.h
index 3152f8c..9ae76c2 100644
--- a/server/spice.h
+++ b/server/spice.h
@@ -166,6 +166,8 @@ void spice_qxl_flush_surfaces_async(QXLInstance *instance, uint64_t cookie);
 /* since spice 0.12.0 */
 void spice_qxl_monitors_config_async(QXLInstance *instance, QXLPHYSICAL monitors_config,
                                      int group_id, uint64_t cookie);
+void spice_qxl_guest_capabilities_set(QXLInstance *instance, size_t caps_length,
+                                      uint8_t *new_caps);
 
 typedef struct QXLDrawArea {
     uint8_t *buf;
-- 
1.7.12



More information about the Spice-devel mailing list