[Spice-devel] [PATCH] usb-device-manager: do not try to connect a usb device that was removed

Uri Lublin uril at redhat.com
Wed Jul 11 02:50:18 PDT 2012


If a device that is asked to be shared with the guest, is unplugged out
of the machine before being redirected, then let the user know that
usbredir of that device failed (and cleanup nicely).

For Windows client, the time between request and redir is larger, as
it includes the time it takes to install the libusb driver.
---
 gtk/usb-device-manager.c |    7 +++++++
 1 files changed, 7 insertions(+), 0 deletions(-)

diff --git a/gtk/usb-device-manager.c b/gtk/usb-device-manager.c
index 9dab4c6..e5f84d0 100644
--- a/gtk/usb-device-manager.c
+++ b/gtk/usb-device-manager.c
@@ -1073,6 +1073,13 @@ _spice_usb_device_manager_connect_device_async(SpiceUsbDeviceManager *self,
             continue; /* Skip already used channels */

         libdev = spice_usb_device_manager_device_to_libdev(self, device);
+        if (libdev == NULL) {
+            g_simple_async_result_set_error(result,
+                                            SPICE_CLIENT_ERROR,
+                                            SPICE_CLIENT_ERROR_FAILED,
+                                            _("Device was not found"));
+            goto done;
+        }
         spice_usbredir_channel_connect_device_async(channel,
                                  libdev,
                                  cancellable,
-- 
1.7.7.6



More information about the Spice-devel mailing list