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

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

 



Hey,

On Sun, Mar 10, 2019 at 04:46:04PM +0200, Yuri Benditovich wrote:
> 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


Maybe 'If when calling handle_dev_change, the new device has the same
bus:address as an existing device cached in GUdevClient::udev_list,
then an "uevent" signal will not be emitted to notify about the new
device.' ?


>(for example, when due to some reason the
> 'redirecting' property is set for long time and during this
> time one of devices is changed).

I would remove the (), and reformulate a bit: "is set for a long time
and during this time, one device is unplugged and replugged"

For what it's worth, unplugging the device does not make the
cached libusb_device invalid, it can still be queried for its
bus/addr/vid/pid, at least on linux (in short, this indeed looks like
something which could happen).

Acked-by: Christophe Fergeau <cfergeau@xxxxxxxxxx>


> 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

Attachment: signature.asc
Description: PGP signature

_______________________________________________
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]