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

Pavel Grunt pgrunt at redhat.com
Fri Oct 24 07:16:47 PDT 2014


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

diff --git a/src/vdagentd.c b/src/vdagentd.c
index b5c7d14..a6800c9 100644
--- a/src/vdagentd.c
+++ b/src/vdagentd.c
@@ -108,6 +108,21 @@ static void send_capabilities(struct vdagent_virtio_port *vport,
     free(caps);
 }
 
+static void send_version(struct vdagent_virtio_port *vport)
+{
+    gchar *version_utf8;
+    gsize size;
+    if (VD_AGENT_HAS_CAPABILITY(capabilities, capabilities_size, VD_AGENT_CAP_GUEST_VERSION)) {
+        version_utf8 = g_locale_to_utf8(VERSION, strlen(VERSION), NULL, &size, NULL);
+        if (version_utf8 != NULL) {
+            vdagent_virtio_port_write(vport, VDP_CLIENT_PORT,
+                                      VD_AGENT_GUEST_VERSION, 0,
+                                      (uint8_t *) version_utf8, size + 1);
+            g_free(version_utf8);
+        }
+    }
+}
+
 static void do_client_disconnect(void)
 {
     if (client_connected) {
@@ -180,6 +195,7 @@ static void do_client_capabilities(struct vdagent_virtio_port *vport,
             syslog(LOG_DEBUG, "New client connected");
         client_connected = 1;
         send_capabilities(vport, 0);
+        send_version(vport);
     }
 }
 
-- 
1.9.3



More information about the Spice-devel mailing list