[Spice-devel] [PATCH spice-gtk 2/2] channel-usbredir: Properly reset state from reset callback
Hans de Goede
hdegoede at redhat.com
Fri Sep 28 11:13:47 PDT 2012
This is necesary to be able to use the usbredir channel after a
non seamless migration.
Signed-off-by: Hans de Goede <hdegoede at redhat.com>
---
gtk/channel-usbredir.c | 17 +++++++++++++++--
1 file changed, 15 insertions(+), 2 deletions(-)
diff --git a/gtk/channel-usbredir.c b/gtk/channel-usbredir.c
index 5f8fb16..d5f8253 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 the 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,
--
1.7.12
More information about the Spice-devel
mailing list