[Spice-commits] 8 commits - server/agent-msg-filter.c server/red-dispatcher.c server/red-dispatcher.h server/reds.c server/reds.h server/reds-private.h
Frediano Ziglio
fziglio at kemper.freedesktop.org
Tue Feb 16 10:12:19 UTC 2016
server/agent-msg-filter.c | 3
server/red-dispatcher.c | 228 +++++++++++++---------------------------------
server/red-dispatcher.h | 23 ++--
server/reds-private.h | 2
server/reds.c | 176 +++++++++++++++++++++++++++++++++--
server/reds.h | 4
6 files changed, 249 insertions(+), 187 deletions(-)
New commits:
commit aadb94557011af2466dd7e678a1de45415ce424a
Author: Frediano Ziglio <fziglio at redhat.com>
Date: Fri Feb 12 14:41:57 2016 +0000
Remove global 'dispatchers', 'num_active_workers' variables
Since these are server-level variables, move them into RedsState.
However, num_active_workers was removed because:
- each dispatcher always has 1 active worker, so we can determine the
number of active workers by counting the dispatchers
- it was never actually set correctly. Even if there was more than one
worker, this variable was always only set to either 0 or 1.
This change required moving a bunch of helper code into RedsState as
well, an providing some RedDispatcher interfaces to access dispatcher
information from RedsState.
Signed-off-by: Jonathon Jongsma <jjongsma at redhat.com>
Signed-off-by: Frediano Ziglio <fziglio at redhat.com>
Acked-by: Fabiano Fidêncio <fidencio at redhat.com>
diff --git a/server/agent-msg-filter.c b/server/agent-msg-filter.c
index 1c1c01f..069822b 100644
--- a/server/agent-msg-filter.c
+++ b/server/agent-msg-filter.c
@@ -24,6 +24,7 @@
#include <string.h>
#include "red-common.h"
#include "agent-msg-filter.h"
+#include "reds.h"
#include "red-dispatcher.h"
void agent_msg_filter_init(struct AgentMsgFilter *filter,
@@ -92,7 +93,7 @@ data_to_read:
}
break;
case VD_AGENT_MONITORS_CONFIG:
- if (red_dispatcher_use_client_monitors_config()) {
+ if (reds_use_client_monitors_config(reds)) {
filter->result = AGENT_MSG_FILTER_MONITORS_CONFIG;
} else {
filter->result = AGENT_MSG_FILTER_OK;
diff --git a/server/red-dispatcher.c b/server/red-dispatcher.c
index 40d13fe..c2ca6b6 100644
--- a/server/red-dispatcher.c
+++ b/server/red-dispatcher.c
@@ -54,13 +54,10 @@ struct RedDispatcher {
int x_res;
int y_res;
int use_hardware_cursor;
- RedDispatcher *next;
QXLDevSurfaceCreate surface_create;
unsigned int max_monitors;
};
-static RedDispatcher *dispatchers = NULL;
-
static int red_dispatcher_check_qxl_version(RedDispatcher *rd, int major, int minor)
{
int qxl_major = rd->qxl->st->qif->base.major_version;
@@ -190,33 +187,6 @@ static void red_dispatcher_cursor_migrate(RedChannelClient *rcc)
&payload);
}
-static void reds_update_client_mouse_allowed(RedsState *reds)
-{
- static int allowed = FALSE;
- int allow_now = FALSE;
- int x_res = 0;
- int y_res = 0;
-
- allow_now = TRUE;
- RedDispatcher *now = dispatchers;
- while (now && allow_now) {
- if (now->primary_active) {
- allow_now = now->use_hardware_cursor;
- if (allow_now) {
- x_res = now->x_res;
- y_res = now->y_res;
- }
- break;
- }
- now = now->next;
- }
-
- if (allow_now || allow_now != allowed) {
- allowed = allow_now;
- reds_set_client_mouse_allowed(reds, allowed, x_res, y_res);
- }
-}
-
static void red_dispatcher_update_area(RedDispatcher *dispatcher, uint32_t surface_id,
QXLRect *qxl_area, QXLRect *qxl_dirty_rects,
uint32_t num_dirty_rects, uint32_t clear_dirty_region)
@@ -233,33 +203,19 @@ static void red_dispatcher_update_area(RedDispatcher *dispatcher, uint32_t surfa
&payload);
}
-int red_dispatcher_use_client_monitors_config(void)
+gboolean red_dispatcher_use_client_monitors_config(RedDispatcher *dispatcher)
{
- RedDispatcher *now = dispatchers;
-
- for (; now ; now = now->next) {
- if (!red_dispatcher_check_qxl_version(now, 3, 3) ||
- !now->qxl->st->qif->client_monitors_config ||
- !now->qxl->st->qif->client_monitors_config(now->qxl, NULL)) {
- return FALSE;
- }
- }
- return TRUE;
+ return (red_dispatcher_check_qxl_version(dispatcher, 3, 3) &&
+ dispatcher->qxl->st->qif->client_monitors_config &&
+ dispatcher->qxl->st->qif->client_monitors_config(dispatcher->qxl, NULL));
}
-void red_dispatcher_client_monitors_config(VDAgentMonitorsConfig *monitors_config)
+gboolean red_dispatcher_client_monitors_config(RedDispatcher *dispatcher,
+ VDAgentMonitorsConfig *monitors_config)
{
- RedDispatcher *now = dispatchers;
-
- while (now) {
- if (!now->qxl->st->qif->client_monitors_config ||
- !now->qxl->st->qif->client_monitors_config(now->qxl,
- monitors_config)) {
- /* this is a normal condition, some qemu devices might not implement it */
- spice_debug("QXLInterface::client_monitors_config failed");
- }
- now = now->next;
- }
+ return (dispatcher->qxl->st->qif->client_monitors_config &&
+ dispatcher->qxl->st->qif->client_monitors_config(dispatcher->qxl,
+ monitors_config));
}
static AsyncCommand *async_command_alloc(RedDispatcher *dispatcher,
@@ -682,6 +638,11 @@ static void qxl_worker_loadvm_commands(QXLWorker *qxl_worker,
red_dispatcher_loadvm_commands((RedDispatcher*)qxl_worker, ext, count);
}
+void red_dispatcher_set_mm_time(RedDispatcher *dispatcher, uint32_t mm_time)
+{
+ dispatcher->qxl->st->qif->set_mm_time(dispatcher->qxl, mm_time);
+}
+
void red_dispatcher_attach_worker(RedDispatcher *dispatcher)
{
QXLInstance *qxl = dispatcher->qxl;
@@ -693,13 +654,10 @@ void red_dispatcher_set_compression_level(RedDispatcher *dispatcher, int level)
dispatcher->qxl->st->qif->set_compression_level(dispatcher->qxl, level);
}
-uint32_t red_dispatcher_qxl_ram_size(void)
+uint32_t red_dispatcher_qxl_ram_size(RedDispatcher *dispatcher)
{
QXLDevInitInfo qxl_info;
- if (!dispatchers) {
- return 0;
- }
- dispatchers->qxl->st->qif->get_init_info(dispatchers->qxl, &qxl_info);
+ dispatcher->qxl->st->qif->get_init_info(dispatcher->qxl, &qxl_info);
return qxl_info.qxl_ram_size;
}
@@ -1010,8 +968,6 @@ void red_dispatcher_init(QXLInstance *qxl)
red_worker_run(worker);
qxl->st->dispatcher = red_dispatcher;
- red_dispatcher->next = dispatchers;
- dispatchers = red_dispatcher;
}
struct Dispatcher *red_dispatcher_get_dispatcher(RedDispatcher *red_dispatcher)
@@ -1032,6 +988,22 @@ void red_dispatcher_clear_pending(RedDispatcher *red_dispatcher, int pending)
clear_bit(pending, &red_dispatcher->pending);
}
+gboolean red_dispatcher_get_primary_active(RedDispatcher *dispatcher)
+{
+ return dispatcher->primary_active;
+}
+
+gboolean red_dispatcher_get_allow_client_mouse(RedDispatcher *dispatcher, gint *x_res, gint *y_res)
+{
+ if (dispatcher->use_hardware_cursor) {
+ if (x_res)
+ *x_res = dispatcher->x_res;
+ if (y_res)
+ *y_res = dispatcher->y_res;
+ }
+ return dispatcher->use_hardware_cursor;
+}
+
void red_dispatcher_on_ic_change(RedDispatcher *dispatcher, SpiceImageCompression ic)
{
RedWorkerMessageSetCompression payload;
diff --git a/server/red-dispatcher.h b/server/red-dispatcher.h
index 9614544..1aa63c2 100644
--- a/server/red-dispatcher.h
+++ b/server/red-dispatcher.h
@@ -26,6 +26,7 @@ typedef struct AsyncCommand AsyncCommand;
void red_dispatcher_init(QXLInstance *qxl);
+void red_dispatcher_set_mm_time(RedDispatcher *dispatcher, uint32_t);
void red_dispatcher_on_ic_change(RedDispatcher *dispatcher, SpiceImageCompression ic);
void red_dispatcher_on_sv_change(RedDispatcher *dispatcher, int sv);
void red_dispatcher_set_mouse_mode(RedDispatcher *dispatcher, uint32_t mode);
@@ -33,13 +34,13 @@ void red_dispatcher_attach_worker(RedDispatcher *dispatcher);
void red_dispatcher_set_compression_level(RedDispatcher *dispatcher, int level);
void red_dispatcher_stop(RedDispatcher *dispatcher);
void red_dispatcher_start(RedDispatcher *dispatcher);
-void red_dispatcher_on_vm_stop(void);
-void red_dispatcher_on_vm_start(void);
-uint32_t red_dispatcher_qxl_ram_size(void);
+uint32_t red_dispatcher_qxl_ram_size(RedDispatcher *dispatcher);
void red_dispatcher_async_complete(struct RedDispatcher *, AsyncCommand *);
struct Dispatcher *red_dispatcher_get_dispatcher(struct RedDispatcher *);
-int red_dispatcher_use_client_monitors_config(void);
-void red_dispatcher_client_monitors_config(VDAgentMonitorsConfig *monitors_config);
+gboolean red_dispatcher_use_client_monitors_config(RedDispatcher *dispatcher);
+gboolean red_dispatcher_client_monitors_config(RedDispatcher *dispatcher, VDAgentMonitorsConfig *monitors_config);
+gboolean red_dispatcher_get_primary_active(RedDispatcher *dispatcher);
+gboolean red_dispatcher_get_allow_client_mouse(RedDispatcher *dispatcher, gint *x_res, gint *y_res);
typedef uint32_t RedWorkerMessage;
diff --git a/server/reds.c b/server/reds.c
index 57b01b0..7ec7cdc 100644
--- a/server/reds.c
+++ b/server/reds.c
@@ -176,6 +176,9 @@ static void reds_on_ic_change(RedsState *reds);
static void reds_on_sv_change(RedsState *reds);
static void reds_on_vm_stop(RedsState *reds);
static void reds_on_vm_start(RedsState *reds);
+static void reds_set_mouse_mode(RedsState *reds, uint32_t mode);
+static uint32_t reds_qxl_ram_size(RedsState *reds);
+static int calc_compression_level(RedsState *reds);
static VDIReadBuf *vdi_port_state_get_read_buf(VDIPortState *state);
static VDIReadBuf *vdi_port_read_buf_ref(VDIReadBuf *buf);
@@ -1034,7 +1037,7 @@ static void reds_on_main_agent_monitors_config(RedsState *reds,
}
monitors_config = (VDAgentMonitorsConfig *)(cmc->buffer + sizeof(*msg_header));
spice_debug("%s: %d", __func__, monitors_config->num_of_monitors);
- red_dispatcher_client_monitors_config(monitors_config);
+ reds_client_monitors_config(reds, monitors_config);
reds_client_monitors_config_cleanup(reds);
}
@@ -1681,7 +1684,7 @@ static void reds_handle_main_link(RedsState *reds, RedLinkInfo *link)
main_channel_push_init(mcc, g_list_length(reds->dispatchers),
reds->mouse_mode, reds->is_client_mouse_allowed,
reds_get_mm_time() - MM_TIME_DELTA,
- red_dispatcher_qxl_ram_size());
+ reds_qxl_ram_size(reds));
if (reds->spice_name)
main_channel_push_name(mcc, reds->spice_name);
if (reds->spice_uuid_is_set)
@@ -1827,7 +1830,7 @@ void reds_on_client_semi_seamless_migrate_complete(RedsState *reds, RedClient *c
main_channel_push_init(mcc, g_list_length(reds->dispatchers),
reds->mouse_mode, reds->is_client_mouse_allowed,
reds_get_mm_time() - MM_TIME_DELTA,
- red_dispatcher_qxl_ram_size());
+ reds_qxl_ram_size(reds));
reds_link_mig_target_channels(reds, client);
main_channel_migrate_dst_complete(mcc);
}
@@ -4063,7 +4066,74 @@ SpiceCoreInterfaceInternal* reds_get_core_interface(RedsState *reds)
return reds->core;
}
-int calc_compression_level(RedsState *reds)
+void reds_update_client_mouse_allowed(RedsState *reds)
+{
+ static int allowed = FALSE;
+ int allow_now = FALSE;
+ int x_res = 0;
+ int y_res = 0;
+ GList *l;
+ int num_active_workers = g_list_length(reds->dispatchers);
+
+ if (num_active_workers > 0) {
+ allow_now = TRUE;
+ for (l = reds->dispatchers; l != NULL && allow_now; l = l->next) {
+
+ RedDispatcher *now = l->data;
+ if (red_dispatcher_get_primary_active(now)) {
+ allow_now = red_dispatcher_get_allow_client_mouse(now, &x_res, &y_res);
+ break;
+ }
+ }
+ }
+
+ if (allow_now || allow_now != allowed) {
+ allowed = allow_now;
+ reds_set_client_mouse_allowed(reds, allowed, x_res, y_res);
+ }
+}
+
+gboolean reds_use_client_monitors_config(RedsState *reds)
+{
+ GList *l;
+
+ if (reds->dispatchers == NULL) {
+ return FALSE;
+ }
+
+ for (l = reds->dispatchers; l != NULL ; l = l->next) {
+ RedDispatcher *now = l->data;
+
+ if (!red_dispatcher_use_client_monitors_config(now))
+ return FALSE;
+ }
+ return TRUE;
+}
+
+void reds_client_monitors_config(RedsState *reds, VDAgentMonitorsConfig *monitors_config)
+{
+ GList *l;
+
+ for (l = reds->dispatchers; l != NULL; l = l->next) {
+ RedDispatcher *now = l->data;
+ if (!red_dispatcher_client_monitors_config(now, monitors_config)) {
+ /* this is a normal condition, some qemu devices might not implement it */
+ spice_debug("QXLInterface::client_monitors_config failed\n");
+ }
+ }
+}
+
+void reds_set_mm_time(RedsState *reds, uint32_t mm_time)
+{
+ GList *l;
+
+ for (l = reds->dispatchers; l != NULL; l = l->next) {
+ RedDispatcher *now = l->data;
+ red_dispatcher_set_mm_time(now, mm_time);
+ }
+}
+
+static int calc_compression_level(RedsState *reds)
{
spice_assert(reds_get_streaming_video(reds) != SPICE_STREAM_VIDEO_INVALID);
@@ -4114,3 +4184,14 @@ void reds_on_vm_start(RedsState *reds)
for (l = reds->dispatchers; l != NULL; l = l->next)
red_dispatcher_start(l->data);
}
+
+uint32_t reds_qxl_ram_size(RedsState *reds)
+{
+ RedDispatcher *first;
+ if (!reds->dispatchers) {
+ return 0;
+ }
+
+ first = reds->dispatchers->data;
+ return red_dispatcher_qxl_ram_size(first);
+}
diff --git a/server/reds.h b/server/reds.h
index df34a88..686aaac 100644
--- a/server/reds.h
+++ b/server/reds.h
@@ -111,6 +111,9 @@ uint32_t reds_get_streaming_video(const RedsState *reds);
spice_wan_compression_t reds_get_jpeg_state(const RedsState *reds);
spice_wan_compression_t reds_get_zlib_glz_state(const RedsState *reds);
SpiceCoreInterfaceInternal* reds_get_core_interface(RedsState *reds);
-int calc_compression_level(RedsState *reds);
+void reds_update_client_mouse_allowed(RedsState *reds);
+gboolean reds_use_client_monitors_config(RedsState *reds);
+void reds_client_monitors_config(RedsState *reds, VDAgentMonitorsConfig *monitors_config);
+void reds_set_mm_time(RedsState *reds, uint32_t mm_time);
#endif
commit faa5364732c534a833c45c193ca5f50a84273494
Author: Frediano Ziglio <fziglio at redhat.com>
Date: Fri Feb 12 13:41:38 2016 +0000
move red_dispatcher_on_vm_stop and red_dispatcher_on_vm_start to RedsState
Signed-off-by: Jonathon Jongsma <jjongsma at redhat.com>
Signed-off-by: Frediano Ziglio <fziglio at redhat.com>
Acked-by: Fabiano Fidêncio <fidencio at redhat.com>
diff --git a/server/red-dispatcher.c b/server/red-dispatcher.c
index f634d28..40d13fe 100644
--- a/server/red-dispatcher.c
+++ b/server/red-dispatcher.c
@@ -599,7 +599,7 @@ static void qxl_worker_oom(QXLWorker *qxl_worker)
red_dispatcher_oom((RedDispatcher*)qxl_worker);
}
-static void red_dispatcher_start(RedDispatcher *dispatcher)
+void red_dispatcher_start(RedDispatcher *dispatcher)
{
RedWorkerMessageStart payload;
@@ -647,7 +647,7 @@ static void red_dispatcher_driver_unload(RedDispatcher *dispatcher)
&payload);
}
-static void red_dispatcher_stop(RedDispatcher *dispatcher)
+void red_dispatcher_stop(RedDispatcher *dispatcher)
{
RedWorkerMessageStop payload;
@@ -682,31 +682,15 @@ static void qxl_worker_loadvm_commands(QXLWorker *qxl_worker,
red_dispatcher_loadvm_commands((RedDispatcher*)qxl_worker, ext, count);
}
-void red_dispatcher_set_compression_level(RedDispatcher *dispatcher, int level)
-{
- dispatcher->qxl->st->qif->set_compression_level(dispatcher->qxl, level);
-}
-
-void red_dispatcher_on_vm_stop(void)
+void red_dispatcher_attach_worker(RedDispatcher *dispatcher)
{
- RedDispatcher *now = dispatchers;
-
- spice_debug(NULL);
- while (now) {
- red_dispatcher_stop(now);
- now = now->next;
- }
+ QXLInstance *qxl = dispatcher->qxl;
+ qxl->st->qif->attache_worker(qxl, &dispatcher->base);
}
-void red_dispatcher_on_vm_start(void)
+void red_dispatcher_set_compression_level(RedDispatcher *dispatcher, int level)
{
- RedDispatcher *now = dispatchers;
-
- spice_debug(NULL);
- while (now) {
- red_dispatcher_start(now);
- now = now->next;
- }
+ dispatcher->qxl->st->qif->set_compression_level(dispatcher->qxl, level);
}
uint32_t red_dispatcher_qxl_ram_size(void)
@@ -1028,9 +1012,6 @@ void red_dispatcher_init(QXLInstance *qxl)
qxl->st->dispatcher = red_dispatcher;
red_dispatcher->next = dispatchers;
dispatchers = red_dispatcher;
-
- qxl->st->qif->attache_worker(qxl, &red_dispatcher->base);
- qxl->st->qif->set_compression_level(qxl, calc_compression_level(reds));
}
struct Dispatcher *red_dispatcher_get_dispatcher(RedDispatcher *red_dispatcher)
diff --git a/server/red-dispatcher.h b/server/red-dispatcher.h
index 2279680..9614544 100644
--- a/server/red-dispatcher.h
+++ b/server/red-dispatcher.h
@@ -29,7 +29,10 @@ void red_dispatcher_init(QXLInstance *qxl);
void red_dispatcher_on_ic_change(RedDispatcher *dispatcher, SpiceImageCompression ic);
void red_dispatcher_on_sv_change(RedDispatcher *dispatcher, int sv);
void red_dispatcher_set_mouse_mode(RedDispatcher *dispatcher, uint32_t mode);
+void red_dispatcher_attach_worker(RedDispatcher *dispatcher);
void red_dispatcher_set_compression_level(RedDispatcher *dispatcher, int level);
+void red_dispatcher_stop(RedDispatcher *dispatcher);
+void red_dispatcher_start(RedDispatcher *dispatcher);
void red_dispatcher_on_vm_stop(void);
void red_dispatcher_on_vm_start(void);
uint32_t red_dispatcher_qxl_ram_size(void);
diff --git a/server/reds.c b/server/reds.c
index 0f8f69a..57b01b0 100644
--- a/server/reds.c
+++ b/server/reds.c
@@ -174,6 +174,8 @@ static void reds_char_device_remove_state(RedsState *reds, SpiceCharDeviceState
static void reds_send_mm_time(RedsState *reds);
static void reds_on_ic_change(RedsState *reds);
static void reds_on_sv_change(RedsState *reds);
+static void reds_on_vm_stop(RedsState *reds);
+static void reds_on_vm_start(RedsState *reds);
static VDIReadBuf *vdi_port_state_get_read_buf(VDIPortState *state);
static VDIReadBuf *vdi_port_read_buf_ref(VDIReadBuf *buf);
@@ -3190,6 +3192,7 @@ SPICE_GNUC_VISIBLE int spice_server_add_interface(SpiceServer *s,
}
} else if (strcmp(interface->type, SPICE_INTERFACE_QXL) == 0) {
QXLInstance *qxl;
+ RedDispatcher *dispatcher;
spice_info("SPICE_INTERFACE_QXL");
if (interface->major_version != SPICE_INTERFACE_QXL_MAJOR ||
@@ -3204,8 +3207,16 @@ SPICE_GNUC_VISIBLE int spice_server_add_interface(SpiceServer *s,
qxl->st->scanout.drm_dma_buf_fd = -1;
qxl->st->qif = SPICE_CONTAINEROF(interface, QXLInterface, base);
red_dispatcher_init(qxl);
- reds->dispatchers = g_list_prepend(reds->dispatchers, qxl->st->dispatcher);
-
+ dispatcher = qxl->st->dispatcher;
+ reds->dispatchers = g_list_prepend(reds->dispatchers, dispatcher);
+
+ /* this function has to be called after the dispatcher is on the list
+ * as QXLInstance clients expect the dispatcher to be on the list when
+ * this callback is called. This as clients assume they can start the
+ * dispatchers. Also note that this should be the first callback to
+ * be called. */
+ red_dispatcher_attach_worker(dispatcher);
+ red_dispatcher_set_compression_level(dispatcher, 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");
@@ -3999,7 +4010,7 @@ SPICE_GNUC_VISIBLE void spice_server_vm_start(SpiceServer *s)
st_item = SPICE_CONTAINEROF(item, SpiceCharDeviceStateItem, link);
spice_char_device_start(st_item->st);
}
- red_dispatcher_on_vm_start();
+ reds_on_vm_start(reds);
}
SPICE_GNUC_VISIBLE void spice_server_vm_stop(SpiceServer *s)
@@ -4014,7 +4025,7 @@ SPICE_GNUC_VISIBLE void spice_server_vm_stop(SpiceServer *s)
st_item = SPICE_CONTAINEROF(item, SpiceCharDeviceStateItem, link);
spice_char_device_stop(st_item->st);
}
- red_dispatcher_on_vm_stop();
+ reds_on_vm_stop(reds);
}
SPICE_GNUC_VISIBLE void spice_server_set_seamless_migration(SpiceServer *s, int enable)
@@ -4087,3 +4098,19 @@ void reds_on_sv_change(RedsState *reds)
red_dispatcher_on_sv_change(d, reds_get_streaming_video(reds));
}
}
+
+void reds_on_vm_stop(RedsState *reds)
+{
+ GList *l;
+
+ for (l = reds->dispatchers; l != NULL; l = l->next)
+ red_dispatcher_stop(l->data);
+}
+
+void reds_on_vm_start(RedsState *reds)
+{
+ GList *l;
+
+ for (l = reds->dispatchers; l != NULL; l = l->next)
+ red_dispatcher_start(l->data);
+}
commit 7ac2bfc2d8893aad8879556f67fe3a7f33d41426
Author: Frediano Ziglio <fziglio at redhat.com>
Date: Fri Feb 12 13:23:26 2016 +0000
remove unused function
Signed-off-by: Jonathon Jongsma <jjongsma at redhat.com>
Signed-off-by: Frediano Ziglio <fziglio at redhat.com>
Acked-by: Fabiano Fidêncio <fidencio at redhat.com>
diff --git a/server/red-dispatcher.c b/server/red-dispatcher.c
index 7d755c1..f634d28 100644
--- a/server/red-dispatcher.c
+++ b/server/red-dispatcher.c
@@ -709,18 +709,6 @@ void red_dispatcher_on_vm_start(void)
}
}
-int red_dispatcher_count(void)
-{
- RedDispatcher *now = dispatchers;
- int ret = 0;
-
- while (now) {
- ret++;
- now = now->next;
- }
- return ret;
-}
-
uint32_t red_dispatcher_qxl_ram_size(void)
{
QXLDevInitInfo qxl_info;
diff --git a/server/red-dispatcher.h b/server/red-dispatcher.h
index bfb74fe..2279680 100644
--- a/server/red-dispatcher.h
+++ b/server/red-dispatcher.h
@@ -32,7 +32,6 @@ void red_dispatcher_set_mouse_mode(RedDispatcher *dispatcher, uint32_t mode);
void red_dispatcher_set_compression_level(RedDispatcher *dispatcher, int level);
void red_dispatcher_on_vm_stop(void);
void red_dispatcher_on_vm_start(void);
-int red_dispatcher_count(void);
uint32_t red_dispatcher_qxl_ram_size(void);
void red_dispatcher_async_complete(struct RedDispatcher *, AsyncCommand *);
struct Dispatcher *red_dispatcher_get_dispatcher(struct RedDispatcher *);
commit 577966e48254e1eaafe4682125a83a9f53b5b9f1
Author: Frediano Ziglio <fziglio at redhat.com>
Date: Fri Feb 12 13:20:36 2016 +0000
use list in RedsState for ic_change and sv_change
Instead of using list in RedDispatcher (which is going to be removed)
use the one in RedsState.
Signed-off-by: Jonathon Jongsma <jjongsma at redhat.com>
Signed-off-by: Frediano Ziglio <fziglio at redhat.com>
Acked-by: Fabiano Fidêncio <fidencio at redhat.com>
diff --git a/server/red-dispatcher.c b/server/red-dispatcher.c
index 68423a1..7d755c1 100644
--- a/server/red-dispatcher.c
+++ b/server/red-dispatcher.c
@@ -682,35 +682,9 @@ static void qxl_worker_loadvm_commands(QXLWorker *qxl_worker,
red_dispatcher_loadvm_commands((RedDispatcher*)qxl_worker, ext, count);
}
-void red_dispatcher_on_ic_change(void)
+void red_dispatcher_set_compression_level(RedDispatcher *dispatcher, int level)
{
- RedWorkerMessageSetCompression payload;
- int compression_level = calc_compression_level(reds);
- RedDispatcher *now = dispatchers;
-
- while (now) {
- now->qxl->st->qif->set_compression_level(now->qxl, compression_level);
- payload.image_compression = spice_server_get_image_compression(reds);
- dispatcher_send_message(&now->dispatcher,
- RED_WORKER_MESSAGE_SET_COMPRESSION,
- &payload);
- now = now->next;
- }
-}
-
-void red_dispatcher_on_sv_change(void)
-{
- RedWorkerMessageSetStreamingVideo payload;
- int compression_level = calc_compression_level(reds);
- RedDispatcher *now = dispatchers;
- while (now) {
- now->qxl->st->qif->set_compression_level(now->qxl, compression_level);
- payload.streaming_video = reds_get_streaming_video(reds);
- dispatcher_send_message(&now->dispatcher,
- RED_WORKER_MESSAGE_SET_STREAMING_VIDEO,
- &payload);
- now = now->next;
- }
+ dispatcher->qxl->st->qif->set_compression_level(dispatcher->qxl, level);
}
void red_dispatcher_on_vm_stop(void)
@@ -1089,6 +1063,24 @@ void red_dispatcher_clear_pending(RedDispatcher *red_dispatcher, int pending)
clear_bit(pending, &red_dispatcher->pending);
}
+void red_dispatcher_on_ic_change(RedDispatcher *dispatcher, SpiceImageCompression ic)
+{
+ RedWorkerMessageSetCompression payload;
+ payload.image_compression = ic;
+ dispatcher_send_message(&dispatcher->dispatcher,
+ RED_WORKER_MESSAGE_SET_COMPRESSION,
+ &payload);
+}
+
+void red_dispatcher_on_sv_change(RedDispatcher *dispatcher, int sv)
+{
+ RedWorkerMessageSetStreamingVideo payload;
+ payload.streaming_video = sv;
+ dispatcher_send_message(&dispatcher->dispatcher,
+ RED_WORKER_MESSAGE_SET_STREAMING_VIDEO,
+ &payload);
+}
+
void red_dispatcher_set_mouse_mode(RedDispatcher *dispatcher, uint32_t mode)
{
RedWorkerMessageSetMouseMode payload;
diff --git a/server/red-dispatcher.h b/server/red-dispatcher.h
index 1c0c218..bfb74fe 100644
--- a/server/red-dispatcher.h
+++ b/server/red-dispatcher.h
@@ -26,9 +26,10 @@ typedef struct AsyncCommand AsyncCommand;
void red_dispatcher_init(QXLInstance *qxl);
-void red_dispatcher_on_ic_change(void);
-void red_dispatcher_on_sv_change(void);
+void red_dispatcher_on_ic_change(RedDispatcher *dispatcher, SpiceImageCompression ic);
+void red_dispatcher_on_sv_change(RedDispatcher *dispatcher, int sv);
void red_dispatcher_set_mouse_mode(RedDispatcher *dispatcher, uint32_t mode);
+void red_dispatcher_set_compression_level(RedDispatcher *dispatcher, int level);
void red_dispatcher_on_vm_stop(void);
void red_dispatcher_on_vm_start(void);
int red_dispatcher_count(void);
diff --git a/server/reds.c b/server/reds.c
index 3882477..0f8f69a 100644
--- a/server/reds.c
+++ b/server/reds.c
@@ -172,6 +172,8 @@ static void reds_mig_remove_wait_disconnect_client(RedsState *reds, RedClient *c
static void reds_char_device_add_state(RedsState *reds, SpiceCharDeviceState *st);
static void reds_char_device_remove_state(RedsState *reds, SpiceCharDeviceState *st);
static void reds_send_mm_time(RedsState *reds);
+static void reds_on_ic_change(RedsState *reds);
+static void reds_on_sv_change(RedsState *reds);
static VDIReadBuf *vdi_port_state_get_read_buf(VDIPortState *state);
static VDIReadBuf *vdi_port_read_buf_ref(VDIReadBuf *buf);
@@ -2774,7 +2776,7 @@ static void reds_set_image_compression(RedsState *reds, SpiceImageCompression va
return;
}
reds->image_compression = val;
- red_dispatcher_on_ic_change();
+ reds_on_ic_change(reds);
}
static void reds_set_one_channel_security(RedsState *reds, int id, uint32_t security)
@@ -3797,7 +3799,7 @@ SPICE_GNUC_VISIBLE int spice_server_set_streaming_video(SpiceServer *s, int valu
value != SPICE_STREAM_VIDEO_FILTER)
return -1;
s->streaming_video = value;
- red_dispatcher_on_sv_change();
+ reds_on_sv_change(reds);
return 0;
}
@@ -4061,3 +4063,27 @@ int calc_compression_level(RedsState *reds)
return 1;
}
}
+
+void reds_on_ic_change(RedsState *reds)
+{
+ int compression_level = calc_compression_level(reds);
+ GList *l;
+
+ for (l = reds->dispatchers; l != NULL; l = l->next) {
+ RedDispatcher *d = l->data;
+ red_dispatcher_set_compression_level(d, compression_level);
+ red_dispatcher_on_ic_change(d, spice_server_get_image_compression(reds));
+ }
+}
+
+void reds_on_sv_change(RedsState *reds)
+{
+ int compression_level = calc_compression_level(reds);
+ GList *l;
+
+ for (l = reds->dispatchers; l != NULL; l = l->next) {
+ RedDispatcher *d = l->data;
+ red_dispatcher_set_compression_level(d, compression_level);
+ red_dispatcher_on_sv_change(d, reds_get_streaming_video(reds));
+ }
+}
commit 0435ab30d5f59d8506a70ed161c02c54f2956d1e
Author: Frediano Ziglio <fziglio at redhat.com>
Date: Fri Feb 12 13:08:33 2016 +0000
keep dispatcher list in RedsState
This duplicate the other list which will be removed
Signed-off-by: Jonathon Jongsma <jjongsma at redhat.com>
Signed-off-by: Frediano Ziglio <fziglio at redhat.com>
Acked-by: Fabiano Fidêncio <fidencio at redhat.com>
diff --git a/server/red-dispatcher.c b/server/red-dispatcher.c
index 9ec760f..68423a1 100644
--- a/server/red-dispatcher.c
+++ b/server/red-dispatcher.c
@@ -713,19 +713,6 @@ void red_dispatcher_on_sv_change(void)
}
}
-void red_dispatcher_set_mouse_mode(uint32_t mode)
-{
- RedWorkerMessageSetMouseMode payload;
- RedDispatcher *now = dispatchers;
- while (now) {
- payload.mode = mode;
- dispatcher_send_message(&now->dispatcher,
- RED_WORKER_MESSAGE_SET_MOUSE_MODE,
- &payload);
- now = now->next;
- }
-}
-
void red_dispatcher_on_vm_stop(void)
{
RedDispatcher *now = dispatchers;
@@ -1101,3 +1088,12 @@ void red_dispatcher_clear_pending(RedDispatcher *red_dispatcher, int pending)
clear_bit(pending, &red_dispatcher->pending);
}
+
+void red_dispatcher_set_mouse_mode(RedDispatcher *dispatcher, uint32_t mode)
+{
+ RedWorkerMessageSetMouseMode payload;
+ payload.mode = mode;
+ dispatcher_send_message(&dispatcher->dispatcher,
+ RED_WORKER_MESSAGE_SET_MOUSE_MODE,
+ &payload);
+}
diff --git a/server/red-dispatcher.h b/server/red-dispatcher.h
index 4aa5854..1c0c218 100644
--- a/server/red-dispatcher.h
+++ b/server/red-dispatcher.h
@@ -28,7 +28,7 @@ void red_dispatcher_init(QXLInstance *qxl);
void red_dispatcher_on_ic_change(void);
void red_dispatcher_on_sv_change(void);
-void red_dispatcher_set_mouse_mode(uint32_t mode);
+void red_dispatcher_set_mouse_mode(RedDispatcher *dispatcher, uint32_t mode);
void red_dispatcher_on_vm_stop(void);
void red_dispatcher_on_vm_start(void);
int red_dispatcher_count(void);
diff --git a/server/reds-private.h b/server/reds-private.h
index 2272d4c..c214091 100644
--- a/server/reds-private.h
+++ b/server/reds-private.h
@@ -241,7 +241,7 @@ struct RedsState {
RedSSLParameters ssl_parameters;
SpiceCoreInterfaceInternal *core;
-
+ GList *dispatchers;
};
#endif
diff --git a/server/reds.c b/server/reds.c
index 418f89a..3882477 100644
--- a/server/reds.c
+++ b/server/reds.c
@@ -556,11 +556,16 @@ int reds_get_mouse_mode(RedsState *reds)
static void reds_set_mouse_mode(RedsState *reds, uint32_t mode)
{
+ GList *l;
+
if (reds->mouse_mode == mode) {
return;
}
reds->mouse_mode = mode;
- red_dispatcher_set_mouse_mode(reds->mouse_mode);
+
+ for (l = reds->dispatchers; l != NULL; l = l->next)
+ red_dispatcher_set_mouse_mode(l->data, mode);
+
main_channel_push_mouse_mode(reds->main_channel, reds->mouse_mode, reds->is_client_mouse_allowed);
}
@@ -572,9 +577,10 @@ 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->dispatchers);
if ((reds->agent_mouse && reds->vdagent) ||
- (inputs_channel_has_tablet(reds->inputs_channel))) {
+ (inputs_channel_has_tablet(reds->inputs_channel) && qxl_count == 1)) {
allowed = reds->dispatcher_allows_client_mouse;
}
if (allowed == reds->is_client_mouse_allowed) {
@@ -1668,7 +1674,7 @@ static void reds_handle_main_link(RedsState *reds, RedLinkInfo *link)
}
if (!mig_target) {
- main_channel_push_init(mcc, red_dispatcher_count(),
+ main_channel_push_init(mcc, g_list_length(reds->dispatchers),
reds->mouse_mode, reds->is_client_mouse_allowed,
reds_get_mm_time() - MM_TIME_DELTA,
red_dispatcher_qxl_ram_size());
@@ -1814,7 +1820,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, red_dispatcher_count(),
+ main_channel_push_init(mcc, g_list_length(reds->dispatchers),
reds->mouse_mode, reds->is_client_mouse_allowed,
reds_get_mm_time() - MM_TIME_DELTA,
red_dispatcher_qxl_ram_size());
@@ -3196,6 +3202,7 @@ SPICE_GNUC_VISIBLE int spice_server_add_interface(SpiceServer *s,
qxl->st->scanout.drm_dma_buf_fd = -1;
qxl->st->qif = SPICE_CONTAINEROF(interface, QXLInterface, base);
red_dispatcher_init(qxl);
+ reds->dispatchers = g_list_prepend(reds->dispatchers, qxl->st->dispatcher);
} else if (strcmp(interface->type, SPICE_INTERFACE_TABLET) == 0) {
SpiceTabletInstance *tablet = SPICE_CONTAINEROF(sin, SpiceTabletInstance, base);
commit e98ed23bc22af6569f3616c094be5606d28b036f
Author: Frediano Ziglio <fziglio at redhat.com>
Date: Fri Feb 12 12:34:44 2016 +0000
move calc_compression_level to reds
Signed-off-by: Jonathon Jongsma <jjongsma at redhat.com>
Signed-off-by: Frediano Ziglio <fziglio at redhat.com>
Acked-by: Fabiano Fidêncio <fidencio at redhat.com>
diff --git a/server/red-dispatcher.c b/server/red-dispatcher.c
index 3061735..9ec760f 100644
--- a/server/red-dispatcher.c
+++ b/server/red-dispatcher.c
@@ -682,22 +682,10 @@ static void qxl_worker_loadvm_commands(QXLWorker *qxl_worker,
red_dispatcher_loadvm_commands((RedDispatcher*)qxl_worker, ext, count);
}
-static inline int calc_compression_level(void)
-{
- spice_assert(reds_get_streaming_video(reds) != SPICE_STREAM_VIDEO_INVALID);
-
- if ((reds_get_streaming_video(reds) != SPICE_STREAM_VIDEO_OFF) ||
- (spice_server_get_image_compression(reds) != SPICE_IMAGE_COMPRESSION_QUIC)) {
- return 0;
- } else {
- return 1;
- }
-}
-
void red_dispatcher_on_ic_change(void)
{
RedWorkerMessageSetCompression payload;
- int compression_level = calc_compression_level();
+ int compression_level = calc_compression_level(reds);
RedDispatcher *now = dispatchers;
while (now) {
@@ -713,7 +701,7 @@ void red_dispatcher_on_ic_change(void)
void red_dispatcher_on_sv_change(void)
{
RedWorkerMessageSetStreamingVideo payload;
- int compression_level = calc_compression_level();
+ int compression_level = calc_compression_level(reds);
RedDispatcher *now = dispatchers;
while (now) {
now->qxl->st->qif->set_compression_level(now->qxl, compression_level);
@@ -1093,7 +1081,7 @@ void red_dispatcher_init(QXLInstance *qxl)
dispatchers = red_dispatcher;
qxl->st->qif->attache_worker(qxl, &red_dispatcher->base);
- qxl->st->qif->set_compression_level(qxl, calc_compression_level());
+ qxl->st->qif->set_compression_level(qxl, calc_compression_level(reds));
}
struct Dispatcher *red_dispatcher_get_dispatcher(RedDispatcher *red_dispatcher)
diff --git a/server/reds.c b/server/reds.c
index e621a25..418f89a 100644
--- a/server/reds.c
+++ b/server/reds.c
@@ -4042,3 +4042,15 @@ SpiceCoreInterfaceInternal* reds_get_core_interface(RedsState *reds)
{
return reds->core;
}
+
+int calc_compression_level(RedsState *reds)
+{
+ spice_assert(reds_get_streaming_video(reds) != SPICE_STREAM_VIDEO_INVALID);
+
+ if ((reds_get_streaming_video(reds) != SPICE_STREAM_VIDEO_OFF) ||
+ (spice_server_get_image_compression(reds) != SPICE_IMAGE_COMPRESSION_QUIC)) {
+ return 0;
+ } else {
+ return 1;
+ }
+}
diff --git a/server/reds.h b/server/reds.h
index 6caed73..df34a88 100644
--- a/server/reds.h
+++ b/server/reds.h
@@ -111,5 +111,6 @@ uint32_t reds_get_streaming_video(const RedsState *reds);
spice_wan_compression_t reds_get_jpeg_state(const RedsState *reds);
spice_wan_compression_t reds_get_zlib_glz_state(const RedsState *reds);
SpiceCoreInterfaceInternal* reds_get_core_interface(RedsState *reds);
+int calc_compression_level(RedsState *reds);
#endif
commit 2e688f91ed6add82e99a1026b3ef0561d5ac51de
Author: Frediano Ziglio <fziglio at redhat.com>
Date: Fri Feb 12 12:27:53 2016 +0000
add RedsState parameter to update_client_mouse_allowed
Signed-off-by: Jonathon Jongsma <jjongsma at redhat.com>
Signed-off-by: Frediano Ziglio <fziglio at redhat.com>
Acked-by: Fabiano Fidêncio <fidencio at redhat.com>
diff --git a/server/red-dispatcher.c b/server/red-dispatcher.c
index 81f2ed9..3061735 100644
--- a/server/red-dispatcher.c
+++ b/server/red-dispatcher.c
@@ -190,7 +190,7 @@ static void red_dispatcher_cursor_migrate(RedChannelClient *rcc)
&payload);
}
-static void update_client_mouse_allowed(void)
+static void reds_update_client_mouse_allowed(RedsState *reds)
{
static int allowed = FALSE;
int allow_now = FALSE;
@@ -371,7 +371,7 @@ static void red_dispatcher_destroy_primary_surface_complete(RedDispatcher *dispa
dispatcher->use_hardware_cursor = FALSE;
dispatcher->primary_active = FALSE;
- update_client_mouse_allowed();
+ reds_update_client_mouse_allowed(reds);
}
static void
@@ -423,7 +423,7 @@ static void red_dispatcher_create_primary_surface_complete(RedDispatcher *dispat
dispatcher->use_hardware_cursor = surface->mouse_mode;
dispatcher->primary_active = TRUE;
- update_client_mouse_allowed();
+ reds_update_client_mouse_allowed(reds);
memset(&dispatcher->surface_create, 0, sizeof(QXLDevSurfaceCreate));
}
commit 8bdc63495afe0f72319d9a7f5c5ce014c561115c
Author: Frediano Ziglio <fziglio at redhat.com>
Date: Fri Feb 12 12:20:18 2016 +0000
remove num_active_workers
This global variable was mainly 1.
Signed-off-by: Jonathon Jongsma <jjongsma at redhat.com>
Signed-off-by: Frediano Ziglio <fziglio at redhat.com>
Acked-by: Fabiano Fidêncio <fidencio at redhat.com>
diff --git a/server/red-dispatcher.c b/server/red-dispatcher.c
index 11355e4..81f2ed9 100644
--- a/server/red-dispatcher.c
+++ b/server/red-dispatcher.c
@@ -39,7 +39,6 @@
#include "red-dispatcher.h"
-static int num_active_workers = 0;
struct AsyncCommand {
RedWorkerMessage message;
@@ -191,11 +190,6 @@ static void red_dispatcher_cursor_migrate(RedChannelClient *rcc)
&payload);
}
-int red_dispatcher_qxl_count(void)
-{
- return num_active_workers;
-}
-
static void update_client_mouse_allowed(void)
{
static int allowed = FALSE;
@@ -203,22 +197,18 @@ static void update_client_mouse_allowed(void)
int x_res = 0;
int y_res = 0;
- if (num_active_workers > 0) {
- allow_now = TRUE;
- RedDispatcher *now = dispatchers;
- while (now && allow_now) {
- if (now->primary_active) {
- allow_now = now->use_hardware_cursor;
- if (num_active_workers == 1) {
- if (allow_now) {
- x_res = now->x_res;
- y_res = now->y_res;
- }
- break;
- }
+ allow_now = TRUE;
+ RedDispatcher *now = dispatchers;
+ while (now && allow_now) {
+ if (now->primary_active) {
+ allow_now = now->use_hardware_cursor;
+ if (allow_now) {
+ x_res = now->x_res;
+ y_res = now->y_res;
}
- now = now->next;
+ break;
}
+ now = now->next;
}
if (allow_now || allow_now != allowed) {
@@ -247,10 +237,6 @@ int red_dispatcher_use_client_monitors_config(void)
{
RedDispatcher *now = dispatchers;
- if (num_active_workers == 0) {
- return FALSE;
- }
-
for (; now ; now = now->next) {
if (!red_dispatcher_check_qxl_version(now, 3, 3) ||
!now->qxl->st->qif->client_monitors_config ||
@@ -1101,7 +1087,6 @@ void red_dispatcher_init(QXLInstance *qxl)
reds_register_channel(reds, channel);
red_worker_run(worker);
- num_active_workers = 1;
qxl->st->dispatcher = red_dispatcher;
red_dispatcher->next = dispatchers;
diff --git a/server/red-dispatcher.h b/server/red-dispatcher.h
index 11a4f2a..4aa5854 100644
--- a/server/red-dispatcher.h
+++ b/server/red-dispatcher.h
@@ -33,7 +33,6 @@ void red_dispatcher_on_vm_stop(void);
void red_dispatcher_on_vm_start(void);
int red_dispatcher_count(void);
uint32_t red_dispatcher_qxl_ram_size(void);
-int red_dispatcher_qxl_count(void);
void red_dispatcher_async_complete(struct RedDispatcher *, AsyncCommand *);
struct Dispatcher *red_dispatcher_get_dispatcher(struct RedDispatcher *);
int red_dispatcher_use_client_monitors_config(void);
diff --git a/server/reds.c b/server/reds.c
index 01d4db5..e621a25 100644
--- a/server/reds.c
+++ b/server/reds.c
@@ -572,10 +572,9 @@ gboolean reds_get_agent_mouse(const RedsState *reds)
static void reds_update_mouse_mode(RedsState *reds)
{
int allowed = 0;
- int qxl_count = red_dispatcher_qxl_count();
if ((reds->agent_mouse && reds->vdagent) ||
- (inputs_channel_has_tablet(reds->inputs_channel) && qxl_count == 1)) {
+ (inputs_channel_has_tablet(reds->inputs_channel))) {
allowed = reds->dispatcher_allows_client_mouse;
}
if (allowed == reds->is_client_mouse_allowed) {
More information about the Spice-commits
mailing list