[Spice-devel] [PATCH linux/vd_agent] Support for the VD_AGENT_INFORMATION message

Pavel Grunt pgrunt at redhat.com
Thu Oct 23 09:12:32 PDT 2014


The agent will send an information about its version to the client.
---
depends on http://lists.freedesktop.org/archives/spice-devel/2014-October/017654.html
---
 src/vdagentd.c | 22 ++++++++++++++++++++++
 1 file changed, 22 insertions(+)

diff --git a/src/vdagentd.c b/src/vdagentd.c
index b5c7d14..4f3efdb 100644
--- a/src/vdagentd.c
+++ b/src/vdagentd.c
@@ -108,6 +108,23 @@ static void send_capabilities(struct vdagent_virtio_port *vport,
     free(caps);
 }
 
+static void do_client_information(struct vdagent_virtio_port *vport,
+    VDAgentMessage *message_header, VDAgentInformation *information_msg)
+{
+    VDAgentInformation *msg;
+    uint32_t size;
+    if (information_msg->type == VD_AGENT_INFORMATION_VERSION) {
+        size = sizeof(VDAgentInformation) + strlen(VERSION) + 1;
+        msg = g_malloc0(size);
+        msg->type = VD_AGENT_INFORMATION_VERSION;
+        memcpy(msg->data, VERSION, strlen(VERSION));
+        vdagent_virtio_port_write(vport, VDP_CLIENT_PORT,
+                                  VD_AGENT_INFORMATION, 0,
+                                  (const uint8_t *) msg, size);
+        g_free(msg);
+    }
+}
+
 static void do_client_disconnect(void)
 {
     if (client_connected) {
@@ -379,6 +396,11 @@ int virtio_port_read_complete(
         syslog(LOG_DEBUG, "Set max clipboard: %d", msg->max);
         max_clipboard = msg->max;
         break;
+    case VD_AGENT_INFORMATION:
+        if (message_header->size < sizeof(VDAgentInformation))
+            goto size_error;
+        do_client_information(vport, message_header, (VDAgentInformation *) data);
+        break;
     default:
         syslog(LOG_WARNING, "unknown message type %d, ignoring",
                message_header->type);
-- 
1.9.3



More information about the Spice-devel mailing list