summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJonathon Jongsma <jjongsma@redhat.com>2018-12-19 08:54:29 -0600
committerJonathon Jongsma <jjongsma@redhat.com>2019-01-29 10:11:04 -0600
commit67f3a09c22e0e5198cfb5a43d68dfd476edb396e (patch)
treeed31e47e28081681e888089e33cf7eba5635cdbc /src
parent5ad18905c8aab3e8530474651200b5091a9fddcc (diff)
Send device info to agent when it connects
Previously, the device info was only sent from the daemon to the session agent when we receive the device info message from the host. That means that if the session agent exits and reconnects, the session agent will not have the device info necessary to translate spice display IDs to guest device outputs. This patch saves the last device info message that was received from the host, and re-sends it to the session agent when it reconnects. NOTE: this may not be necessary if the server simply re-sends a device info message when it detects that the agent has connected... Acked-by: Lukáš Hrázký <lhrazky@redhat.com> Signed-off-by: Jonathon Jongsma <jjongsma@redhat.com>
Diffstat (limited to 'src')
-rw-r--r--src/vdagentd/vdagentd.c15
1 files changed, 15 insertions, 0 deletions
diff --git a/src/vdagentd/vdagentd.c b/src/vdagentd/vdagentd.c
index ec8defc..f80f48b 100644
--- a/src/vdagentd/vdagentd.c
+++ b/src/vdagentd/vdagentd.c
@@ -514,6 +514,8 @@ static gboolean vdagent_message_check_size(const VDAgentMessage *message_header)
return TRUE;
}
+static VDAgentGraphicsDeviceInfo *device_info = NULL;
+static size_t device_info_size = 0;
static int virtio_port_read_complete(
struct vdagent_virtio_port *vport,
int port_nr,
@@ -561,6 +563,14 @@ static int virtio_port_read_complete(
break;
}
case VD_AGENT_GRAPHICS_DEVICE_INFO: {
+ if (device_info) {
+ g_free(device_info);
+ device_info = NULL;
+ device_info_size = 0;
+ }
+ // store device info for re-sending when a session agent reconnects
+ device_info = g_memdup(data, message_header->size);
+ device_info_size = message_header->size;
forward_data_to_session_agent(VDAGENTD_GRAPHICS_DEVICE_INFO, data, message_header->size);
break;
}
@@ -851,6 +861,11 @@ static void agent_connect(struct udscs_connection *conn)
udscs_write(conn, VDAGENTD_VERSION, 0, 0,
(uint8_t *)VERSION, strlen(VERSION) + 1);
update_active_session_connection(conn);
+
+ if (device_info) {
+ forward_data_to_session_agent(VDAGENTD_GRAPHICS_DEVICE_INFO,
+ (uint8_t *) device_info, device_info_size);
+ }
}
static void agent_disconnect(struct udscs_connection *conn)