All of lore.kernel.org
 help / color / mirror / Atom feed
* [Qemu-devel] USB passthrough in qemu
@ 2014-06-12  8:53 Michal Suchanek
  2014-06-12  9:08 ` Gerd Hoffmann
  0 siblings, 1 reply; 11+ messages in thread
From: Michal Suchanek @ 2014-06-12  8:53 UTC (permalink / raw)
  To: Gerd Hoffmann; +Cc: qemu-devel

Hello,

I hit bug https://bugs.launchpad.net/qemu/+bug/685096 and found the
usb2.txt file in the source which is sadly not installed by the
distribution.

What I would like is an -usb2 option which instantiates both uhci/ohci
and ehci root hubs. I don't particularly care if the buses appear as
companion or separate.

I would also want the -usbdevice host option to attach devices by bus
compatibility to either uhci or ehci. The compatibility level is
already examined in the libusb code so the information should be
available.

Then bug 685096 should be resolved by simply specifying -usb2

Before I start butchering the options is there perhaps something like
this in progress/planned?

Thanks

Michal

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [Qemu-devel] USB passthrough in qemu
  2014-06-12  8:53 [Qemu-devel] USB passthrough in qemu Michal Suchanek
@ 2014-06-12  9:08 ` Gerd Hoffmann
  2014-06-12  9:25   ` Michal Suchanek
  0 siblings, 1 reply; 11+ messages in thread
From: Gerd Hoffmann @ 2014-06-12  9:08 UTC (permalink / raw)
  To: Michal Suchanek; +Cc: qemu-devel

On Do, 2014-06-12 at 10:53 +0200, Michal Suchanek wrote:
> Hello,
> 
> I hit bug https://bugs.launchpad.net/qemu/+bug/685096 and found the
> usb2.txt file in the source which is sadly not installed by the
> distribution.
> 
> What I would like is an -usb2 option which instantiates both uhci/ohci
> and ehci root hubs. I don't particularly care if the buses appear as
> companion or separate.

The -usb switch installs what the chipset has by default.  On
"pc" (piix4 southbridge) this is only uhci.  On "q35" (ich9 southbridge)
this actually is a uhci/ehci companion setup.

> I would also want the -usbdevice host option to attach devices by bus
> compatibility to either uhci or ehci. The compatibility level is
> already examined in the libusb code so the information should be
> available.

Not needed.  With the companion setup you'll have a usb bus which can
handle both usb1 and usb2 devices.

If the guest is new enough that it has drivers you can also simply use
xhci.

cheers,
  Gerd

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [Qemu-devel] USB passthrough in qemu
  2014-06-12  9:08 ` Gerd Hoffmann
@ 2014-06-12  9:25   ` Michal Suchanek
  2014-06-12 10:26     ` Gerd Hoffmann
  0 siblings, 1 reply; 11+ messages in thread
From: Michal Suchanek @ 2014-06-12  9:25 UTC (permalink / raw)
  To: Gerd Hoffmann; +Cc: qemu-devel

On 12 June 2014 11:08, Gerd Hoffmann <kraxel@redhat.com> wrote:
> On Do, 2014-06-12 at 10:53 +0200, Michal Suchanek wrote:
>> Hello,
>>
>> I hit bug https://bugs.launchpad.net/qemu/+bug/685096 and found the
>> usb2.txt file in the source which is sadly not installed by the
>> distribution.
>>
>> What I would like is an -usb2 option which instantiates both uhci/ohci
>> and ehci root hubs. I don't particularly care if the buses appear as
>> companion or separate.
>
> The -usb switch installs what the chipset has by default.  On
> "pc" (piix4 southbridge) this is only uhci.  On "q35" (ich9 southbridge)
> this actually is a uhci/ehci companion setup.

In this particular case using q35 as platform should not pose a
problem, hopefully.

Also using the sendmail.cf like commandline works.

However, for the piix4 which is the default platform and is desirable
due to driver issues in many cases no simple way to instantiate the
companion setup and have qemu automagically attach the devices
correctly exists.

>
>> I would also want the -usbdevice host option to attach devices by bus
>> compatibility to either uhci or ehci. The compatibility level is
>> already examined in the libusb code so the information should be
>> available.
>
> Not needed.  With the companion setup you'll have a usb bus which can
> handle both usb1 and usb2 devices.

So this is taken care of already. Nice

>
> If the guest is new enough that it has drivers you can also simply use
> xhci.

What xhci hub is emulated?

Anyway, xhci drivers for Windows are a mess so this is not going to be
an option for a while I guess.

Thanks

