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

Yonit Halperin yhalperi at redhat.com
Sun Apr 8 08:44:01 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.

Signed-off-by: Yonit Halperin <yhalperi at redhat.com>
---
 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 783b94a..28d2979 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 cc613c0..5b11895 160000
--- a/spice-common
+++ b/spice-common
@@ -1 +1 @@
-Subproject commit cc613c0c3c1ba3fe7017528d0da998a210a35d75
+Subproject commit 5b1189540ad62f2c79815040e93e2ad567304cdb
-- 
1.7.7.6



More information about the Spice-devel mailing list