[Spice-devel] [PATCH spice 5/8] Send the graphics device info from streaming agent to the vd_agent
Lukáš Hrázký
lhrazky at redhat.com
Tue Jan 8 15:28:44 UTC 2019
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>
---
server/red-stream-device.c | 14 ++++++++++
server/red-stream-device.h | 4 +++
server/reds.c | 56 ++++++++++++++++++++++++++++++++++++--
3 files changed, 72 insertions(+), 2 deletions(-)
diff --git a/server/red-stream-device.c b/server/red-stream-device.c
index bbd6874f..567e7485 100644
--- a/server/red-stream-device.c
+++ b/server/red-stream-device.c
@@ -328,6 +328,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;
}
@@ -785,6 +787,18 @@ 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;
+}
+
+uint32_t stream_device_get_stream_channel_id(StreamDevice *dev)
+{
+ uint32_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 9e71cb88..0a3ac7f7 100644
--- a/server/red-stream-device.h
+++ b/server/red-stream-device.h
@@ -56,6 +56,10 @@ StreamDevice *stream_device_connect(RedsState *reds, SpiceCharDeviceInstance *si
*/
void stream_device_create_channel(StreamDevice *dev);
+StreamDeviceDisplayInfo *stream_device_get_device_display_info(StreamDevice *dev);
+
+uint32_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 b85758b6..d26fdf65 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->device_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,38 @@ 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);
+
+ if (strlen(info->device_address) == 0) {
+ // the device info wasn't set (yet), don't send it
+ continue;
+ }
+
+ device_display_info->channel_id = stream_device_get_stream_channel_id(stream_dev);
+ device_display_info->monitor_id = info->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 = strlen(info->device_address) + 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,
--
2.20.1
More information about the Spice-devel
mailing list