Michal

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [Qemu-devel] USB passthrough in qemu
  2014-06-12  9:25   ` Michal Suchanek
@ 2014-06-12 10:26     ` Gerd Hoffmann
  2014-06-12 16:00       ` Michal Suchanek
  0 siblings, 1 reply; 11+ messages in thread
From: Gerd Hoffmann @ 2014-06-12 10:26 UTC (permalink / raw)
  To: Michal Suchanek; +Cc: qemu-devel

  Hi,

> However, for the piix4 which is the default platform and is desirable
> due to driver issues in many cases no simple way to instantiate the
> companion setup and have qemu automagically attach the devices
> correctly exists.

We havn't added shortcuts like this to qemu for a while.  There are a
bunch of other new things which don't have a shorthand command line
switch too.  I suspect -usb2 wouldn't be very welcome @ qemu-devel.  You
can try sending a patch though, shouldn't be hard, code is there as q35
uses it.

There is also the option to stick things into a config file (see
docs/q35-chipset.cfg for an example), then do "-readconfig usb2.cfg".

> > If the guest is new enough that it has drivers you can also simply use
> > xhci.
> 
> What xhci hub is emulated?

nec.

> Anyway, xhci drivers for Windows are a mess so this is not going to be
> an option for a while I guess.

Thats why the "if the guest is new enough" above.  With windows this
works nicely only with win8+ (ships with xhci drivers).  For older
windows versions it is not really an option, you'd have to hunt down
drivers on the internet etc.

cheers,
  Gerd

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [Qemu-devel] USB passthrough in qemu
  2014-06-12 10:26     ` Gerd Hoffmann
@ 2014-06-12 16:00       ` Michal Suchanek
  2014-06-13  7:33         ` Gerd Hoffmann
  0 siblings, 1 reply; 11+ messages in thread
From: Michal Suchanek @ 2014-06-12 16:00 UTC (permalink / raw)
  To: Gerd Hoffmann; +Cc: qemu-devel

On 12 June 2014 12:26, Gerd Hoffmann <kraxel@redhat.com> wrote:
>   Hi,
>
>> However, for the piix4 which is the default platform and is desirable
>> due to driver issues in many cases no simple way to instantiate the
>> companion setup and have qemu automagically attach the devices
>> correctly exists.
>
> We havn't added shortcuts like this to qemu for a while.  There are a
> bunch of other new things which don't have a shorthand command line
> switch too.  I suspect -usb2 wouldn't be very welcome @ qemu-devel.  You
> can try sending a patch though, shouldn't be hard, code is there as q35
> uses it.
>
> There is also the option to stick things into a config file (see
> docs/q35-chipset.cfg for an example), then do "-readconfig usb2.cfg".

Maybe such config file or a pc-usb2 machine specification would work then.

>
>> > If the guest is new enough that it has drivers you can also simply use
>> > xhci.
>>
>> What xhci hub is emulated?
>
> nec.

That seems to work with Windows 7, at least the real hardware.

However,
-device nec-usb-xhci -usbdevice host:0b95:772b -usbdevice tablet
gives empy xhci bus and both devices attached to uhci bus which does not work.

The example in usb2.txt only shows how to manually specify to which
bus the usb devices are to be attached but there is no example of
making usb devices just work.

Thanks

Michal

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [Qemu-devel] USB passthrough in qemu
  2014-06-12 16:00       ` Michal Suchanek
@ 2014-06-13  7:33         ` Gerd Hoffmann
  2014-06-13  7:46           ` Michal Suchanek
  0 siblings, 1 reply; 11+ messages in thread
From: Gerd Hoffmann @ 2014-06-13  7:33 UTC (permalink / raw)
  To: Michal Suchanek; +Cc: qemu-devel

  Hi,

> However,
> -device nec-usb-xhci -usbdevice host:0b95:772b -usbdevice tablet
> gives empy xhci bus and both devices attached to uhci bus which does not work.

Either drop '-usb' so xhci is the only usb controller, or use -device
usb-$device,bus=$name to explicitly say which controller you want your
device attach to.

cheers,
  Gerd

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [Qemu-devel] USB passthrough in qemu
  2014-06-13  7:33         ` Gerd Hoffmann
@ 2014-06-13  7:46           ` Michal Suchanek
  2014-06-13  8:12             ` Gerd Hoffmann
  0 siblings, 1 reply; 11+ messages in thread
From: Michal Suchanek @ 2014-06-13  7:46 UTC (permalink / raw)
  To: Gerd Hoffmann; +Cc: qemu-devel

On 13 June 2014 09:33, Gerd Hoffmann <kraxel@redhat.com> wrote:
>   Hi,
>
>> However,
>> -device nec-usb-xhci -usbdevice host:0b95:772b -usbdevice tablet
>> gives empy xhci bus and both devices attached to uhci bus which does not work.
>
> Either drop '-usb' so xhci is the only usb controller, or use -device
> usb-$device,bus=$name to explicitly say which controller you want your
> device attach to.
>

