<html><head><meta http-equiv="Content-Type" content="text/html charset=us-ascii"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><br class=""><div><blockquote type="cite" class=""><div class="">On 21 Feb 2016, at 09:28 AM, Dmitry Fleytman <<a href="mailto:dmitry@daynix.com" class="">dmitry@daynix.com</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><blockquote type="cite" class="" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><div class=""><br class="Apple-interchange-newline">On 19 Feb 2016, at 23:31 PM, Jonathon Jongsma <<a href="mailto:jjongsma@redhat.com" class="">jjongsma@redhat.com</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><span class="" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; float: none; display: inline !important;">On Thu, 2016-02-11 at 18:04 +0200, Dmitry Fleytman wrote:</span><br class="" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><blockquote type="cite" class="" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;">Hide rules order UsbDk to avoid showing specific USB<br class="">devices to Windows PnP manager.<br class=""><br class="">Spice-gtk loads hide rules for devices that should be<br class="">automatically redirected on connection to prevent Windows<br class="">from showing "New Hardware Found" wizard window for USB<br class="">devices that do not have driver on the local system.<br class=""><br class="">Signed-off-by: Dmitry Fleytman <<a href="mailto:dmitry@daynix.com" class="">dmitry@daynix.com</a>><br class="">---<br class="">src/usb-device-manager.c | 82<br class="">++++++++++++++++++++++++++++++++++++++++++++++++<br class="">1 file changed, 82 insertions(+)<br class=""><br class="">diff --git a/src/usb-device-manager.c b/src/usb-device-manager.c<br class="">index 9a3df97..ee8e490 100644<br class="">--- a/src/usb-device-manager.c<br class="">+++ b/src/usb-device-manager.c<br class="">@@ -29,6 +29,10 @@<br class="">#include <errno.h><br class="">#include <libusb.h><br class=""><br class="">+#ifdef G_OS_WIN32<br class="">+#include "usbdk_api.h"<br class="">+#endif<br class="">+<br class="">#if defined(USE_GUDEV)<br class="">#include <gudev/gudev.h><br class="">#elif defined(G_OS_WIN32)<br class="">@@ -122,6 +126,8 @@ struct _SpiceUsbDeviceManagerPrivate {<br class="">    libusb_hotplug_callback_handle hp_handle;<br class="">#endif<br class="">#ifdef G_OS_WIN32<br class="">+    usbdk_api_wrapper     *usbdk_api;<br class="">+    HANDLE                 usbdk_hider_handle;<br class="">    SpiceWinUsbDriver     *installer;<br class="">#endif<br class="">    gboolean               use_usbclerk;<br class="">@@ -184,6 +190,9 @@ static void spice_usb_device_unref(SpiceUsbDevice<br class="">*device);<br class="">#ifdef G_OS_WIN32<br class="">static guint8 spice_usb_device_get_state(SpiceUsbDevice *device);<br class="">static void  spice_usb_device_set_state(SpiceUsbDevice *device, guint8 s);<br class="">+<br class="">+static void _usbdk_hider_update(SpiceUsbDeviceManager *manager);<br class="">+static void _usbdk_hider_clear(SpiceUsbDeviceManager *manager);<br class="">#endif<br class=""><br class="">static gboolean spice_usb_manager_device_equal_libdev(SpiceUsbDeviceManager<br class="">*manager,<br class="">@@ -359,6 +368,9 @@ static void spice_usb_device_manager_finalize(GObject<br class="">*gobject)<br class="">#ifdef G_OS_WIN32<br class="">    if (priv->installer)<br class="">        g_object_unref(priv->installer);<br class="">+    if (!priv->use_usbclerk) {<br class="">+        _usbdk_hider_clear(self);<br class="">+    }<br class="">#endif<br class="">#endif<br class=""><br class="">@@ -430,6 +442,11 @@ static void spice_usb_device_manager_set_property(GObject<br class="">      *gobject,<br class="">        break;<br class="">    case PROP_AUTO_CONNECT:<br class="">        priv->auto_connect = g_value_get_boolean(value);<br class="">+#if defined(G_OS_WIN32) && defined(USE_USBREDIR)<br class="">+        if (!priv->use_usbclerk) {<br class="">+            _usbdk_hider_update(self);<br class="">+        }<br class="">+#endif<br class="">        break;<br class="">    case PROP_AUTO_CONNECT_FILTER: {<br class="">        const gchar *filter = g_value_get_string(value);<br class="">@@ -452,6 +469,12 @@ static void spice_usb_device_manager_set_property(GObject<br class="">      *gobject,<br class="">#endif<br class="">        g_free(priv->auto_connect_filter);<br class="">        priv->auto_connect_filter = g_strdup(filter);<br class="">+<br class="">+#if defined(G_OS_WIN32) && defined(USE_USBREDIR)<br class="">+        if (!priv->use_usbclerk) {<br class="">+            _usbdk_hider_update(self);<br class="">+        }<br class="">+#endif<br class="">        break;<br class="">    }<br class="">    case PROP_REDIRECT_ON_CONNECT: {<br class="">@@ -1863,6 +1886,65 @@ guint8 spice_usb_device_get_state(SpiceUsbDevice<br class="">*device)<br class=""><br class="">    return info->state;<br class="">}<br class="">+<br class="">+static<br class="">+gboolean _usbdk_hider_prepare(SpiceUsbDeviceManager *manager)<br class="">+{<br class="">+    SpiceUsbDeviceManagerPrivate *priv = manager->priv;<br class="">+<br class="">+    g_return_val_if_fail(!priv->use_usbclerk, FALSE);<br class="">+<br class="">+    if (priv->usbdk_hider_handle == NULL) {<br class="">+        priv->usbdk_hider_handle = usbdk_create_hider_handle(priv<br class="">->usbdk_api);<br class="">+        if (priv->usbdk_hider_handle == NULL) {<br class="">+            g_warning("Failed to instantiate UsbDk hider interface");<br class="">+            return FALSE;<br class="">+        }<br class="">+    }<br class="">+<br class="">+    return TRUE;<br class="">+}<br class="">+<br class="">+static<br class="">+void _usbdk_hider_clear(SpiceUsbDeviceManager *manager)<br class="">+{<br class="">+    SpiceUsbDeviceManagerPrivate *priv = manager->priv;<br class="">+<br class="">+    g_return_if_fail(!priv->use_usbclerk);<br class="">+<br class="">+    if (priv->usbdk_hider_handle != NULL) {<br class="">+        usbdk_clear_hide_rules(priv->usbdk_api, priv->usbdk_hider_handle);<br class="">+        usbdk_close_hider_handle(priv->usbdk_api, priv->usbdk_hider_handle);<br class="">+        priv->usbdk_hider_handle = NULL;<br class="">+    }<br class="">+}<br class="">+<br class="">+static<br class="">+void _usbdk_hider_update(SpiceUsbDeviceManager *manager)<br class="">+{<br class="">+    SpiceUsbDeviceManagerPrivate *priv = manager->priv;<br class="">+<br class="">+    g_return_if_fail(!priv->use_usbclerk);<br class="">+<br class="">+    if (priv->auto_connect_filter == NULL) {<br class="">+        SPICE_DEBUG("No autoredirect rules, no hider setup needed");<br class="">+        _usbdk_hider_clear(manager);<br class="">+        return;<br class="">+    }<br class="">+<br class="">+    if (!priv->auto_connect) {<br class="">+        SPICE_DEBUG("Auto-connect disabled, no hider setup needed");<br class="">+        _usbdk_hider_clear(manager);<br class="">+        return;<br class="">+    }<br class="">+<br class="">+    if(_usbdk_hider_prepare(manager)) {<br class="">+        usbdk_api_set_hide_rules(priv->usbdk_api,<br class="">+                                 priv->usbdk_hider_handle,<br class="">+                                 priv->auto_connect_filter);<br class=""></blockquote><br class="" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><span class="" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; float: none; display: inline !important;">So, in the previous version of this patch, you passed priv->redirect_on_connect</span><br class="" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><span class="" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; float: none; display: inline !important;">as the third parameter to usbdk_api_set_hide_rules(). Why did you change this to</span><br class="" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><span class="" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; float: none; display: inline !important;">priv->auto_connect_filter?</span><br class="" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;"></div></blockquote><div style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><br class=""></div><div style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class="">Hi Jonathon,</div><div style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><br class=""></div><div style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class="">After additional code review we realised that the logic was broken there. Hide rules are loaded for devices that should be redirected on plugin. This is done to avoid client OS attempts to load driver driver that may not be available for such devices. If I understand correctly redirect_on_connect string describes devices that are redirected on session connection i.e. plugged in already with client OS driver installed which is not the case for hide rules. And auto_connect_filter is for devices that are redirected on plug-in which is the case to be covered by hide rules.</div><div style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><br class=""></div><div style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class="">~Dmitry</div></div></blockquote><div><br class=""></div><div>Hi Jonathon,</div><div><br class=""></div><div>Any news regarding this patch?</div><div><br class=""></div><div>Thanks,</div><div>Dmitry</div><br class=""><blockquote type="cite" class=""><div class=""><br class="" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><blockquote type="cite" class="" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><div class=""><br class="" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><blockquote type="cite" class="" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;">+    }<br class="">+}<br class="">+<br class="">#endif<br class=""><br class="">static SpiceUsbDevice *spice_usb_device_ref(SpiceUsbDevice *device)</blockquote></div></blockquote></div></blockquote></div><br class=""></body></html>