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

fpemud fpemud at gmail.com
Tue Jun 25 11:59:41 PDT 2013


On 06/25/2013 02:00 AM, Hans de Goede wrote:
> 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
>
>
> _______________________________________________
> Spice-devel mailing list
> Spice-devel at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/spice-devel

I want to implement a similar use case.
I think I can redirect the hub and all the devices attached to it when
they are inserted by writing a script
monitoring kernel usb device events.
I think the only problem is that the guest will see a different usb
topology. The guest will think usb
hub and the devices under it are siblings, not parent-child.
I guess qemu "usb_add" command has the same behavior.
However, the topology difference is irrelevant to me (a normal desktop
user).



More information about the Spice-devel mailing list