<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 10 Feb 2016, at 23:48 PM, Jonathon Jongsma <<a href="mailto:jjongsma@redhat.com" class="">jjongsma@redhat.com</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><span 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;" class="">On Thu, 2015-10-29 at 17:27 +0200, Dmitry Fleytman wrote:</span><br 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=""><blockquote type="cite" 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="">From: Kirill Moizik <<a href="mailto:kmoizik@redhat.com" class="">kmoizik@redhat.com</a>><br class=""><br class="">During device connection, unwanted hotplug events may happen.<br class="">We need to ignore those therefore we track redirection operations<br class="">in progress.<br class=""><br class="">See also comment to commit<br class="">"Do not process USB hotplug events while redirection is in progress"<br class="">that introduces corresponding filtering out logic.<br class=""><br class="">Signed-off-by: Kirill Moizik <<a href="mailto:kmoizik@redhat.com" class="">kmoizik@redhat.com</a>><br class="">Signed-off-by: Dmitry Fleytman <<a href="mailto:dfleytma@redhat.com" class="">dfleytma@redhat.com</a>><br class="">---<br class="">src/usb-device-manager.c | 69 +++++++++++++++++++++++++++++++++++++++--------<br class="">-<br class="">1 file changed, 56 insertions(+), 13 deletions(-)<br class=""><br class="">diff --git a/src/usb-device-manager.c b/src/usb-device-manager.c<br class="">index 4d376b6..0626923 100644<br class="">--- a/src/usb-device-manager.c<br class="">+++ b/src/usb-device-manager.c<br class="">@@ -122,6 +122,7 @@ struct _SpiceUsbDeviceManagerPrivate {<br class="">    GUdevClient *udev;<br class="">    libusb_device **coldplug_list; /* Avoid needless reprobing during init */<br class="">#else<br class="">+    gboolean redirecting;<br class=""></blockquote><br 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=""><span 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;" class="">I'd prefer a comment here indicating that in the gudev case, the 'redirecting'</span><br 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=""><span 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;" class="">status is handled by the GUdevClient.</span><br 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=""></div></blockquote><div><br class=""></div><div>Added.</div><br class=""><blockquote type="cite" class=""><div class=""><br 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=""><blockquote type="cite" 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="">    libusb_hotplug_callback_handle hp_handle;<br class="">#endif<br class="">#ifdef G_OS_WIN32<br class="">@@ -208,10 +209,25 @@<br class="">_spice_usb_device_manager_connect_device_async(SpiceUsbDeviceManager *self,<br class="">                                               GAsyncReadyCallback callback,<br class="">                                               gpointer user_data);<br class=""><br class="">+static<br class="">+void _connect_device_async_cb(GObject *gobject,<br class="">+                              GAsyncResult *channel_res,<br class="">+                              gpointer user_data);<br class="">+<br class="">G_DEFINE_BOXED_TYPE(SpiceUsbDevice, spice_usb_device,<br class="">                    (GBoxedCopyFunc)spice_usb_device_ref,<br class="">                    (GBoxedFreeFunc)spice_usb_device_unref)<br class=""><br class="">+static void<br class="">+_set_redirecting(SpiceUsbDeviceManager *self, gboolean is_redirecting)<br class="">+{<br class="">+#ifdef USE_GUDEV<br class="">+    g_object_set(self->priv->udev, "redirecting", is_redirecting, NULL);<br class="">+#else<br class="">+    self->priv->redirecting = is_redirecting;<br class="">+#endif<br class="">+}<br class="">+<br class="">#else<br class="">G_DEFINE_BOXED_TYPE(SpiceUsbDevice, spice_usb_device, g_object_ref,<br class="">g_object_unref)<br class="">#endif<br class="">@@ -1135,7 +1151,7 @@ static void<br class="">spice_usb_device_manager_drv_install_cb(GObject *gobject,<br class="">    SpiceUsbDevice *device;<br class="">    UsbInstallCbInfo *cbinfo;<br class="">    GCancellable *cancellable;<br class="">-    GAsyncReadyCallback callback;<br class="">+    gpointer data;<br class=""><br class="">    g_return_if_fail(user_data != NULL);<br class=""><br class="">@@ -1144,8 +1160,7 @@ static void<br class="">spice_usb_device_manager_drv_install_cb(GObject *gobject,<br class="">    device      = cbinfo->device;<br class="">    installer   = cbinfo->installer;<br class="">    cancellable = cbinfo->cancellable;<br class="">-    callback    = cbinfo->callback;<br class="">-    user_data   = cbinfo->user_data;<br class="">+    data        = cbinfo->user_data;<br class=""><br class="">    g_free(cbinfo);<br class=""><br class="">@@ -1167,8 +1182,8 @@ static void<br class="">spice_usb_device_manager_drv_install_cb(GObject *gobject,<br class="">    _spice_usb_device_manager_connect_device_async(self,<br class="">                                                   device,<br class="">                                                   cancellable,<br class="">-                                                   callback,<br class="">-                                                   user_data);<br class="">+                                                   _connect_device_async_cb,<br class="">+                                                   data);<br class=""><br class="">    spice_usb_device_unref(device);<br class="">}<br class="">@@ -1496,6 +1511,8 @@<br class="">_spice_usb_device_manager_uninstall_driver_async(SpiceUsbDeviceManager *self,<br class=""><br class="">#endif<br class=""><br class="">+#ifdef USE_USBREDIR<br class="">+<br class=""></blockquote><br 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=""><span 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;" class="">Moving the #ifdef outside of the function here seems like a fine change, but it</span><br 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=""><span 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;" class="">doesn't appear to be necessary for this patch and makes the patch slightly</span><br 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=""><span 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;" class="">harder to review. Can this change be split?</span><br 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=""></div></blockquote><div><br class=""></div><div><br class=""></div><div>Moving these chunks to a separate patch breaks compilation without USE_USBREDIR.</div><br class=""><blockquote type="cite" class=""><div class=""><br 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=""><blockquote type="cite" 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="">static void<br class="">_spice_usb_device_manager_connect_device_async(SpiceUsbDeviceManager *self,<br class="">                                               SpiceUsbDevice *device,<br class="">@@ -1513,7 +1530,6 @@<br class="">_spice_usb_device_manager_connect_device_async(SpiceUsbDeviceManager *self,<br class="">    result = g_simple_async_result_new(G_OBJECT(self), callback, user_data,<br class=""><br class="">spice_usb_device_manager_connect_device_async);<br class=""><br class="">-#ifdef USE_USBREDIR<br class="">    SpiceUsbDeviceManagerPrivate *priv = self->priv;<br class="">    libusb_device *libdev;<br class="">    guint i;<br class="">@@ -1559,18 +1575,17 @@<br class="">_spice_usb_device_manager_connect_device_async(SpiceUsbDeviceManager *self,<br class="">        libusb_unref_device(libdev);<br class="">        return;<br class="">    }<br class="">-#endif<br class=""><br class="">    g_simple_async_result_set_error(result,<br class="">                            SPICE_CLIENT_ERROR, SPICE_CLIENT_ERROR_FAILED,<br class="">                            _("No free USB channel"));<br class="">-#ifdef USE_USBREDIR<br class="">done:<br class="">-#endif<br class="">    g_simple_async_result_complete_in_idle(result);<br class="">    g_object_unref(result);<br class="">}<br class=""><br class="">+#endif<br class="">+<br class="">/**<br class=""> * spice_usb_device_manager_connect_device_async:<br class=""> * @self: a #SpiceUsbDeviceManager.<br class="">@@ -1589,11 +1604,20 @@ void<br class="">spice_usb_device_manager_connect_device_async(SpiceUsbDeviceManager *self,<br class="">                                             GAsyncReadyCallback callback,<br class="">                                             gpointer user_data)<br class="">{<br class="">+    g_return_if_fail(SPICE_IS_USB_DEVICE_MANAGER(self));<br class=""><br class="">-#if defined(USE_USBREDIR) && defined(G_OS_WIN32)<br class="">+#ifdef USE_USBREDIR<br class="">+<br class="">+    GSimpleAsyncResult *result =<br class="">+        g_simple_async_result_new(G_OBJECT(self), callback, user_data,<br class="">+                                 <br class="">spice_usb_device_manager_connect_device_async);<br class="">+<br class="">+    _set_redirecting(self, TRUE);<br class="">+<br class="">+#ifdef G_OS_WIN32<br class="">    if (self->priv->use_usbclerk) {<br class="">        _spice_usb_device_manager_install_driver_async(self, device,<br class="">cancellable,<br class="">-                                                       callback, user_data);<br class="">+                                                       callback, result);<br class="">        return;<br class="">    }<br class="">#endif<br class="">@@ -1601,10 +1625,13 @@ void<br class="">spice_usb_device_manager_connect_device_async(SpiceUsbDeviceManager *self,<br class="">    _spice_usb_device_manager_connect_device_async(self,<br class="">                                                   device,<br class="">                                                   cancellable,<br class="">-                                                   callback,<br class="">-                                                   user_data);<br class="">+                                                   _connect_device_async_cb,<br class="">+                                                   result);<br class="">+<br class="">+#endif<br class="">}<br class=""><br class="">+<br class="">/**<br class=""> * spice_usb_device_manager_connect_device_finish:<br class=""> * @self: a #SpiceUsbDeviceManager.<br class="">@@ -1630,6 +1657,22 @@ gboolean<br class="">spice_usb_device_manager_connect_device_finish(<br class="">    return TRUE;<br class="">}<br class=""><br class="">+#ifdef USE_USBREDIR<br class="">+static<br class="">+void _connect_device_async_cb(GObject *gobject,<br class="">+                              GAsyncResult *channel_res,<br class="">+                              gpointer user_data)<br class="">+{<br class="">+    SpiceUsbDeviceManager *self = SPICE_USB_DEVICE_MANAGER(gobject);<br class="">+    GSimpleAsyncResult *result = user_data;<br class="">+<br class="">+    _set_redirecting(self, FALSE);<br class="">+<br class="">+    g_simple_async_result_complete(result);<br class="">+    g_object_unref(result);<br class="">+}<br class="">+#endif<br class="">+<br class="">/**<br class=""> * spice_usb_device_manager_disconnect_device:<br class=""> * @manager: the #SpiceUsbDeviceManager manager<br class=""></blockquote><br 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=""><span 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;" class="">ACK with minor changes</span><br 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 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=""><span 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;" class="">Acked-by: Jonathon Jongsma <</span><a href="mailto:jjongsma@redhat.com" 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="">jjongsma@redhat.com</a><span 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;" class="">></span></div></blockquote></div><br class=""></body></html>