[Spice-devel] [PATCH v2 spice-gtk 2/3] channel: support qos queries

Yonit Halperin yhalperi at redhat.com
Tue Apr 17 03:13:36 PDT 2012


When a channel receives SPICE_MSG_QOS_QUERY, it responds to the server
with SPICE_MSGC_QOS_ACK right after it recieves one more message.
---
 gtk/channel-base.c       |    7 +++++++
 gtk/spice-channel-priv.h |    3 +++
 gtk/spice-channel.c      |   22 ++++++++++++++++++----
 spice-common             |    2 +-
 4 files changed, 29 insertions(+), 5 deletions(-)

diff --git a/gtk/channel-base.c b/gtk/channel-base.c
index cc4d242..481ff71 100644
--- a/gtk/channel-base.c
+++ b/gtk/channel-base.c
@@ -187,3 +187,10 @@ void spice_channel_handle_migrate(SpiceChannel *channel, SpiceMsgIn *in)
         spice_msg_out_send_internal(out);
     }
 }
+
+G_GNUC_INTERNAL
+void spice_channel_handle_qos_query(SpiceChannel *channel, SpiceMsgIn *in)
+{
+    SPICE_DEBUG("qos query");
+    channel->priv->qos_query_pending = TRUE;
+}
diff --git a/gtk/spice-channel-priv.h b/gtk/spice-channel-priv.h
index ac8bece..ca8386e 100644
--- a/gtk/spice-channel-priv.h
+++ b/gtk/spice-channel-priv.h
@@ -123,6 +123,8 @@ struct _SpiceChannelPrivate {
     int                         message_ack_window;
     int                         message_ack_count;
 
+    gboolean                    qos_query_pending;
+
     GArray                      *caps;
     GArray                      *common_caps;
     GArray                      *remote_caps;
@@ -170,6 +172,7 @@ void spice_channel_handle_notify(SpiceChannel *channel, SpiceMsgIn *in);
 void spice_channel_handle_disconnect(SpiceChannel *channel, SpiceMsgIn *in);
 void spice_channel_handle_wait_for_channels(SpiceChannel *channel, SpiceMsgIn *in);
 void spice_channel_handle_migrate(SpiceChannel *channel, SpiceMsgIn *in);
+void spice_channel_handle_qos_query(SpiceChannel *channel, SpiceMsgIn *in);
 
 gint spice_channel_get_channel_id(SpiceChannel *channel);
 gint spice_channel_get_channel_type(SpiceChannel *channel);
diff --git a/gtk/spice-channel.c b/gtk/spice-channel.c
index b0f2d4e..c5f655a 100644
--- a/gtk/spice-channel.c
+++ b/gtk/spice-channel.c
@@ -93,6 +93,13 @@ static guint signals[SPICE_CHANNEL_LAST_SIGNAL];
 static void spice_channel_iterate_write(SpiceChannel *channel);
 static void spice_channel_iterate_read(SpiceChannel *channel);
 
+static void spice_channel_init_capabilities(SpiceChannel *channel)
+{
+    spice_channel_set_common_capability(channel, SPICE_COMMON_CAP_PROTOCOL_AUTH_SELECTION);
+    spice_channel_set_common_capability(channel, SPICE_COMMON_CAP_MINI_HEADER);
+    spice_channel_set_common_capability(channel, SPICE_COMMON_CAP_QOS_QUERY);
+}
+
 static void spice_channel_init(SpiceChannel *channel)
 {
     SpiceChannelPrivate *c;
@@ -107,8 +114,7 @@ static void spice_channel_init(SpiceChannel *channel)
     c->common_caps = g_array_new(FALSE, TRUE, sizeof(guint32));
     c->remote_caps = g_array_new(FALSE, TRUE, sizeof(guint32));
     c->remote_common_caps = g_array_new(FALSE, TRUE, sizeof(guint32));
-    spice_channel_set_common_capability(channel, SPICE_COMMON_CAP_PROTOCOL_AUTH_SELECTION);
-    spice_channel_set_common_capability(channel, SPICE_COMMON_CAP_MINI_HEADER);
+    spice_channel_init_capabilities(channel);
     g_queue_init(&c->xmit_queue);
     STATIC_MUTEX_INIT(c->xmit_queue_lock);
 }
@@ -1781,6 +1787,14 @@ void spice_channel_recv_msg(SpiceChannel *channel,
             return;
     }
 
+    if (c->qos_query_pending) {
+        SpiceMsgOut *out = spice_msg_out_new(channel, SPICE_MSGC_QOS_ACK);
+
+        SPICE_DEBUG("qos ack");
+        spice_msg_out_send_internal(out);
+        c->qos_query_pending = FALSE;
+    }
+
     msg_type = spice_header_get_msg_type(in->header, c->use_mini_header);
     sub_list_offset = spice_header_get_msg_sub_list(in->header, c->use_mini_header);
 
@@ -2388,8 +2402,7 @@ static void channel_reset(SpiceChannel *channel, gboolean migrating)
     g_array_set_size(c->common_caps, 0);
     g_array_set_size(c->caps, 0);
     /* Restore our default capabilities in case the channel gets re-used */
-    spice_channel_set_common_capability(channel, SPICE_COMMON_CAP_PROTOCOL_AUTH_SELECTION);
-    spice_channel_set_common_capability(channel, SPICE_COMMON_CAP_MINI_HEADER);
+    spice_channel_init_capabilities(channel);
 }
 
 /* system or coroutine context */
@@ -2616,6 +2629,7 @@ static const spice_msg_handler base_handlers[] = {
     [ SPICE_MSG_DISCONNECTING ]            = spice_channel_handle_disconnect,
     [ SPICE_MSG_WAIT_FOR_CHANNELS ]        = spice_channel_handle_wait_for_channels,
     [ SPICE_MSG_MIGRATE ]                  = spice_channel_handle_migrate,
+    [ SPICE_MSG_QOS_QUERY ]                = spice_channel_handle_qos_query,
 };
 
 /* coroutine context */
diff --git a/spice-common b/spice-common
index 005f433..76aebac 160000
--- a/spice-common
+++ b/spice-common
@@ -1 +1 @@
-Subproject commit 005f433769e90a4be32302cc90aca3d34919f9d5
+Subproject commit 76aebac3db2626929f4bd233eb973b6ea2ca47f3
-- 
1.7.7.6



More information about the Spice-devel mailing list