[PATCH] usb-device-manager: mingw: connect: cleanup device if it's libdev is missing

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



For Windows client, when connecting a device to the guest, if a libusb
device (libdev) does not exist, cleanup and forget about that device.

Most likely, the device was plugged out at driver installation
time, and its remove-device event was ignored.
---

An alternative patch for the same fix can be:
 - split spice_usb_device_manager_remove_dev, such that the lower part
   is kept in another static function and accepts a SpiceUsbDevice
 - call it from _spice_usb_device_manager_connect_device_async.

---
 gtk/usb-device-manager.c |    9 +++++++++
 1 files changed, 9 insertions(+), 0 deletions(-)

diff --git a/gtk/usb-device-manager.c b/gtk/usb-device-manager.c
index e5f84d0..bdef24e 100644
--- a/gtk/usb-device-manager.c
+++ b/gtk/usb-device-manager.c
@@ -1074,6 +1074,15 @@ _spice_usb_device_manager_connect_device_async(SpiceUsbDeviceManager *self,

         libdev = spice_usb_device_manager_device_to_libdev(self, device);
         if (libdev == NULL) {
+#ifdef G_OS_WIN32
+            /* Most likely, the device was plugged out at driver installation
+             * time, and its remove-device event was ignored.
+             * So remove the device now
+             */
+            SPICE_DEBUG("libdev does not exist for %p -- removing", device);
+            g_signal_emit(self, signals[DEVICE_REMOVED], 0, device);
+            g_ptr_array_remove(priv->devices, device);
+#endif
             g_simple_async_result_set_error(result,
                                             SPICE_CLIENT_ERROR,
                                             SPICE_CLIENT_ERROR_FAILED,
-- 
1.7.7.6

_______________________________________________
Spice-devel mailing list
Spice-devel@xxxxxxxxxxxxxxxxxxxxx
http://lists.freedesktop.org/mailman/listinfo/spice-devel


[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Security]     [Bugtraq]     [Linux]     [Linux OMAP]     [Linux MIPS]     [ECOS]     [Asterisk Internet PBX]     [Linux API]     [Monitors]