[Spice-commits] 3 commits - server/cursor-channel.c server/dcc-send.c server/display-channel.c server/red-qxl.c server/red-qxl.h server/red-worker.c server/reds-private.h server/reds.c
Frediano Ziglio
fziglio at kemper.freedesktop.org
Thu Mar 17 16:27:20 UTC 2016
server/cursor-channel.c | 2
server/dcc-send.c | 4
server/display-channel.c | 6 -
server/red-qxl.c | 199 ++++++++++++++++++++++++++++++++---------------
server/red-qxl.h | 54 ++++++++----
server/red-worker.c | 43 ++++------
server/reds-private.h | 2
server/reds.c | 87 ++++++++++----------
8 files changed, 248 insertions(+), 149 deletions(-)
New commits:
commit fe9977c469a5082f264a34a2d05b04f8ed05a21c
Author: Christophe Fergeau <cfergeau at redhat.com>
Date: Thu Mar 17 16:35:50 2016 +0100
Use red_qxl_check_qxl_version in red-worker
Acked-by: Frediano Ziglio <fziglio at redhat.com>
diff --git a/server/red-qxl.c b/server/red-qxl.c
index 7003a96..0169a6a 100644
--- a/server/red-qxl.c
+++ b/server/red-qxl.c
@@ -63,7 +63,7 @@ struct QXLState {
struct AsyncCommand *gl_draw_async;
};
-static int red_qxl_check_qxl_version(QXLInstance *qxl, int major, int minor)
+int red_qxl_check_qxl_version(QXLInstance *qxl, int major, int minor)
{
int qxl_major = qxl_get_interface(qxl)->base.major_version;
int qxl_minor = qxl_get_interface(qxl)->base.minor_version;
diff --git a/server/red-qxl.h b/server/red-qxl.h
index f58d42b..7287740 100644
--- a/server/red-qxl.h
+++ b/server/red-qxl.h
@@ -44,6 +44,7 @@ gboolean red_qxl_get_allow_client_mouse(QXLInstance *qxl, gint *x_res, gint *y_r
SpiceMsgDisplayGlScanoutUnix *red_qxl_get_gl_scanout(QXLInstance *qxl);
void red_qxl_put_gl_scanout(QXLInstance *qxl, SpiceMsgDisplayGlScanoutUnix *scanout);
void red_qxl_gl_draw_async_complete(QXLInstance *qxl);
+int red_qxl_check_qxl_version(QXLInstance *qxl, int major, int minor);
SpiceServer* red_qxl_get_server(QXLState *qxl);
/* Wrappers around QXLInterface vfuncs */
diff --git a/server/red-worker.c b/server/red-worker.c
index 3a82aa4..8ca11c7 100644
--- a/server/red-worker.c
+++ b/server/red-worker.c
@@ -510,10 +510,10 @@ static void guest_set_client_capabilities(RedWorker *worker)
};
QXLInterface *qif = qxl_get_interface(worker->qxl);
- if (qif->base.major_version < 3 ||
- (qif->base.major_version == 3 &&
- qif->base.minor_version < 2) ||
- !qif->set_client_capabilities) {
+ if (!red_qxl_check_qxl_version(worker->qxl, 3, 2)) {
+ return;
+ }
+ if (!qif->set_client_capabilities) {
return;
}
#define SET_CAP(a,c) \
commit ae931c7dab8c78d5ab75caf022f20599c49c01c2
Author: Christophe Fergeau <cfergeau at redhat.com>
Date: Thu Mar 17 16:35:49 2016 +0100
Add more red_qxl_ methods
Add red_qxl_ methods wrapping the QXLInterface vfuncs. This allows to
remove most of the qxl_get_interface() use outside of red-qxl.c
Acked-by: Frediano Ziglio <fziglio at redhat.com>
diff --git a/server/cursor-channel.c b/server/cursor-channel.c
index a904cff..7d5ac6a 100644
--- a/server/cursor-channel.c
+++ b/server/cursor-channel.c
@@ -116,7 +116,7 @@ static void cursor_item_unref(CursorItem *item)
return;
cursor_cmd = item->red_cursor;
- qxl_get_interface(item->qxl)->release_resource(item->qxl, cursor_cmd->release_info_ext);
+ red_qxl_release_resource(item->qxl, cursor_cmd->release_info_ext);
red_put_cursor_cmd(cursor_cmd);
free(cursor_cmd);
diff --git a/server/display-channel.c b/server/display-channel.c
index f5f3527..3f61926 100644
--- a/server/display-channel.c
+++ b/server/display-channel.c
@@ -268,10 +268,10 @@ void display_channel_surface_unref(DisplayChannel *display, uint32_t surface_id)
surface->context.canvas->ops->destroy(surface->context.canvas);
if (surface->create.info) {
- qxl_get_interface(qxl)->release_resource(qxl, surface->create);
+ red_qxl_release_resource(qxl, surface->create);
}
if (surface->destroy.info) {
- qxl_get_interface(qxl)->release_resource(qxl, surface->destroy);
+ red_qxl_release_resource(qxl, surface->destroy);
}
region_destroy(&surface->draw_dirty_region);
diff --git a/server/red-qxl.c b/server/red-qxl.c
index 2055f92..7003a96 100644
--- a/server/red-qxl.c
+++ b/server/red-qxl.c
@@ -665,7 +665,9 @@ void red_qxl_set_compression_level(QXLInstance *qxl, int level)
uint32_t red_qxl_get_ram_size(QXLInstance *qxl)
{
QXLDevInitInfo qxl_info;
- qxl_get_interface(qxl)->get_init_info(qxl, &qxl_info);
+
+ red_qxl_get_init_info(qxl, &qxl_info);
+
return qxl_info.qxl_ram_size;
}
@@ -1065,3 +1067,77 @@ RedsState* red_qxl_get_server(QXLState *qxl_state)
{
return qxl_state->reds;
}
+
+void red_qxl_get_init_info(QXLInstance *qxl, QXLDevInitInfo *info)
+{
+ QXLInterface *interface = qxl_get_interface(qxl);
+
+ interface->get_init_info(qxl, info);
+}
+
+int red_qxl_get_command(QXLInstance *qxl, struct QXLCommandExt *cmd)
+{
+ QXLInterface *interface = qxl_get_interface(qxl);
+
+ return interface->get_command(qxl, cmd);
+}
+
+int red_qxl_req_cmd_notification(QXLInstance *qxl)
+{
+ QXLInterface *interface = qxl_get_interface(qxl);
+
+ return interface->req_cmd_notification(qxl);
+}
+
+void red_qxl_release_resource(QXLInstance *qxl, struct QXLReleaseInfoExt release_info)
+{
+ QXLInterface *interface = qxl_get_interface(qxl);
+
+ interface->release_resource(qxl, release_info);
+}
+
+int red_qxl_get_cursor_command(QXLInstance *qxl, struct QXLCommandExt *cmd)
+{
+ QXLInterface *interface = qxl_get_interface(qxl);
+
+ return interface->get_cursor_command(qxl, cmd);
+}
+
+int red_qxl_req_cursor_notification(QXLInstance *qxl)
+{
+ QXLInterface *interface = qxl_get_interface(qxl);
+
+ return interface->req_cursor_notification(qxl);
+}
+
+void red_qxl_notify_update(QXLInstance *qxl, uint32_t update_id)
+{
+ QXLInterface *interface = qxl_get_interface(qxl);
+
+ interface->notify_update(qxl, update_id);
+}
+
+int red_qxl_flush_resources(QXLInstance *qxl)
+{
+ QXLInterface *interface = qxl_get_interface(qxl);
+
+ return interface->flush_resources(qxl);
+}
+
+void red_qxl_update_area_complete(QXLInstance *qxl, uint32_t surface_id,
+ struct QXLRect *updated_rects,
+ uint32_t num_updated_rects)
+{
+ QXLInterface *interface = qxl_get_interface(qxl);
+
+ interface->update_area_complete(qxl, surface_id, updated_rects, num_updated_rects);
+}
+
+void red_qxl_set_client_capabilities(QXLInstance *qxl,
+ uint8_t client_present,
+ uint8_t caps[SPICE_CAPABILITIES_SIZE])
+{
+ QXLInterface *interface = qxl_get_interface(qxl);
+
+ interface->set_client_capabilities(qxl, client_present, caps);
+}
diff --git a/server/red-qxl.h b/server/red-qxl.h
index 7e158c2..f58d42b 100644
--- a/server/red-qxl.h
+++ b/server/red-qxl.h
@@ -46,6 +46,23 @@ void red_qxl_put_gl_scanout(QXLInstance *qxl, SpiceMsgDisplayGlScanoutUnix *scan
void red_qxl_gl_draw_async_complete(QXLInstance *qxl);
SpiceServer* red_qxl_get_server(QXLState *qxl);
+/* Wrappers around QXLInterface vfuncs */
+void red_qxl_get_init_info(QXLInstance *qxl, QXLDevInitInfo *info);;
+int red_qxl_get_command(QXLInstance *qxl, struct QXLCommandExt *cmd);
+int red_qxl_req_cmd_notification(QXLInstance *qxl);
+void red_qxl_release_resource(QXLInstance *qxl, struct QXLReleaseInfoExt release_info);
+int red_qxl_get_cursor_command(QXLInstance *qxl, struct QXLCommandExt *cmd);
+int red_qxl_req_cursor_notification(QXLInstance *qxl);
+void red_qxl_notify_update(QXLInstance *qxl, uint32_t update_id);
+int red_qxl_flush_resources(QXLInstance *qxl);
+void red_qxl_async_complete(QXLInstance *qxl, AsyncCommand *cmd);
+void red_qxl_update_area_complete(QXLInstance *qxl, uint32_t surface_id,
+ struct QXLRect *updated_rects,
+ uint32_t num_updated_rects);
+void red_qxl_set_client_capabilities(QXLInstance *qxl,
+ uint8_t client_present,
+ uint8_t caps[SPICE_CAPABILITIES_SIZE]);
+
typedef uint32_t RedWorkerMessage;
/* Keep message order, only append new messages!
diff --git a/server/red-worker.c b/server/red-worker.c
index 2eb4fee..3a82aa4 100644
--- a/server/red-worker.c
+++ b/server/red-worker.c
@@ -128,8 +128,7 @@ void red_drawable_unref(RedDrawable *red_drawable)
if (--red_drawable->refs) {
return;
}
- qxl_get_interface(red_drawable->qxl)->release_resource(red_drawable->qxl,
- red_drawable->release_info_ext);
+ red_qxl_release_resource(red_drawable->qxl, red_drawable->release_info_ext);
red_put_drawable(red_drawable);
free(red_drawable);
}
@@ -146,12 +145,12 @@ static int red_process_cursor(RedWorker *worker, int *ring_is_empty)
*ring_is_empty = FALSE;
while (red_channel_max_pipe_size(RED_CHANNEL(worker->cursor_channel)) <= MAX_PIPE_SIZE) {
- if (!qxl_get_interface(worker->qxl)->get_cursor_command(worker->qxl, &ext_cmd)) {
+ if (!red_qxl_get_cursor_command(worker->qxl, &ext_cmd)) {
*ring_is_empty = TRUE;
if (worker->cursor_poll_tries < CMD_RING_POLL_RETRIES) {
worker->event_timeout = MIN(worker->event_timeout, CMD_RING_POLL_TIMEOUT);
} else if (worker->cursor_poll_tries == CMD_RING_POLL_RETRIES &&
- !qxl_get_interface(worker->qxl)->req_cursor_notification(worker->qxl)) {
+ !red_qxl_req_cursor_notification(worker->qxl)) {
continue;
}
worker->cursor_poll_tries++;
@@ -204,12 +203,12 @@ static int red_process_display(RedWorker *worker, int *ring_is_empty)
worker->process_display_generation++;
*ring_is_empty = FALSE;
while (red_channel_max_pipe_size(RED_CHANNEL(worker->display_channel)) <= MAX_PIPE_SIZE) {
- if (!qxl_get_interface(worker->qxl)->get_command(worker->qxl, &ext_cmd)) {
+ if (!red_qxl_get_command(worker->qxl, &ext_cmd)) {
*ring_is_empty = TRUE;
if (worker->display_poll_tries < CMD_RING_POLL_RETRIES) {
worker->event_timeout = MIN(worker->event_timeout, CMD_RING_POLL_TIMEOUT);
} else if (worker->display_poll_tries == CMD_RING_POLL_RETRIES &&
- !qxl_get_interface(worker->qxl)->req_cmd_notification(worker->qxl)) {
+ !red_qxl_req_cmd_notification(worker->qxl)) {
continue;
}
worker->display_poll_tries++;
@@ -246,9 +245,9 @@ static int red_process_display(RedWorker *worker, int *ring_is_empty)
spice_warning("Invalid surface in QXL_CMD_UPDATE");
} else {
display_channel_draw(worker->display_channel, &update.area, update.surface_id);
- qxl_get_interface(worker->qxl)->notify_update(worker->qxl, update.update_id);
+ red_qxl_notify_update(worker->qxl, update.update_id);
}
- qxl_get_interface(worker->qxl)->release_resource(worker->qxl, update.release_info_ext);
+ red_qxl_release_resource(worker->qxl, update.release_info_ext);
red_put_update_cmd(&update);
break;
}
@@ -263,7 +262,7 @@ static int red_process_display(RedWorker *worker, int *ring_is_empty)
/* alert: accessing message.data is insecure */
spice_warning("MESSAGE: %s", message.data);
#endif
- qxl_get_interface(worker->qxl)->release_resource(worker->qxl, message.release_info_ext);
+ red_qxl_release_resource(worker->qxl, message.release_info_ext);
red_put_message(&message);
break;
}
@@ -528,7 +527,7 @@ static void guest_set_client_capabilities(RedWorker *worker)
}
if ((worker->display_channel == NULL) ||
(RED_CHANNEL(worker->display_channel)->clients_num == 0)) {
- qif->set_client_capabilities(worker->qxl, FALSE, caps);
+ red_qxl_set_client_capabilities(worker->qxl, FALSE, caps);
} else {
// Take least common denominator
for (i = 0 ; i < sizeof(caps_available) / sizeof(caps_available[0]); ++i) {
@@ -541,7 +540,7 @@ static void guest_set_client_capabilities(RedWorker *worker)
CLEAR_CAP(caps, caps_available[i]);
}
}
- qif->set_client_capabilities(worker->qxl, TRUE, caps);
+ red_qxl_set_client_capabilities(worker->qxl, TRUE, caps);
}
}
@@ -587,8 +586,8 @@ static void handle_dev_update_async(void *opaque, void *payload)
msg->surface_id, &msg->qxl_area, msg->clear_dirty_region,
&qxl_dirty_rects, &num_dirty_rects);
- qxl_get_interface(worker->qxl)->update_area_complete(worker->qxl, msg->surface_id,
- qxl_dirty_rects, num_dirty_rects);
+ red_qxl_update_area_complete(worker->qxl, msg->surface_id,
+ qxl_dirty_rects, num_dirty_rects);
free(qxl_dirty_rects);
}
@@ -847,9 +846,9 @@ static void handle_dev_oom(void *opaque, void *payload)
while (red_process_display(worker, &ring_is_empty)) {
red_channel_push(display_red_channel);
}
- if (qxl_get_interface(worker->qxl)->flush_resources(worker->qxl) == 0) {
+ if (red_qxl_flush_resources(worker->qxl) == 0) {
display_channel_free_some(worker->display_channel);
- qxl_get_interface(worker->qxl)->flush_resources(worker->qxl);
+ red_qxl_flush_resources(worker->qxl);
}
spice_debug("OOM2 #draw=%u, #glz_draw=%u current %u pipes %u",
display->drawable_count,
@@ -1473,7 +1472,7 @@ RedWorker* red_worker_new(QXLInstance *qxl)
const char *record_filename;
RedsState *reds = red_qxl_get_server(qxl->st);
- qxl_get_interface(qxl)->get_init_info(qxl, &init_info);
+ red_qxl_get_init_info(qxl, &init_info);
worker = spice_new0(RedWorker, 1);
worker->core = event_loop_core;
commit e45ab9cf230f127d93dd3a24780cea676f43aa9c
Author: Christophe Fergeau <cfergeau at redhat.com>
Date: Mon Mar 14 18:10:31 2016 +0100
Use QXLInstance instead of QXLState in red_qxl_*
This seems to make more sense this way, QXLInstance is the 'main' object
with QXLState being its private data. External users then use QXLInstance
rather than passing a pointer to the private data to red-qxl.h methods.
Acked-by: Frediano Ziglio <fziglio at redhat.com>
diff --git a/server/dcc-send.c b/server/dcc-send.c
index 53e02f5..eb866cf 100644
--- a/server/dcc-send.c
+++ b/server/dcc-send.c
@@ -2307,12 +2307,12 @@ static void marshall_gl_scanout(RedChannelClient *rcc,
DisplayChannel *display_channel = DCC_TO_DC(dcc);
QXLInstance* qxl = display_channel->common.qxl;
- SpiceMsgDisplayGlScanoutUnix *scanout = red_qxl_get_gl_scanout(qxl->st);
+ SpiceMsgDisplayGlScanoutUnix *scanout = red_qxl_get_gl_scanout(qxl);
if (scanout != NULL) {
red_channel_client_init_send_data(rcc, SPICE_MSG_DISPLAY_GL_SCANOUT_UNIX, NULL);
spice_marshall_msg_display_gl_scanout_unix(m, scanout);
}
- red_qxl_put_gl_scanout(qxl->st, scanout);
+ red_qxl_put_gl_scanout(qxl, scanout);
}
static void marshall_gl_draw(RedChannelClient *rcc,
diff --git a/server/display-channel.c b/server/display-channel.c
index ff9aeac..f5f3527 100644
--- a/server/display-channel.c
+++ b/server/display-channel.c
@@ -2163,7 +2163,7 @@ static void set_gl_draw_async_count(DisplayChannel *display, int num)
display->gl_draw_async_count = num;
if (num == 0) {
- red_qxl_gl_draw_async_complete(qxl->st);
+ red_qxl_gl_draw_async_complete(qxl);
}
}
diff --git a/server/red-qxl.c b/server/red-qxl.c
index 3a94944..2055f92 100644
--- a/server/red-qxl.c
+++ b/server/red-qxl.c
@@ -63,10 +63,10 @@ struct QXLState {
struct AsyncCommand *gl_draw_async;
};
-static int red_qxl_check_qxl_version(QXLState *rq, int major, int minor)
+static int red_qxl_check_qxl_version(QXLInstance *qxl, int major, int minor)
{
- int qxl_major = qxl_get_interface(rq->qxl)->base.major_version;
- int qxl_minor = qxl_get_interface(rq->qxl)->base.minor_version;
+ int qxl_major = qxl_get_interface(qxl)->base.major_version;
+ int qxl_minor = qxl_get_interface(qxl)->base.minor_version;
return ((qxl_major > major) ||
((qxl_major == major) && (qxl_minor >= minor)));
@@ -208,19 +208,18 @@ static void red_qxl_update_area(QXLState *qxl_state, uint32_t surface_id,
&payload);
}
-gboolean red_qxl_use_client_monitors_config(QXLState *qxl_state)
+gboolean red_qxl_use_client_monitors_config(QXLInstance *qxl)
{
- return (red_qxl_check_qxl_version(qxl_state, 3, 3) &&
- qxl_get_interface(qxl_state->qxl)->client_monitors_config &&
- qxl_get_interface(qxl_state->qxl)->client_monitors_config(qxl_state->qxl, NULL));
+ 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(QXLState *qxl_state,
+gboolean red_qxl_client_monitors_config(QXLInstance *qxl,
VDAgentMonitorsConfig *monitors_config)
{
- return (qxl_get_interface(qxl_state->qxl)->client_monitors_config &&
- qxl_get_interface(qxl_state->qxl)->client_monitors_config(qxl_state->qxl,
- monitors_config));
+ return (qxl_get_interface(qxl)->client_monitors_config &&
+ qxl_get_interface(qxl)->client_monitors_config(qxl, monitors_config));
}
static AsyncCommand *async_command_alloc(QXLState *qxl_state,
@@ -560,18 +559,19 @@ static void qxl_worker_oom(QXLWorker *qxl_worker)
red_qxl_oom((QXLState*)qxl_worker);
}
-void red_qxl_start(QXLState *qxl_state)
+void red_qxl_start(QXLInstance *qxl)
{
RedWorkerMessageStart payload;
- dispatcher_send_message(&qxl_state->dispatcher,
+ dispatcher_send_message(&qxl->st->dispatcher,
RED_WORKER_MESSAGE_START,
&payload);
}
static void qxl_worker_start(QXLWorker *qxl_worker)
{
- red_qxl_start((QXLState*)qxl_worker);
+ QXLState *state = (QXLState *)qxl_worker;
+ red_qxl_start(state->qxl);
}
static void red_qxl_flush_surfaces_async(QXLState *qxl_state, uint64_t cookie)
@@ -608,18 +608,19 @@ static void red_qxl_driver_unload(QXLState *qxl_state)
&payload);
}
-void red_qxl_stop(QXLState *qxl_state)
+void red_qxl_stop(QXLInstance *qxl)
{
RedWorkerMessageStop payload;
- dispatcher_send_message(&qxl_state->dispatcher,
+ dispatcher_send_message(&qxl->st->dispatcher,
RED_WORKER_MESSAGE_STOP,
&payload);
}
static void qxl_worker_stop(QXLWorker *qxl_worker)
{
- red_qxl_stop((QXLState*)qxl_worker);
+ QXLState *state = (QXLState *)qxl_worker;
+ red_qxl_stop(state->qxl);
}
static void red_qxl_loadvm_commands(QXLState *qxl_state,
@@ -643,26 +644,28 @@ static void qxl_worker_loadvm_commands(QXLWorker *qxl_worker,
red_qxl_loadvm_commands((QXLState*)qxl_worker, ext, count);
}
-void red_qxl_set_mm_time(QXLState *qxl_state, uint32_t mm_time)
+void red_qxl_set_mm_time(QXLInstance *qxl, uint32_t mm_time)
{
- qxl_get_interface(qxl_state->qxl)->set_mm_time(qxl_state->qxl, mm_time);
+ QXLInterface *interface = qxl_get_interface(qxl);
+ interface->set_mm_time(qxl, mm_time);
}
-void red_qxl_attach_worker(QXLState *qxl_state)
+void red_qxl_attach_worker(QXLInstance *qxl)
{
- QXLInstance *qxl = qxl_state->qxl;
- qxl_get_interface(qxl_state->qxl)->attache_worker(qxl, &qxl_state->base);
+ QXLInterface *interface = qxl_get_interface(qxl);
+ interface->attache_worker(qxl, &qxl->st->base);
}
-void red_qxl_set_compression_level(QXLState *qxl_state, int level)
+void red_qxl_set_compression_level(QXLInstance *qxl, int level)
{
- qxl_get_interface(qxl_state->qxl)->set_compression_level(qxl_state->qxl, level);
+ QXLInterface *interface = qxl_get_interface(qxl);
+ interface->set_compression_level(qxl, level);
}
-uint32_t red_qxl_get_ram_size(QXLState *qxl_state)
+uint32_t red_qxl_get_ram_size(QXLInstance *qxl)
{
QXLDevInitInfo qxl_info;
- qxl_get_interface(qxl_state->qxl)->get_init_info(qxl_state->qxl, &qxl_info);
+ qxl_get_interface(qxl)->get_init_info(qxl, &qxl_info);
return qxl_info.qxl_ram_size;
}
@@ -681,13 +684,13 @@ void spice_qxl_oom(QXLInstance *instance)
SPICE_GNUC_VISIBLE
void spice_qxl_start(QXLInstance *instance)
{
- red_qxl_start(instance->st);
+ red_qxl_start(instance);
}
SPICE_GNUC_VISIBLE
void spice_qxl_stop(QXLInstance *instance)
{
- red_qxl_stop(instance->st);
+ red_qxl_stop(instance);
}
SPICE_GNUC_VISIBLE
@@ -824,20 +827,20 @@ void spice_qxl_driver_unload(QXLInstance *instance)
red_qxl_driver_unload(instance->st);
}
-SpiceMsgDisplayGlScanoutUnix *red_qxl_get_gl_scanout(QXLState *qxl_state)
+SpiceMsgDisplayGlScanoutUnix *red_qxl_get_gl_scanout(QXLInstance *qxl)
{
- pthread_mutex_lock(&qxl_state->scanout_mutex);
- if (qxl_state->scanout.drm_dma_buf_fd >= 0) {
- return &qxl_state->scanout;
+ pthread_mutex_lock(&qxl->st->scanout_mutex);
+ if (qxl->st->scanout.drm_dma_buf_fd >= 0) {
+ return &qxl->st->scanout;
}
- pthread_mutex_unlock(&qxl_state->scanout_mutex);
+ pthread_mutex_unlock(&qxl->st->scanout_mutex);
return NULL;
}
-void red_qxl_put_gl_scanout(QXLState *qxl_state, SpiceMsgDisplayGlScanoutUnix *scanout)
+void red_qxl_put_gl_scanout(QXLInstance *qxl, SpiceMsgDisplayGlScanoutUnix *scanout)
{
if (scanout) {
- pthread_mutex_unlock(&qxl_state->scanout_mutex);
+ pthread_mutex_unlock(&qxl->st->scanout_mutex);
}
}
@@ -899,9 +902,10 @@ void spice_qxl_gl_draw_async(QXLInstance *qxl,
dispatcher_send_message(&qxl_state->dispatcher, message, &draw);
}
-void red_qxl_async_complete(QXLState *qxl_state,
- AsyncCommand *async_command)
+void red_qxl_async_complete(QXLInstance *qxl, AsyncCommand *async_command)
{
+ QXLInterface *interface = qxl_get_interface(qxl);
+
spice_debug("%p: cookie %" PRId64, async_command, async_command->cookie);
switch (async_command->message) {
case RED_WORKER_MESSAGE_UPDATE_ASYNC:
@@ -913,25 +917,24 @@ void red_qxl_async_complete(QXLState *qxl_state,
case RED_WORKER_MESSAGE_GL_DRAW_ASYNC:
break;
case RED_WORKER_MESSAGE_CREATE_PRIMARY_SURFACE_ASYNC:
- red_qxl_create_primary_surface_complete(qxl_state);
+ red_qxl_create_primary_surface_complete(qxl->st);
break;
case RED_WORKER_MESSAGE_DESTROY_PRIMARY_SURFACE_ASYNC:
- red_qxl_destroy_primary_surface_complete(qxl_state);
+ red_qxl_destroy_primary_surface_complete(qxl->st);
break;
default:
spice_warning("unexpected message %d", async_command->message);
}
- qxl_get_interface(qxl_state->qxl)->async_complete(qxl_state->qxl,
- async_command->cookie);
+ interface->async_complete(qxl, async_command->cookie);
free(async_command);
}
-void red_qxl_gl_draw_async_complete(QXLState *qxl_state)
+void red_qxl_gl_draw_async_complete(QXLInstance *qxl)
{
/* this reset before usage prevent a possible race condition */
- struct AsyncCommand *async = qxl_state->gl_draw_async;
- qxl_state->gl_draw_async = NULL;
- red_qxl_async_complete(qxl_state, async);
+ struct AsyncCommand *async = qxl->st->gl_draw_async;
+ qxl->st->gl_draw_async = NULL;
+ red_qxl_async_complete(qxl, async);
}
void red_qxl_init(RedsState *reds, QXLInstance *qxl)
@@ -1003,9 +1006,9 @@ void red_qxl_init(RedsState *reds, QXLInstance *qxl)
red_worker_run(worker);
}
-struct Dispatcher *red_qxl_get_dispatcher(QXLState *qxl_state)
+struct Dispatcher *red_qxl_get_dispatcher(QXLInstance *qxl)
{
- return &qxl_state->dispatcher;
+ return &qxl->st->dispatcher;
}
void red_qxl_clear_pending(QXLState *qxl_state, int pending)
@@ -1015,45 +1018,45 @@ void red_qxl_clear_pending(QXLState *qxl_state, int pending)
clear_bit(pending, &qxl_state->pending);
}
-gboolean red_qxl_get_primary_active(QXLState *qxl_state)
+gboolean red_qxl_get_primary_active(QXLInstance *qxl)
{
- return qxl_state->primary_active;
+ return qxl->st->primary_active;
}
-gboolean red_qxl_get_allow_client_mouse(QXLState *qxl_state, gint *x_res, gint *y_res)
+gboolean red_qxl_get_allow_client_mouse(QXLInstance *qxl, gint *x_res, gint *y_res)
{
- if (qxl_state->use_hardware_cursor) {
+ if (qxl->st->use_hardware_cursor) {
if (x_res)
- *x_res = qxl_state->x_res;
+ *x_res = qxl->st->x_res;
if (y_res)
- *y_res = qxl_state->y_res;
+ *y_res = qxl->st->y_res;
}
- return qxl_state->use_hardware_cursor;
+ return qxl->st->use_hardware_cursor;
}
-void red_qxl_on_ic_change(QXLState *qxl_state, SpiceImageCompression ic)
+void red_qxl_on_ic_change(QXLInstance *qxl, SpiceImageCompression ic)
{
RedWorkerMessageSetCompression payload;
payload.image_compression = ic;
- dispatcher_send_message(&qxl_state->dispatcher,
+ dispatcher_send_message(&qxl->st->dispatcher,
RED_WORKER_MESSAGE_SET_COMPRESSION,
&payload);
}
-void red_qxl_on_sv_change(QXLState *qxl_state, int sv)
+void red_qxl_on_sv_change(QXLInstance *qxl, int sv)
{
RedWorkerMessageSetStreamingVideo payload;
payload.streaming_video = sv;
- dispatcher_send_message(&qxl_state->dispatcher,
+ dispatcher_send_message(&qxl->st->dispatcher,
RED_WORKER_MESSAGE_SET_STREAMING_VIDEO,
&payload);
}
-void red_qxl_set_mouse_mode(QXLState *qxl_state, uint32_t mode)
+void red_qxl_set_mouse_mode(QXLInstance *qxl, uint32_t mode)
{
RedWorkerMessageSetMouseMode payload;
payload.mode = mode;
- dispatcher_send_message(&qxl_state->dispatcher,
+ dispatcher_send_message(&qxl->st->dispatcher,
RED_WORKER_MESSAGE_SET_MOUSE_MODE,
&payload);
}
diff --git a/server/red-qxl.h b/server/red-qxl.h
index f100cb4..7e158c2 100644
--- a/server/red-qxl.h
+++ b/server/red-qxl.h
@@ -26,24 +26,24 @@ typedef struct AsyncCommand AsyncCommand;
void red_qxl_init(SpiceServer *reds, QXLInstance *qxl);
-void red_qxl_set_mm_time(QXLState *qxl_state, uint32_t);
-void red_qxl_on_ic_change(QXLState *qxl_state, SpiceImageCompression ic);
-void red_qxl_on_sv_change(QXLState *qxl_state, int sv);
-void red_qxl_set_mouse_mode(QXLState *qxl_state, uint32_t mode);
-void red_qxl_attach_worker(QXLState *qxl_state);
-void red_qxl_set_compression_level(QXLState *qxl_state, int level);
-void red_qxl_stop(QXLState *qxl_state);
-void red_qxl_start(QXLState *qxl_state);
-uint32_t red_qxl_get_ram_size(QXLState *qxl_state);
-void red_qxl_async_complete(QXLState *qxl_state, AsyncCommand *cmd);
-struct Dispatcher *red_qxl_get_dispatcher(QXLState *qxl_state);
-gboolean red_qxl_use_client_monitors_config(QXLState *qxl_state);
-gboolean red_qxl_client_monitors_config(QXLState *qxl_state, VDAgentMonitorsConfig *monitors_config);
-gboolean red_qxl_get_primary_active(QXLState *qxl_state);
-gboolean red_qxl_get_allow_client_mouse(QXLState *qxl_state, gint *x_res, gint *y_res);
-SpiceMsgDisplayGlScanoutUnix *red_qxl_get_gl_scanout(QXLState *qxl_state);
-void red_qxl_put_gl_scanout(QXLState *qxl_state, SpiceMsgDisplayGlScanoutUnix *scanout);
-void red_qxl_gl_draw_async_complete(QXLState *qxl);
+void red_qxl_set_mm_time(QXLInstance *qxl, uint32_t);
+void red_qxl_on_ic_change(QXLInstance *qxl, SpiceImageCompression ic);
+void red_qxl_on_sv_change(QXLInstance *qxl, int sv);
+void red_qxl_set_mouse_mode(QXLInstance *qxl, uint32_t mode);
+void red_qxl_attach_worker(QXLInstance *qxl);
+void red_qxl_set_compression_level(QXLInstance *qxl, int level);
+void red_qxl_stop(QXLInstance *qxl);
+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);
+SpiceMsgDisplayGlScanoutUnix *red_qxl_get_gl_scanout(QXLInstance *qxl);
+void red_qxl_put_gl_scanout(QXLInstance *qxl, SpiceMsgDisplayGlScanoutUnix *scanout);
+void red_qxl_gl_draw_async_complete(QXLInstance *qxl);
SpiceServer* red_qxl_get_server(QXLState *qxl);
typedef uint32_t RedWorkerMessage;
diff --git a/server/red-worker.c b/server/red-worker.c
index 0b61ec4..2eb4fee 100644
--- a/server/red-worker.c
+++ b/server/red-worker.c
@@ -1197,7 +1197,7 @@ static void worker_handle_dispatcher_async_done(void *opaque,
RedWorkerMessageAsync *msg_async = payload;
spice_debug(NULL);
- red_qxl_async_complete(worker->qxl->st, msg_async->cmd);
+ red_qxl_async_complete(worker->qxl, msg_async->cmd);
}
static void worker_dispatcher_record(void *opaque, uint32_t message_type, void *payload)
@@ -1491,7 +1491,7 @@ RedWorker* red_worker_new(QXLInstance *qxl)
spice_error("failed to write replay header");
}
}
- dispatcher = red_qxl_get_dispatcher(qxl->st);
+ dispatcher = red_qxl_get_dispatcher(qxl);
dispatcher_set_opaque(dispatcher, worker);
worker->qxl = qxl;
diff --git a/server/reds-private.h b/server/reds-private.h
index 032f9f0..3001990 100644
--- a/server/reds-private.h
+++ b/server/reds-private.h
@@ -231,7 +231,7 @@ struct RedsState {
RedSSLParameters ssl_parameters;
SpiceCoreInterfaceInternal *core;
- GList *qxl_states;
+ GList *qxl_instances;
MainDispatcher *main_dispatcher;
};
diff --git a/server/reds.c b/server/reds.c
index b1e1139..e4ee1cf 100644
--- a/server/reds.c
+++ b/server/reds.c
@@ -570,8 +570,10 @@ static void reds_set_mouse_mode(RedsState *reds, uint32_t mode)
}
reds->mouse_mode = mode;
- for (l = reds->qxl_states; l != NULL; l = l->next)
- red_qxl_set_mouse_mode((QXLState*) l->data, mode);
+ for (l = reds->qxl_instances; l != NULL; l = l->next) {
+ QXLInstance *qxl = (QXLInstance *)l->data;
+ red_qxl_set_mouse_mode(qxl, mode);
+ }
main_channel_push_mouse_mode(reds->main_channel, reds->mouse_mode, reds->is_client_mouse_allowed);
}
@@ -584,7 +586,7 @@ gboolean reds_get_agent_mouse(const RedsState *reds)
static void reds_update_mouse_mode(RedsState *reds)
{
int allowed = 0;
- int qxl_count = g_list_length(reds->qxl_states);
+ int qxl_count = g_list_length(reds->qxl_instances);
if ((reds->agent_mouse && reds->vdagent) ||
(inputs_channel_has_tablet(reds->inputs_channel) && qxl_count == 1)) {
@@ -1681,7 +1683,7 @@ static void reds_handle_main_link(RedsState *reds, RedLinkInfo *link)
}
if (!mig_target) {
- main_channel_push_init(mcc, g_list_length(reds->qxl_states),
+ main_channel_push_init(mcc, g_list_length(reds->qxl_instances),
reds->mouse_mode, reds->is_client_mouse_allowed,
reds_get_mm_time() - MM_TIME_DELTA,
reds_qxl_ram_size(reds));
@@ -1827,7 +1829,7 @@ void reds_on_client_semi_seamless_migrate_complete(RedsState *reds, RedClient *c
mcc = red_client_get_main(client);
// TODO: not doing net test. consider doing it on client_migrate_info
- main_channel_push_init(mcc, g_list_length(reds->qxl_states),
+ main_channel_push_init(mcc, g_list_length(reds->qxl_instances),
reds->mouse_mode, reds->is_client_mouse_allowed,
reds_get_mm_time() - MM_TIME_DELTA,
reds_qxl_ram_size(reds));
@@ -3175,7 +3177,6 @@ SPICE_GNUC_VISIBLE int spice_server_add_interface(SpiceServer *s,
}
} else if (strcmp(interface->type, SPICE_INTERFACE_QXL) == 0) {
QXLInstance *qxl;
- QXLState *qxl_state;
spice_info("SPICE_INTERFACE_QXL");
if (interface->major_version != SPICE_INTERFACE_QXL_MAJOR ||
@@ -3186,16 +3187,15 @@ SPICE_GNUC_VISIBLE int spice_server_add_interface(SpiceServer *s,
qxl = SPICE_CONTAINEROF(sin, QXLInstance, base);
red_qxl_init(reds, qxl);
- qxl_state = qxl->st;
- reds->qxl_states = g_list_prepend(reds->qxl_states, qxl_state);
+ reds->qxl_instances = g_list_prepend(reds->qxl_instances, qxl);
/* this function has to be called after the qxl is on the list
* as QXLInstance clients expect the qxl to be on the list when
* this callback is called. This as clients assume they can start the
- * qxl_states. Also note that this should be the first callback to
+ * qxl_instances. Also note that this should be the first callback to
* be called. */
- red_qxl_attach_worker(qxl_state);
- red_qxl_set_compression_level(qxl_state, calc_compression_level(reds));
+ red_qxl_attach_worker(qxl);
+ red_qxl_set_compression_level(qxl, calc_compression_level(reds));
} else if (strcmp(interface->type, SPICE_INTERFACE_TABLET) == 0) {
SpiceTabletInstance *tablet = SPICE_CONTAINEROF(sin, SpiceTabletInstance, base);
spice_info("SPICE_INTERFACE_TABLET");
@@ -4109,15 +4109,14 @@ void reds_update_client_mouse_allowed(RedsState *reds)
int x_res = 0;
int y_res = 0;
GList *l;
- int num_active_workers = g_list_length(reds->qxl_states);
+ int num_active_workers = g_list_length(reds->qxl_instances);
if (num_active_workers > 0) {
allow_now = TRUE;
- for (l = reds->qxl_states; l != NULL && allow_now; l = l->next) {
-
- QXLState *now = l->data;
- if (red_qxl_get_primary_active(now)) {
- allow_now = red_qxl_get_allow_client_mouse(now, &x_res, &y_res);
+ for (l = reds->qxl_instances; l != NULL && allow_now; l = l->next) {
+ QXLInstance *qxl = l->data;
+ if (red_qxl_get_primary_active(qxl)) {
+ allow_now = red_qxl_get_allow_client_mouse(qxl, &x_res, &y_res);
break;
}
}
@@ -4133,14 +4132,14 @@ gboolean reds_use_client_monitors_config(RedsState *reds)
{
GList *l;
- if (reds->qxl_states == NULL) {
+ if (reds->qxl_instances == NULL) {
return FALSE;
}
- for (l = reds->qxl_states; l != NULL ; l = l->next) {
- QXLState *now = l->data;
+ for (l = reds->qxl_instances; l != NULL ; l = l->next) {
+ QXLInstance *qxl = l->data;
- if (!red_qxl_use_client_monitors_config(now))
+ if (!red_qxl_use_client_monitors_config(qxl))
return FALSE;
}
return TRUE;
@@ -4150,9 +4149,9 @@ void reds_client_monitors_config(RedsState *reds, VDAgentMonitorsConfig *monitor
{
GList *l;
- for (l = reds->qxl_states; l != NULL; l = l->next) {
- QXLState *now = l->data;
- if (!red_qxl_client_monitors_config(now, monitors_config)) {
+ for (l = reds->qxl_instances; l != NULL; l = l->next) {
+ QXLInstance *qxl = l->data;
+ if (!red_qxl_client_monitors_config(qxl, monitors_config)) {
/* this is a normal condition, some qemu devices might not implement it */
spice_debug("QXLInterface::client_monitors_config failed\n");
}
@@ -4163,9 +4162,9 @@ void reds_set_mm_time(RedsState *reds, uint32_t mm_time)
{
GList *l;
- for (l = reds->qxl_states; l != NULL; l = l->next) {
- QXLState *now = l->data;
- red_qxl_set_mm_time(now, mm_time);
+ for (l = reds->qxl_instances; l != NULL; l = l->next) {
+ QXLInstance *qxl = l->data;
+ red_qxl_set_mm_time(qxl, mm_time);
}
}
@@ -4186,10 +4185,10 @@ void reds_on_ic_change(RedsState *reds)
int compression_level = calc_compression_level(reds);
GList *l;
- for (l = reds->qxl_states; l != NULL; l = l->next) {
- QXLState *q = l->data;
- red_qxl_set_compression_level(q, compression_level);
- red_qxl_on_ic_change(q, spice_server_get_image_compression(reds));
+ for (l = reds->qxl_instances; l != NULL; l = l->next) {
+ QXLInstance *qxl = l->data;
+ red_qxl_set_compression_level(qxl, compression_level);
+ red_qxl_on_ic_change(qxl, spice_server_get_image_compression(reds));
}
}
@@ -4198,10 +4197,10 @@ void reds_on_sv_change(RedsState *reds)
int compression_level = calc_compression_level(reds);
GList *l;
- for (l = reds->qxl_states; l != NULL; l = l->next) {
- QXLState *q = l->data;
- red_qxl_set_compression_level(q, compression_level);
- red_qxl_on_sv_change(q, reds_get_streaming_video(reds));
+ for (l = reds->qxl_instances; l != NULL; l = l->next) {
+ QXLInstance *qxl = l->data;
+ red_qxl_set_compression_level(qxl, compression_level);
+ red_qxl_on_sv_change(qxl, reds_get_streaming_video(reds));
}
}
@@ -4209,26 +4208,30 @@ void reds_on_vm_stop(RedsState *reds)
{
GList *l;
- for (l = reds->qxl_states; l != NULL; l = l->next)
- red_qxl_stop((QXLState*) l->data);
+ for (l = reds->qxl_instances; l != NULL; l = l->next) {
+ QXLInstance *qxl = l->data;
+ red_qxl_stop(qxl);
+ }
}
void reds_on_vm_start(RedsState *reds)
{
GList *l;
- for (l = reds->qxl_states; l != NULL; l = l->next)
- red_qxl_start((QXLState*) l->data);
+ for (l = reds->qxl_instances; l != NULL; l = l->next) {
+ QXLInstance *qxl = l->data;
+ red_qxl_start(qxl);
+ }
}
uint32_t reds_qxl_ram_size(RedsState *reds)
{
- QXLState *first;
- if (!reds->qxl_states) {
+ QXLInstance *first;
+ if (!reds->qxl_instances) {
return 0;
}
- first = reds->qxl_states->data;
+ first = reds->qxl_instances->data;
return red_qxl_get_ram_size(first);
}
More information about the Spice-commits
mailing list