[spice-gtk 05/13] win-usb-dev: strict comparison of USB devices

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

 



If on device change the new device has the same bus:address
as existing device, win-usb-dev does not emit signal of
device change (for example, when due to some reason the
'redirecting' property is set for long time and during this
time one of devices is changed).
Make device comparison more strict: check not only bus:addr,
but also vid:pid.

Signed-off-by: Yuri Benditovich <yuri.benditovich@xxxxxxxxxx>
---
 src/win-usb-dev.c | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/src/win-usb-dev.c b/src/win-usb-dev.c
index a8d922f..d96e52a 100644
--- a/src/win-usb-dev.c
+++ b/src/win-usb-dev.c
@@ -385,20 +385,21 @@ static gboolean get_usb_dev_info(libusb_device *dev, GUdevDeviceInfo *udevinfo)
     return TRUE;
 }
 
-/* Only bus:addr are compared */
+/* comparing bus:addr and vid:pid */
 static gint gudev_devices_differ(gconstpointer a, gconstpointer b)
 {
     GUdevDeviceInfo *ai, *bi;
-    gboolean same_bus;
-    gboolean same_addr;
+    gboolean same_bus, same_addr, same_vid, same_pid;
 
     ai = G_UDEV_DEVICE(a)->priv->udevinfo;
     bi = G_UDEV_DEVICE(b)->priv->udevinfo;
 
     same_bus = (ai->bus == bi->bus);
     same_addr = (ai->addr == bi->addr);
+    same_vid = (ai->vid == bi->vid);
+    same_pid = (ai->pid == bi->pid);
 
-    return (same_bus && same_addr) ? 0 : -1;
+    return (same_bus && same_addr && same_vid && same_pid) ? 0 : -1;
 }
 
 static void notify_dev_state_change(GUdevClient *self,
-- 
2.17.1

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




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