I did drop -usb

I am using qemu 2.0

Do I need newer version for this to work?

Thanks

Michal

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [Qemu-devel] USB passthrough in qemu
  2014-06-13  7:46           ` Michal Suchanek
@ 2014-06-13  8:12             ` Gerd Hoffmann
  2014-06-13 14:26               ` Michal Suchanek
  0 siblings, 1 reply; 11+ messages in thread
From: Gerd Hoffmann @ 2014-06-13  8:12 UTC (permalink / raw)
  To: Michal Suchanek; +Cc: qemu-devel

On Fr, 2014-06-13 at 09:46 +0200, Michal Suchanek wrote:
> On 13 June 2014 09:33, Gerd Hoffmann <kraxel@redhat.com> wrote:
> >   Hi,
> >
> >> However,
> >> -device nec-usb-xhci -usbdevice host:0b95:772b -usbdevice tablet
> >> gives empy xhci bus and both devices attached to uhci bus which does not work.
> >
> > Either drop '-usb' so xhci is the only usb controller, or use -device
> > usb-$device,bus=$name to explicitly say which controller you want your
> > device attach to.
> >
> 
> I did drop -usb
> 
> I am using qemu 2.0
> 
> Do I need newer version for this to work?

Oops.  No.  Use -device instead of -usbdevice.

-usbdevice tried to be clever and automatically turns on usb for you, so
you get uhci too.

This kind problems showing up when qemu tries to do TheRightThing[tm]
automatically is exactly the reason why we don't like adding such things
any more.  What people consider useful simply changes over time and with
qemu improving.  The behavior made sense back the day where we didn't
have ehci+xhci emulation.  Now days not so much ...

cheers,
  Gerd

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [Qemu-devel] USB passthrough in qemu
  2014-06-13  8:12             ` Gerd Hoffmann
@ 2014-06-13 14:26               ` Michal Suchanek
  2014-06-13 14:51                 ` Gerd Hoffmann
  0 siblings, 1 reply; 11+ messages in thread
From: Michal Suchanek @ 2014-06-13 14:26 UTC (permalink / raw)
  To: Gerd Hoffmann; +Cc: qemu-devel

On 13 June 2014 10:12, Gerd Hoffmann <kraxel@redhat.com> wrote:
> On Fr, 2014-06-13 at 09:46 +0200, Michal Suchanek wrote:
>> On 13 June 2014 09:33, Gerd Hoffmann <kraxel@redhat.com> wrote:
>> >   Hi,
>> >
>> >> However,
>> >> -device nec-usb-xhci -usbdevice host:0b95:772b -usbdevice tablet
>> >> gives empy xhci bus and both devices attached to uhci bus which does not work.
>> >
>> > Either drop '-usb' so xhci is the only usb controller, or use -device
>> > usb-$device,bus=$name to explicitly say which controller you want your
>> > device attach to.
>> >
>>
>> I did drop -usb
>>
>> I am using qemu 2.0
>>
>> Do I need newer version for this to work?
>
> Oops.  No.  Use -device instead of -usbdevice.
>
> -usbdevice tried to be clever and automatically turns on usb for you, so
> you get uhci too.
>
> This kind problems showing up when qemu tries to do TheRightThing[tm]
> automatically is exactly the reason why we don't like adding such things
> any more.  What people consider useful simply changes over time and with
> qemu improving.  The behavior made sense back the day where we didn't
> have ehci+xhci emulation.  Now days not so much ...
>

Ok, so without a machine description that has ehci or xhci as default
device you cannot use -usbdevice and with -device you get a magic
incantation like -device usb-ehci,id=usb,bus=pci.0,addr=0x4 -device
usb-host,vendorid=0x0b95,productid=0x772b,id=hostdev0,bus=usb.0 which
is overly long for TheRightThing(tm) and as I understand it you have
to

1) know if the device is usb1/2/3 because here you specify by hand to
what bus it is attached to and it is not going to be automatically
attached to the correct bus

2) in case you have more than 1 device count usb ports and manually
assign each to unique port number and count pci ports to know where to
attach the ehci controller

which adds unnecessary manual configuration where qemu already has
existing code to deal with all this.

Thanks

