[Spice-devel] Can we directly redir usb hub?

Hans de Goede hdegoede at redhat.com
Mon Jun 24 11:00:42 PDT 2013


Hi,

On 06/24/2013 11:40 AM, 邵鄭叡 wrote:
> Hi all,
> maybe I should post this message to [usbredir and qemu devel list] ,
> but I just didnt find it :)
>
> By default, spice-gtk filters out 'usb hubs' from redir list, and only show 'non-hub non-interface' usb devs.
>
> But sometime, we want to just simply pass a usb-hub to guest , and dont care about whatever is plugged on it.
>
> So, I tweaked spice-gtk a bit  like this:
>
> static void spice_usb_device_manager_add_dev(SpiceUsbDeviceManager  *self,
>                                               GUdevDevice            *udev)
> {
> ...
>      /* Skip hubs */
>      devclass = g_udev_device_get_sysfs_attr(udev, "bDeviceClass");
>      if (!devclass || !strcmp(devclass, "09"))
>      {
> -       return;
> +      printf(" Yes, it's a hub, and we want it :) \n  ");
> ...
>      }
>
> Then, something interesting happened after I redired a usb-hub with a usb-disk plugged on it.
> 1. The hub is successfully redired into guest.
>      I can see it in 'Window Device Manager' , it is correctly recognized as 'usb hub' with right usb transfer speed (in my case , 480M).
>
> 2. The usb-disk is also detected by windows, and addressed under the hub.
>     But we are not lucky enough to see it as 'usb mass storage', but as 'unknown device'.
>
> 3. If I redir the usb-disk rather than the hub, that's OK.

USB-redirection works on a usb-device bases, if you redirect a hub, you will only be redirecting
the hub and not any devices attached to it, which is why your test fails and why you cannot
redirect hubs (as you've found out). This is also the reason why the check is there (and should stay
there) in spice_usb_device_manager.

Regards,

Hans




More information about the Spice-devel mailing list