[Spice-devel] [PATCH spice-server v2 2/3] Only send device display info to supported agents
Jonathon Jongsma
jjongsma at redhat.com
Mon Mar 4 19:50:44 UTC 2019
Only send the graphics device display info to agents that advertise the
VD_AGENT_CAP_GRAPHICS_DEVICE_INFO capability
Signed-off-by: Jonathon Jongsma <jjongsma at redhat.com>
---
Changes in v2:
- renamed member variable
- moved variable to RedCharDeviceVDIPortPrivate
- reset variable when agent disconnects
- make sure the message is sent immediately when we receive the capabilities.
NOTE: I did not change the function name as requested to filter_agent_capabilities because there is
already a agent message filter which determines whether a message should be handled or discarded,
etc. Adding another 'filter' concept would confuse things. I think "adjust_" seems fine to me.
server/reds.c | 11 +++++++++++
1 file changed, 11 insertions(+)
diff --git a/server/reds.c b/server/reds.c
index 63bfadb22..07562b555 100644
--- a/server/reds.c
+++ b/server/reds.c
@@ -234,6 +234,7 @@ struct RedCharDeviceVDIPortPrivate {
gboolean agent_attached;
uint32_t plug_generation;
int client_agent_started;
+ bool agent_supports_graphics_device_info;
/* write to agent */
RedCharDeviceWriteBuffer *recv_from_client_buf;
@@ -486,6 +487,7 @@ static void reds_reset_vdp(RedsState *reds)
dev->priv->write_filter.result = AGENT_MSG_FILTER_DISCARD;
dev->priv->write_filter.discard_all = TRUE;
dev->priv->client_agent_started = FALSE;
+ dev->priv->agent_supports_graphics_device_info = false;
/* The client's tokens are set once when the main channel is initialized
* and once upon agent's connection with SPICE_MSG_MAIN_AGENT_CONNECTED_TOKENS.
@@ -813,6 +815,11 @@ static void reds_adjust_agent_capabilities(RedsState *reds, VDAgentMessage *mess
if (!reds->config->agent_file_xfer) {
VD_AGENT_SET_CAPABILITY(capabilities->caps, VD_AGENT_CAP_FILE_XFER_DISABLED);
}
+
+ size_t caps_size = VD_AGENT_CAPS_SIZE_FROM_MSG_SIZE(message->size);
+ reds->agent_dev->priv->agent_supports_graphics_device_info =
+ VD_AGENT_HAS_CAPABILITY(capabilities->caps, caps_size, VD_AGENT_CAP_GRAPHICS_DEVICE_INFO);
+ reds_send_device_display_info(reds);
}
/* reads from the device till completes reading a message that is addressed to the client,
@@ -965,6 +972,10 @@ void reds_send_device_display_info(RedsState *reds)
if (!reds->agent_dev->priv->agent_attached) {
return;
}
+ if (!reds->agent_dev->priv->agent_supports_graphics_device_info) {
+ return;
+ }
+
g_debug("Sending device display info to the agent:");
SpiceMarshaller *m = spice_marshaller_new();
--
2.17.2
More information about the Spice-devel
mailing list