Michal

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [Qemu-devel] USB passthrough in qemu
  2014-06-13 14:26               ` Michal Suchanek
@ 2014-06-13 14:51                 ` Gerd Hoffmann
  2014-06-13 16:45                   ` Michal Suchanek
  0 siblings, 1 reply; 11+ messages in thread
From: Gerd Hoffmann @ 2014-06-13 14:51 UTC (permalink / raw)
  To: Michal Suchanek; +Cc: qemu-devel

  Hi,

> Ok, so without a machine description that has ehci or xhci as default
> device you cannot use -usbdevice and with -device you get a magic
> incantation like -device usb-ehci,id=usb,bus=pci.0,addr=0x4 -device
> usb-host,vendorid=0x0b95,productid=0x772b,id=hostdev0,bus=usb.0 which
> is overly long for TheRightThing(tm) and as I understand it you have
> to

qemu -device nec-usb-xhci \
     -device usb-host,vendorid=0x0b95,productid=0x772b

Works just fine too.  As long as there is a single bus only there is no
need to explicitly specify which you want.  As long as you don't care
which port your devices are attached to you don't need to specify that.
And as long as you don't want/need refer to your devices you also don't
have to give them an id.

> 1) know if the device is usb1/2/3 because here you specify by hand to
> what bus it is attached to and it is not going to be automatically
> attached to the correct bus

Wrong.  Create a bus which can handle multiple usb speeds (xhci will do
for 1+2+3, ehci+companions will do for 1+2).  Use that.  Done.

And we had that topic in this thread already, so you know this.  Please
stop your false claims.

> 2) in case you have more than 1 device count usb ports and manually
> assign each to unique port number and count pci ports to know where to
> attach the ehci controller

You don't have to specify the port, qemu will happily pick a free one
automatically for you then.

cheers,
  Gerd

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [Qemu-devel] USB passthrough in qemu
  2014-06-13 14:51                 ` Gerd Hoffmann
@ 2014-06-13 16:45                   ` Michal Suchanek
  0 siblings, 0 replies; 11+ messages in thread
From: Michal Suchanek @ 2014-06-13 16:45 UTC (permalink / raw)
  To: Gerd Hoffmann; +Cc: qemu-devel

On 13 June 2014 16:51, Gerd Hoffmann <kraxel@redhat.com> wrote:
>   Hi,
>
>> Ok, so without a machine description that has ehci or xhci as default
>> device you cannot use -usbdevice and with -device you get a magic
>> incantation like -device usb-ehci,id=usb,bus=pci.0,addr=0x4 -device
>> usb-host,vendorid=0x0b95,productid=0x772b,id=hostdev0,bus=usb.0 which
>> is overly long for TheRightThing(tm) and as I understand it you have
>> to
>
> qemu -device nec-usb-xhci \
>      -device usb-host,vendorid=0x0b95,productid=0x772b
>
> Works just fine too.  As long as there is a single bus only there is no
> need to explicitly specify which you want.  As long as you don't care
> which port your devices are attached to you don't need to specify that.
> And as long as you don't want/need refer to your devices you also don't
> have to give them an id.

ok, that's something that could work in the future.

Attaching the passthru device and usb-tablet to xhci hub in in qemu
2.0 results in qemu aborting when Windows probes the xhci bus. Also
the driver Windows attaches after another boot is Renesas.

>
>> 1) know if the device is usb1/2/3 because here you specify by hand to
>> what bus it is attached to and it is not going to be automatically
>> attached to the correct bus
>
> Wrong.  Create a bus which can handle multiple usb speeds (xhci will do
> for 1+2+3, ehci+companions will do for 1+2).  Use that.  Done.
>
> And we had that topic in this thread already, so you know this.  Please
> stop your false claims.

ok, so this should work with -usbdevice *and* -device

>
>> 2) in case you have more than 1 device count usb ports and manually
>> assign each to unique port number and count pci ports to know where to
>> attach the ehci controller
>
> You don't have to specify the port, qemu will happily pick a free one
> automatically for you then.

Indeed, weeding out addr and multifunction in ich9-ehci-uhci.cfg still
results in working setup.

With -net none -readconfig /scratch/qemu/ehci.cfg -device
usb-host,vendorid=0x0b95,productid=0x772b -device
usb-host,vendorid=0x0a12,productid=0x0001 -device usb-tablet

I get networking over the USB Ethernet adaptor (which works only on
ehci), the qemu tablet gets attached to ehci and the BT dongle to
uhci.

Thanks

Michal

^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2014-06-13 16:45 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-06-12  8:53 [Qemu-devel] USB passthrough in qemu Michal Suchanek
2014-06-12  9:08 ` Gerd Hoffmann
2014-06-12  9:25   ` Michal Suchanek
2014-06-12 10:26     ` Gerd Hoffmann
2014-06-12 16:00       ` Michal Suchanek
2014-06-13  7:33         ` Gerd Hoffmann
2014-06-13  7:46           ` Michal Suchanek
2014-06-13  8:12             ` Gerd Hoffmann
2014-06-13 14:26               ` Michal Suchanek
2014-06-13 14:51                 ` Gerd Hoffmann
2014-06-13 16:45                   ` Michal Suchanek

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.