[Spice-commits] 3 commits - configure.ac meson.build server/display-limits.h server/red-qxl.c server/red-qxl.h server/reds.c server/reds.h server/reds-private.h server/red-stream-device.c server/red-stream-device.h
GitLab Mirror
gitlab-mirror at kemper.freedesktop.org
Tue Jan 29 14:47:29 UTC 2019
configure.ac | 2
meson.build | 2
server/display-limits.h | 3 +
server/red-qxl.c | 22 +++++++
server/red-qxl.h | 3 +
server/red-stream-device.c | 96 +++++++++++++++++++++++++++++++++-
server/red-stream-device.h | 15 +++++
server/reds-private.h | 1
server/reds.c | 126 +++++++++++++++++++++++++++++++++++++++++++++
server/reds.h | 1
10 files changed, 266 insertions(+), 5 deletions(-)
New commits:
commit c8e949cea162e5379b3ef6b202abe17146ae901a
Author: Lukáš Hrázký <lhrazky at redhat.com>
Date: Fri Dec 14 11:19:46 2018 +0100
Send the graphics device info from streaming agent to the vd_agent
Adds the graphics device info from the streaming device(s) to the
VDAgentGraphicsDeviceInfo message sent to the vd_agent.
Signed-off-by: Lukáš Hrázký <lhrazky at redhat.com>
Acked-by: Jonathon Jongsma <jjongsma at redhat.com>
diff --git a/server/red-stream-device.c b/server/red-stream-device.c
index 38df8e4c..440b2689 100644
--- a/server/red-stream-device.c
+++ b/server/red-stream-device.c
@@ -346,6 +346,8 @@ handle_msg_device_display_info(StreamDevice *dev, SpiceCharDeviceInstance *sin)
dev->device_display_info.device_address,
dev->device_display_info.device_display_id);
+ reds_send_device_display_info(red_char_device_get_server(RED_CHAR_DEVICE(dev)));
+
return true;
}
@@ -805,6 +807,22 @@ stream_device_init(StreamDevice *dev)
dev->msg_len = sizeof(*dev->msg);
}
+StreamDeviceDisplayInfo *stream_device_get_device_display_info(StreamDevice *dev)
+{
+ return &dev->device_display_info;
+}
+
+int32_t stream_device_get_stream_channel_id(StreamDevice *dev)
+{
+ if (dev->stream_channel == NULL) {
+ return -1;
+ }
+
+ int32_t channel_id;
+ g_object_get(dev->stream_channel, "id", &channel_id, NULL);
+ return channel_id;
+}
+
static StreamDevice *
stream_device_new(SpiceCharDeviceInstance *sin, RedsState *reds)
{
diff --git a/server/red-stream-device.h b/server/red-stream-device.h
index 996be016..d7ab5e41 100644
--- a/server/red-stream-device.h
+++ b/server/red-stream-device.h
@@ -56,6 +56,13 @@ StreamDevice *stream_device_connect(RedsState *reds, SpiceCharDeviceInstance *si
*/
void stream_device_create_channel(StreamDevice *dev);
+StreamDeviceDisplayInfo *stream_device_get_device_display_info(StreamDevice *dev);
+
+/**
+ * Returns -1 if the StreamDevice doesn't have a channel yet.
+ */
+int32_t stream_device_get_stream_channel_id(StreamDevice *dev);
+
G_END_DECLS
#endif /* STREAM_DEVICE_H */
diff --git a/server/reds.c b/server/reds.c
index c4ec2a3f..d7a71dc1 100644
--- a/server/reds.c
+++ b/server/reds.c
@@ -902,14 +902,33 @@ void reds_send_device_display_info(RedsState *reds)
}
g_debug("Sending device display info to the agent:");
- size_t message_size = sizeof(VDAgentGraphicsDeviceInfo);
QXLInstance *qxl;
+ RedCharDevice *dev;
+
+ size_t message_size = sizeof(VDAgentGraphicsDeviceInfo);
+
+ // size for the qxl device info
FOREACH_QXL_INSTANCE(reds, qxl) {
message_size +=
(sizeof(VDAgentDeviceDisplayInfo) + strlen(red_qxl_get_device_address(qxl)) + 1) *
red_qxl_get_monitors_count(qxl);
}
+ // size for the stream device info
+ GLIST_FOREACH(reds->char_devices, RedCharDevice, dev) {
+ if (IS_STREAM_DEVICE(dev)) {
+ size_t device_address_len =
+ strlen(stream_device_get_device_display_info(STREAM_DEVICE(dev))->device_address);
+
+ if (device_address_len == 0) {
+ // the device info wasn't set (yet), don't send it
+ continue;
+ }
+
+ message_size += (sizeof(VDAgentDeviceDisplayInfo) + device_address_len + 1);
+ }
+ }
+
RedCharDeviceWriteBuffer *char_dev_buf = vdagent_new_write_buffer(reds->agent_dev,
VD_AGENT_GRAPHICS_DEVICE_INFO,
message_size,
@@ -925,6 +944,8 @@ void reds_send_device_display_info(RedsState *reds)
graphics_device_info->count = 0;
VDAgentDeviceDisplayInfo *device_display_info = graphics_device_info->display_info;
+
+ // add the qxl devices to the message
FOREACH_QXL_INSTANCE(reds, qxl) {
for (size_t i = 0; i < red_qxl_get_monitors_count(qxl); ++i) {
device_display_info->channel_id = qxl->id;
@@ -936,7 +957,45 @@ void reds_send_device_display_info(RedsState *reds)
device_display_info->device_address_len =
strlen((char*) device_display_info->device_address) + 1;
- g_debug(" channel_id: %u monitor_id: %u, device_address: %s, device_display_id: %u",
+ g_debug(" (qxl) channel_id: %u monitor_id: %u, device_address: %s, device_display_id: %u",
+ device_display_info->channel_id,
+ device_display_info->monitor_id,
+ device_display_info->device_address,
+ device_display_info->device_display_id);
+
+ device_display_info = (VDAgentDeviceDisplayInfo*) ((char*) device_display_info +
+ sizeof(VDAgentDeviceDisplayInfo) + device_display_info->device_address_len);
+
+ graphics_device_info->count++;
+ }
+ }
+
+ // add the stream devices to the message
+ GLIST_FOREACH(reds->char_devices, RedCharDevice, dev) {
+ if (IS_STREAM_DEVICE(dev)) {
+ StreamDevice *stream_dev = STREAM_DEVICE(dev);
+ StreamDeviceDisplayInfo *info = stream_device_get_device_display_info(stream_dev);
+ size_t device_address_len = strlen(info->device_address);
+
+ if (device_address_len == 0) {
+ // the device info wasn't set (yet), don't send it
+ continue;
+ }
+
+ int32_t channel_id = stream_device_get_stream_channel_id(stream_dev);
+ if (channel_id == -1) {
+ g_warning("DeviceDisplayInfo set but no stream channel exists");
+ continue;
+ }
+
+ device_display_info->channel_id = channel_id;
+ device_display_info->monitor_id = info->stream_id;
+ device_display_info->device_display_id = info->device_display_id;
+
+ strcpy((char*) device_display_info->device_address, info->device_address);
+ device_display_info->device_address_len = device_address_len + 1;
+
+ g_debug(" (stream) channel_id: %u monitor_id: %u, device_address: %s, device_display_id: %u",
device_display_info->channel_id,
device_display_info->monitor_id,
device_display_info->device_address,
commit e032e934117b6877cce2807fef57d229688598a4
Author: Lukáš Hrázký <lhrazky at redhat.com>
Date: Wed Dec 12 11:26:59 2018 +0100
Receive the GraphicsDeviceInfo message from the streaming agent
Receives the GraphicsDeviceInfo message from the streaming agent and
stores the data in a list on the streaming device.
Signed-off-by: Lukáš Hrázký <lhrazky at redhat.com>
Acked-by: Jonathon Jongsma <jjongsma at redhat.com>
diff --git a/server/display-limits.h b/server/display-limits.h
index e875149b..d79d3211 100644
--- a/server/display-limits.h
+++ b/server/display-limits.h
@@ -25,4 +25,7 @@
/** Maximum number of streams created by spice-server */
#define NUM_STREAMS 50
+/** Maximum length of the device address string */
+#define MAX_DEVICE_ADDRESS_LEN 256
+
#endif /* DISPLAY_LIMITS_H_ */
diff --git a/server/red-qxl.c b/server/red-qxl.c
index 7f8ac35d..37f3d9c8 100644
--- a/server/red-qxl.c
+++ b/server/red-qxl.c
@@ -37,11 +37,11 @@
#include "dispatcher.h"
#include "red-parse-qxl.h"
#include "red-channel-client.h"
+#include "display-limits.h"
#include "red-qxl.h"
-#define MAX_DEVICE_ADDRESS_LEN 256
#define MAX_MONITORS_COUNT 16
struct QXLState {
diff --git a/server/red-stream-device.c b/server/red-stream-device.c
index 3b553510..38df8e4c 100644
--- a/server/red-stream-device.c
+++ b/server/red-stream-device.c
@@ -39,6 +39,7 @@ struct StreamDevice {
StreamMsgCapabilities capabilities;
StreamMsgCursorSet cursor_set;
StreamMsgCursorMove cursor_move;
+ StreamMsgDeviceDisplayInfo device_display_info;
uint8_t buf[STREAM_MSG_CAPABILITIES_MAX_BYTES];
} *msg;
uint32_t msg_pos;
@@ -51,6 +52,7 @@ struct StreamDevice {
CursorChannel *cursor_channel;
SpiceTimer *close_timer;
uint32_t frame_mmtime;
+ StreamDeviceDisplayInfo device_display_info;
};
struct StreamDeviceClass {
@@ -66,8 +68,8 @@ static void char_device_set_state(RedCharDevice *char_dev, int state);
typedef bool StreamMsgHandler(StreamDevice *dev, SpiceCharDeviceInstance *sin)
SPICE_GNUC_WARN_UNUSED_RESULT;
-static StreamMsgHandler handle_msg_format, handle_msg_data, handle_msg_cursor_set,
- handle_msg_cursor_move, handle_msg_capabilities;
+static StreamMsgHandler handle_msg_format, handle_msg_device_display_info, handle_msg_data,
+ handle_msg_cursor_set, handle_msg_cursor_move, handle_msg_capabilities;
static bool handle_msg_invalid(StreamDevice *dev, SpiceCharDeviceInstance *sin,
const char *error_msg) SPICE_GNUC_WARN_UNUSED_RESULT;
@@ -150,6 +152,13 @@ stream_device_partial_read(StreamDevice *dev, SpiceCharDeviceInstance *sin)
handled = handle_msg_format(dev, sin);
}
break;
+ case STREAM_TYPE_DEVICE_DISPLAY_INFO:
+ if (dev->hdr.size > sizeof(StreamMsgDeviceDisplayInfo) + MAX_DEVICE_ADDRESS_LEN) {
+ handled = handle_msg_invalid(dev, sin, "StreamMsgDeviceDisplayInfo too large");
+ } else {
+ handled = handle_msg_device_display_info(dev, sin);
+ }
+ break;
case STREAM_TYPE_DATA:
if (dev->hdr.size > 32*1024*1024) {
handled = handle_msg_invalid(dev, sin, "STREAM_DATA too large");
@@ -276,6 +285,71 @@ handle_msg_format(StreamDevice *dev, SpiceCharDeviceInstance *sin)
}
static bool
+handle_msg_device_display_info(StreamDevice *dev, SpiceCharDeviceInstance *sin)
+{
+ SpiceCharDeviceInterface *sif = spice_char_device_get_interface(sin);
+
+ if (spice_extra_checks) {
+ spice_assert(dev->hdr_pos >= sizeof(StreamDevHeader));
+ spice_assert(dev->hdr.type == STREAM_TYPE_DEVICE_DISPLAY_INFO);
+ }
+
+ if (dev->msg_len < dev->hdr.size) {
+ dev->msg = g_realloc(dev->msg, dev->hdr.size);
+ dev->msg_len = dev->hdr.size;
+ }
+
+ /* read from device */
+ ssize_t n = sif->read(sin, dev->msg->buf + dev->msg_pos, dev->hdr.size - dev->msg_pos);
+ if (n <= 0) {
+ return dev->msg_pos == dev->hdr.size;
+ }
+
+ dev->msg_pos += n;
+ if (dev->msg_pos != dev->hdr.size) { /* some bytes are still missing */
+ return false;
+ }
+
+ StreamMsgDeviceDisplayInfo *display_info_msg = &dev->msg->device_display_info;
+
+ size_t device_address_len = GUINT32_FROM_LE(display_info_msg->device_address_len);
+ if (device_address_len > MAX_DEVICE_ADDRESS_LEN) {
+ g_warning("Received a device address longer than %u (%zu), "
+ "will be truncated!", MAX_DEVICE_ADDRESS_LEN, device_address_len);
+ device_address_len = sizeof(dev->device_display_info.device_address);
+ }
+
+ if (device_address_len == 0) {
+ g_warning("Zero length device_address in DeviceDisplayInfo message, ignoring.");
+ return true;
+ }
+
+ if (display_info_msg->device_address + device_address_len > (uint8_t*) dev->msg + dev->hdr.size) {
+ g_warning("Malformed DeviceDisplayInfo message, device_address length (%zu) "
+ "goes beyond the end of the message, ignoring.", device_address_len);
+ return true;
+ }
+
+ strncpy(dev->device_display_info.device_address,
+ (char*) display_info_msg->device_address,
+ device_address_len);
+
+ // make sure the string is terminated
+ dev->device_display_info.device_address[device_address_len - 1] = '\0';
+
+ dev->device_display_info.stream_id = GUINT32_FROM_LE(display_info_msg->stream_id);
+ dev->device_display_info.device_display_id = GUINT32_FROM_LE(display_info_msg->device_display_id);
+
+ g_debug("Received DeviceDisplayInfo from the streaming agent: stream_id %u, "
+ "device_address %s, device_display_id %u",
+ dev->device_display_info.stream_id,
+ dev->device_display_info.device_address,
+ dev->device_display_info.device_display_id);
+
+ return true;
+}
+
+static bool
handle_msg_capabilities(StreamDevice *dev, SpiceCharDeviceInstance *sin)
{
SpiceCharDeviceInterface *sif = spice_char_device_get_interface(sin);
diff --git a/server/red-stream-device.h b/server/red-stream-device.h
index f0a5b5c1..996be016 100644
--- a/server/red-stream-device.h
+++ b/server/red-stream-device.h
@@ -19,6 +19,7 @@
#ifndef STREAM_DEVICE_H
#define STREAM_DEVICE_H
+#include "display-limits.h"
#include "char-device.h"
G_BEGIN_DECLS
@@ -41,6 +42,13 @@ typedef struct StreamDeviceClass StreamDeviceClass;
(G_TYPE_INSTANCE_GET_CLASS((obj), TYPE_STREAM_DEVICE, StreamDeviceClass))
GType stream_device_get_type(void) G_GNUC_CONST;
+
+typedef struct StreamDeviceDisplayInfo {
+ uint32_t stream_id;
+ char device_address[MAX_DEVICE_ADDRESS_LEN];
+ uint32_t device_display_id;
+} StreamDeviceDisplayInfo;
+
StreamDevice *stream_device_connect(RedsState *reds, SpiceCharDeviceInstance *sin);
/* Create channel for the streaming device.
commit 852ae0255c1d57b8a6910538aececd093157e17b
Author: Lukáš Hrázký <lhrazky at redhat.com>
Date: Tue Oct 30 15:43:50 2018 +0100
Send the graphics device info to the vd_agent
Sends the device address and device display IDs to the vdagent. The
message is sent either in reaction to the SPICE_MSGC_MAIN_AGENT_START
message or when the graphics device info changes.
Signed-off-by: Lukáš Hrázký <lhrazky at redhat.com>
Acked-by: Jonathon Jongsma <jjongsma at redhat.com>
diff --git a/configure.ac b/configure.ac
index 903993a1..fa79af7f 100644
--- a/configure.ac
+++ b/configure.ac
@@ -161,7 +161,7 @@ AS_IF([test x"$have_smartcard" = "xyes"], [
AS_VAR_APPEND([SPICE_REQUIRES], [" libcacard >= 0.1.2"])
])
-SPICE_PROTOCOL_MIN_VER=0.12.15
+SPICE_PROTOCOL_MIN_VER=0.12.16
PKG_CHECK_MODULES([SPICE_PROTOCOL], [spice-protocol >= $SPICE_PROTOCOL_MIN_VER])
AC_SUBST([SPICE_PROTOCOL_MIN_VER])
diff --git a/meson.build b/meson.build
index 3184a6f5..5f402a5f 100644
--- a/meson.build
+++ b/meson.build
@@ -82,7 +82,7 @@ endif
#
# check for mandatory dependencies
#
-spice_protocol_version='0.12.15'
+spice_protocol_version='0.12.16'
glib_version = '2.38'
glib_version_info = '>= @0@'.format(glib_version)
diff --git a/server/red-qxl.c b/server/red-qxl.c
index 907f78d6..7f8ac35d 100644
--- a/server/red-qxl.c
+++ b/server/red-qxl.c
@@ -889,6 +889,26 @@ void spice_qxl_set_device_info(QXLInstance *instance,
instance->st->monitors_count = device_display_id_count;
instance->st->max_monitors = device_display_id_count;
+
+ reds_send_device_display_info(red_qxl_get_server(instance->st));
+}
+
+const char* red_qxl_get_device_address(const QXLInstance *qxl)
+{
+ const QXLState *qxl_state = qxl->st;
+ return qxl_state->device_address;
+}
+
+const uint32_t* red_qxl_get_device_display_ids(const QXLInstance *qxl)
+{
+ const QXLState *qxl_state = qxl->st;
+ return qxl_state->device_display_ids;
+}
+
+size_t red_qxl_get_monitors_count(const QXLInstance *qxl)
+{
+ const QXLState *qxl_state = qxl->st;
+ return qxl_state->monitors_count;
}
void red_qxl_init(RedsState *reds, QXLInstance *qxl)
diff --git a/server/red-qxl.h b/server/red-qxl.h
index 6014d32a..94753948 100644
--- a/server/red-qxl.h
+++ b/server/red-qxl.h
@@ -40,6 +40,9 @@ void red_qxl_put_gl_scanout(QXLInstance *qxl, SpiceMsgDisplayGlScanoutUnix *scan
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);
+const char* red_qxl_get_device_address(const QXLInstance *qxl);
+const uint32_t* red_qxl_get_device_display_ids(const QXLInstance *qxl);
+size_t red_qxl_get_monitors_count(const QXLInstance *qxl);
/* Wrappers around QXLInterface vfuncs */
void red_qxl_get_init_info(QXLInstance *qxl, QXLDevInitInfo *info);
diff --git a/server/reds-private.h b/server/reds-private.h
index 920edc5c..9dbc7fa9 100644
--- a/server/reds-private.h
+++ b/server/reds-private.h
@@ -81,6 +81,7 @@ struct RedsState {
SpiceWatch *secure_listen_watch;
RedCharDeviceVDIPort *agent_dev;
int pending_mouse_event;
+ bool pending_device_display_info_message;
GList *clients;
MainChannel *main_channel;
InputsChannel *inputs_channel;
diff --git a/server/reds.c b/server/reds.c
index e95c62d5..c4ec2a3f 100644
--- a/server/reds.c
+++ b/server/reds.c
@@ -257,6 +257,7 @@ typedef struct __attribute__ ((__packed__)) VDInternalBuf {
VDAgentMessage header;
union {
VDAgentMouseState mouse_state;
+ VDAgentGraphicsDeviceInfo graphics_device_info;
}
u;
} VDInternalBuf;
@@ -894,6 +895,65 @@ static RedPipeItem *vdi_port_read_one_msg_from_device(RedCharDevice *self,
return NULL;
}
+void reds_send_device_display_info(RedsState *reds)
+{
+ if (!reds->agent_dev->priv->agent_attached) {
+ return;
+ }
+ g_debug("Sending device display info to the agent:");
+
+ size_t message_size = sizeof(VDAgentGraphicsDeviceInfo);
+ QXLInstance *qxl;
+ FOREACH_QXL_INSTANCE(reds, qxl) {
+ message_size +=
+ (sizeof(VDAgentDeviceDisplayInfo) + strlen(red_qxl_get_device_address(qxl)) + 1) *
+ red_qxl_get_monitors_count(qxl);
+ }
+
+ RedCharDeviceWriteBuffer *char_dev_buf = vdagent_new_write_buffer(reds->agent_dev,
+ VD_AGENT_GRAPHICS_DEVICE_INFO,
+ message_size,
+ true);
+
+ if (!char_dev_buf) {
+ reds->pending_device_display_info_message = true;
+ return;
+ }
+
+ VDInternalBuf *internal_buf = (VDInternalBuf *)char_dev_buf->buf;
+ VDAgentGraphicsDeviceInfo *graphics_device_info = &internal_buf->u.graphics_device_info;
+ graphics_device_info->count = 0;
+
+ VDAgentDeviceDisplayInfo *device_display_info = graphics_device_info->display_info;
+ FOREACH_QXL_INSTANCE(reds, qxl) {
+ for (size_t i = 0; i < red_qxl_get_monitors_count(qxl); ++i) {
+ device_display_info->channel_id = qxl->id;
+ device_display_info->monitor_id = i;
+ device_display_info->device_display_id = red_qxl_get_device_display_ids(qxl)[i];
+
+ strcpy((char*) device_display_info->device_address, red_qxl_get_device_address(qxl));
+
+ device_display_info->device_address_len =
+ strlen((char*) device_display_info->device_address) + 1;
+
+ g_debug(" channel_id: %u monitor_id: %u, device_address: %s, device_display_id: %u",
+ device_display_info->channel_id,
+ device_display_info->monitor_id,
+ device_display_info->device_address,
+ device_display_info->device_display_id);
+
+ device_display_info = (VDAgentDeviceDisplayInfo*) ((char*) device_display_info +
+ sizeof(VDAgentDeviceDisplayInfo) + device_display_info->device_address_len);
+
+ graphics_device_info->count++;
+ }
+ }
+
+ reds->pending_device_display_info_message = false;
+
+ red_char_device_write_buffer_add(RED_CHAR_DEVICE(reds->agent_dev), char_dev_buf);
+}
+
/* after calling this, we unref the message, and the ref is in the instance side */
static void vdi_port_send_msg_to_client(RedCharDevice *self,
RedPipeItem *msg,
@@ -925,6 +985,11 @@ static void vdi_port_on_free_self_token(RedCharDevice *self)
spice_debug("pending mouse event");
reds_handle_agent_mouse_event(reds, inputs_channel_get_mouse_state(reds->inputs_channel));
}
+
+ if (reds->pending_device_display_info_message) {
+ spice_debug("pending device display info message");
+ reds_send_device_display_info(reds);
+ }
}
static void vdi_port_remove_client(RedCharDevice *self,
@@ -1062,6 +1127,8 @@ void reds_on_main_agent_start(RedsState *reds, MainChannelClient *mcc, uint32_t
num_tokens);
}
+ reds_send_device_display_info(reds);
+
agent_msg_filter_config(&reds->agent_dev->priv->write_filter, reds->config->agent_copypaste,
reds->config->agent_file_xfer,
reds_use_client_monitors_config(reds));
diff --git a/server/reds.h b/server/reds.h
index 7f74a21a..4778366a 100644
--- a/server/reds.h
+++ b/server/reds.h
@@ -50,6 +50,7 @@ gboolean reds_config_get_agent_mouse(const RedsState *reds); // used by inputs_c
int reds_has_vdagent(RedsState *reds); // used by inputs channel
bool reds_config_get_playback_compression(RedsState *reds); // used by playback channel
+void reds_send_device_display_info(RedsState *reds);
void reds_handle_agent_mouse_event(RedsState *reds, const VDAgentMouseState *mouse_state); // used by inputs_channel
GArray* reds_get_renderers(RedsState *reds);
More information about the Spice-commits
mailing list