[Spice-devel] [PATCH spice-gtk 3/3] usb-device-manager: Add automount disable / restore functionality

Hans de Goede hdegoede at redhat.com
Sun Jul 29 03:48:30 PDT 2012


Hi,

On 07/25/2012 03:36 PM, flooding Controlled wrote:
> Hi:
>     I am puzzled by some functions calling in the function : "spice_usb_device_manager_initable_init"
>
> At this block:
>   /* Do coldplug (detection of already connected devices) */
>      libusb_get_device_list(priv->context, &priv->coldplug_list);
>      list = g_udev_client_query_by_subsystem(priv->udev, "usb");
> ...
> ...
>      libusb_free_device_list(priv->coldplug_list, 1);
>      priv->coldplug_list = NULL;
>
> My questions are as follows:
> 1. Well, it seems that there are two routines to gather information of the  already connected devices :
> "libusb_get_device_list" and " g_udev_client_query_by_subsystem " ,  which is the really for wok one ?
> "g_udev_client_query_by_subsystem" seems to be , am I right ?

g_udev gives us a list of USB devices present in the system, and not much more then that, where as we
use libusb for low level device access, so we manage usb devices through a list of libusb_device references,
the only reason we're also using gusb is because it gives us dynamic notification when device get plugged
in / removed.

>
> 2. So, the second question is, why we gather info to "priv->coldplug_list", as the codes above, it just be freed, and has never been used!

That is not true, the coldplug_list gets used in spice_usb_device_manager_add_dev to not have to
call libusb_get_device_list repeatedly when enumerating devices already plugged in on spice-gtk
startup.

Regards,

Hans


More information about the Spice-devel mailing list