[Spice-commits] 2 commits - gtk/usb-device-manager.c gtk/win-usb-dev.c

Uri Lublin uril at kemper.freedesktop.org
Tue Aug 20 02:11:00 PDT 2013


 gtk/usb-device-manager.c |   14 +++++++++++++-
 gtk/win-usb-dev.c        |    3 +++
 2 files changed, 16 insertions(+), 1 deletion(-)

New commits:
commit b838937683cbbe03e4dc2ec4bf181b1bd87c5eef
Author: Uri Lublin <uril at redhat.com>
Date:   Wed Aug 14 23:45:56 2013 +0300

    win-usb-dev: ignore devices with addr 1 for LIBUSBX_API_VERSION
    
    Starting libusbx version 1.0.13 (commit 8cd30bb7066f785ee78cf6c3dccafdbc4b957b50)
    windows device enumeration changed and root hubs address number is 1 intead
    of 0xff.
    
    This patch uses LIBUSBX_API_VERSION which was introduced after 1.0.13 release
    (commit 9d368fc4774344d81ab02840f3a8478301bfb6fa).

diff --git a/gtk/win-usb-dev.c b/gtk/win-usb-dev.c
index 9c95ac4..0f57e40 100644
--- a/gtk/win-usb-dev.c
+++ b/gtk/win-usb-dev.c
@@ -534,6 +534,9 @@ static gboolean g_udev_skip_search(GUdevDevice *udev)
     g_return_val_if_fail(udevinfo != NULL, FALSE);
 
     skip = ((udevinfo->addr == 0xff) ||  /* root hub (HCD) */
+#if defined(LIBUSBX_API_VERSION) && (LIBUSBX_API_VERSION >= 0x010000FF)
+            (udevinfo->addr == 1) || /* root hub addr for libusbx >= 1.0.13 */
+#endif
             (udevinfo->class == LIBUSB_CLASS_HUB) || /* hub*/
             (udevinfo->addr == 0)); /* bad address */
     return skip;
commit 118be64c21c280531b020517c53ca76f9108508a
Author: Uri Lublin <uril at redhat.com>
Date:   Wed Aug 14 19:31:13 2013 +0300

    win usb: request for driver uninstall only for driver that were installed
    
    Currently when spice_usb_device_manager_remove_dev() is called,
    for windows clients a request to uninstall the driver is sent to usbclerk.
    
    This cause problems when 2 instances (A and B) of the client are running:
    - Both A and B get notified about a new USB device when it's plugged in
    - A is requested to usbredir the USB device.
    - A requests usbclerk to install WinUSB driver for that device.
    - usbclerk starts installing the driver
    - Windows sends to both A and B - device removal events, which may cause
      B to call spice_usb_device_manager_remove_dev.
    - usbclerk completes installing the driver and reply to A
    - B requests usbclerk to remove the WinUSB driver for that device.
    
    To prevent that, spice-gtk now requests usbclerk to remove the driver
    only if it was the instance that requested the driver to be installed.
    This is done with the help of a new device SPICE_USB_DEVICE_STATE_INSTALLED
    state.
    
    rhbz#919166

diff --git a/gtk/usb-device-manager.c b/gtk/usb-device-manager.c
index 71d3462..1051d10 100644
--- a/gtk/usb-device-manager.c
+++ b/gtk/usb-device-manager.c
@@ -135,6 +135,7 @@ enum {
     SPICE_USB_DEVICE_STATE_DISCONNECTING,
     SPICE_USB_DEVICE_STATE_INSTALLING,
     SPICE_USB_DEVICE_STATE_UNINSTALLING,
+    SPICE_USB_DEVICE_STATE_INSTALLED,
     SPICE_USB_DEVICE_STATE_MAX
 };
 
@@ -1106,7 +1107,11 @@ static void spice_usb_device_manager_drv_install_cb(GObject *gobject,
 
     spice_usb_device_unref(device);
 
-    spice_usb_device_set_state(device, SPICE_USB_DEVICE_STATE_NONE);
+    if (is_install) {
+        spice_usb_device_set_state(device, SPICE_USB_DEVICE_STATE_INSTALLED);
+    } else {
+        spice_usb_device_set_state(device, SPICE_USB_DEVICE_STATE_NONE);
+    }
 
     if (err) {
         g_warning("win usb driver %s failed -- %s", opstr, err->message);
@@ -1550,10 +1555,17 @@ void spice_usb_device_manager_disconnect_device(SpiceUsbDeviceManager *self,
 #ifdef G_OS_WIN32
     SpiceWinUsbDriver *installer;
     UsbInstallCbInfo *cbinfo;
+    guint8 state;
 
     g_warn_if_fail(device != NULL);
     g_warn_if_fail(self->priv->installer != NULL);
 
+    state = spice_usb_device_get_state(device);
+    if ((state != SPICE_USB_DEVICE_STATE_INSTALLED) &&
+        (state != SPICE_USB_DEVICE_STATE_CONNECTED)) {
+        return;
+    }
+
     spice_usb_device_set_state(device, SPICE_USB_DEVICE_STATE_UNINSTALLING);
     if (! self->priv->installer) {
         self->priv->installer = spice_win_usb_driver_new();


More information about the Spice-commits mailing list