[Spice-commits] 2 commits - gtk/channel-usbredir.c gtk/spice-channel.c gtk/spice-session.c

Hans de Goede jwrdegoede at kemper.freedesktop.org
Mon Oct 8 04:31:33 PDT 2012


 gtk/channel-usbredir.c |   17 +++++++++++++++--
 gtk/spice-channel.c    |    2 +-
 gtk/spice-session.c    |    8 +++++---
 3 files changed, 21 insertions(+), 6 deletions(-)

New commits:
commit dd85d84b5b7a36a8218e432730efeaadb9243a6e
Author: Hans de Goede <hdegoede at redhat.com>
Date:   Thu Sep 27 17:31:54 2012 +0200

    channel-usbredir: Properly reset state from reset callback
    
    This is necessary to be able to use the usbredir channel after a
    non seamless migration.
    
    Signed-off-by: Hans de Goede <hdegoede at redhat.com>

diff --git a/gtk/channel-usbredir.c b/gtk/channel-usbredir.c
index 5f8fb16..02edcd3 100644
--- a/gtk/channel-usbredir.c
+++ b/gtk/channel-usbredir.c
@@ -66,6 +66,7 @@ enum SpiceUsbredirChannelState {
 
 struct _SpiceUsbredirChannelPrivate {
     libusb_device *device;
+    libusb_context *context;
     struct usbredirhost *host;
     /* To catch usbredirhost error messages and report them as a GError */
     GError **catch_error;
@@ -109,9 +110,20 @@ static void spice_usbredir_channel_init(SpiceUsbredirChannel *channel)
 }
 
 #ifdef USE_USBREDIR
-static void spice_usbredir_channel_reset(SpiceChannel *channel, gboolean migrating)
+static void spice_usbredir_channel_reset(SpiceChannel *c, gboolean migrating)
 {
-    SPICE_CHANNEL_CLASS(spice_usbredir_channel_parent_class)->channel_reset(channel, migrating);
+    SpiceUsbredirChannel *channel = SPICE_USBREDIR_CHANNEL(c);
+    SpiceUsbredirChannelPrivate *priv = channel->priv;
+
+    if (priv->host) {
+        if (priv->state == STATE_CONNECTED)
+            spice_usbredir_channel_disconnect_device(channel);
+        usbredirhost_close(priv->host);
+        priv->host = NULL;
+        /* Call set_context to re-create the host */
+        spice_usbredir_channel_set_context(channel, priv->context);
+    }
+    SPICE_CHANNEL_CLASS(spice_usbredir_channel_parent_class)->channel_reset(c, migrating);
 }
 #endif
 
@@ -190,6 +202,7 @@ void spice_usbredir_channel_set_context(SpiceUsbredirChannel *channel,
 
     g_return_if_fail(priv->host == NULL);
 
+    priv->context = context;
     priv->host = usbredirhost_open_full(
                                    context, NULL,
                                    usbredir_log,
commit f85fa2abfb24954046cc7d9d40374108b033cf32
Author: Hans de Goede <hdegoede at redhat.com>
Date:   Thu Sep 27 17:29:37 2012 +0200

    Set channel state before calling channel_reset
    
    This way functions called from the channel_reset function can rely
    on state accurately reflecting the state. This is necessary to stop
    channel-usbredir's reset callback from trying to send the initial
    hello message while the channel is no longer in a connected state.
    
    Signed-off-by: Hans de Goede <hdegoede at redhat.com>

diff --git a/gtk/spice-channel.c b/gtk/spice-channel.c
index dee0fa3..c5e8d9f 100644
--- a/gtk/spice-channel.c
+++ b/gtk/spice-channel.c
@@ -2428,10 +2428,10 @@ static void channel_disconnect(SpiceChannel *channel)
     if (c->state == SPICE_CHANNEL_STATE_READY)
         emit_main_context(channel, SPICE_CHANNEL_EVENT, SPICE_CHANNEL_CLOSED);
 
+    c->state = SPICE_CHANNEL_STATE_UNCONNECTED;
     spice_channel_reset(channel, FALSE);
 
     g_return_if_fail(SPICE_IS_CHANNEL(channel));
-    c->state = SPICE_CHANNEL_STATE_UNCONNECTED;
 }
 
 /**
diff --git a/gtk/spice-session.c b/gtk/spice-session.c
index 68d1594..28ebe8a 100644
--- a/gtk/spice-session.c
+++ b/gtk/spice-session.c
@@ -1388,15 +1388,17 @@ void spice_session_migrate_end(SpiceSession *self)
         SpiceChannel *channel = l->data;
         l = l->next;
 
+        if (!SPICE_IS_MAIN_CHANNEL(channel)) {
+            /* freeze other channels */
+            channel->priv->state = SPICE_CHANNEL_STATE_MIGRATING;
+        }
+
         /* reset for migration, disconnect */
         spice_channel_reset(channel, TRUE);
 
         if (SPICE_IS_MAIN_CHANNEL(channel)) {
             /* migrate main to target, so we can start talking */
             spice_session_channel_migrate(self, channel);
-        } else {
-            /* freeze other channels */
-            channel->priv->state = SPICE_CHANNEL_STATE_MIGRATING;
         }
     }
 


More information about the Spice-commits mailing list