qemu-devel
[Top][All Lists]
Advanced

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

[Qemu-devel] USB proxy the other way


From: andrzej zaborowski
Subject: [Qemu-devel] USB proxy the other way
Date: Tue, 24 Apr 2007 21:17:58 +0200

Hi,
 attached is an experimental patch that makes use of the Linux' USB
gadgetfs userspace API to allow connecting emulated USB devices to the
host instead of to the qemu virtual machine. This is very much
proof-of-concept now but I hope to use it for connecting emulated
S3C2410-based devices (and possibly PXA and/or OMAP310, all of which
can work as USB slaves) to the computer on which qemu is running and
have them appear as if an actual device (say a mobile phone) was
connected to its USB cradle.

To enable gadgetfs on a Linux 2.6 host you will need to enable the
following three options:

Device Drivers -> USB support -> USB Gadget Support -> Support for USB Gadgets
Device Drivers -> USB support -> USB Gadget Support -> Gadget Filesystem
Device Drivers -> USB support -> USB Gadget Support -> USB Peripheral
Controller = Dummy HCD (unless you have a real USB slave controller)

You will need to edit drivers/usb/gadget/Kconfig and comment out line
221 (#        select USB_GADGET_DUALSPEED) because Dummy HCD is
dualspeed by default and qemu currently only has full-speed devices.
If you don't do that then gadgetfs expects high-speed descriptors and
qemu doesn't provide those, Linux panics and locks-up (yes, gadgetfs
seems to be totally untested). This could also be worked around in
qemu easily.

Not all devices can be emulated this way because of gadgetfs and
dummy_hcd limitations. For example a USB Hub cannot be emulated
because dummy_hcd will report it as a bus-powered device and Linux
power policy will not accept bus-powered Hubs. (This is unfortunate
because qemu connects all devices through a hub normally). GadgetFS'es
signalling of requests on data endpoints is also very strange and I
haven't found any way to know when a request occured other than
polling. Does anyone have experience with gadgetfs?

I tested with the following devices:

QEMU USB-HID mouse and tablet.

QEMU USB CDC/RNDIS NIC which was posted a long time ago in
http://lists.gnu.org/archive/html/qemu-devel/2006-11/msg00034.html -
gadgetfs doesn't support multiple configuration devices so I had to
make some changes on top of it that are in the second attached file.

Wacom Penpartner tablet emulation from
http://svn.o-hand.com/view/misc/trunk/qemu-packaging/qemu/debian/patches/90-oh-wacom.patch?rev=158&view=auto

A host IRDA dongle (attached through usb_add host:2.26)

QEMU USB-Hub - this didn't work because of the power policy thing.
QEMU USB Mass Storage Device - this also didn't work, probably the
timing of the bulk transfers is not correct with the polling - advices
welcome.

Any suggestions about the cmdline switches/monitor commands to deal
with virtual USB slaves, also welcome.

Here are some funny logs from my (non-virtual) PC:


Apr 23 03:05:27 [kernel] gadgetfs: bound to dummy_udc driver
Apr 23 03:05:28 [kernel] usb 3-1: new full speed USB device using
dummy_hcd and address 35
Apr 23 03:05:28 [kernel] gadgetfs: connected
Apr 23 03:05:28 [kernel] gadgetfs: disconnected
Apr 23 03:05:28 [kernel] gadgetfs: connected
Apr 23 03:05:28 [kernel] usb 3-1: Product: QEMU USB Mouse
Apr 23 03:05:28 [kernel] usb 3-1: Manufacturer: QEMU 0.8.2
Apr 23 03:05:28 [kernel] usb 3-1: SerialNumber: 1
Apr 23 03:05:28 [kernel] usb 3-1: configuration #1 chosen from 1 choice
Apr 23 03:05:28 [kernel] gadgetfs: configuration #1
Apr 23 03:05:28 [kernel] input: QEMU 0.8.2 QEMU USB Mouse as
/class/input/input24
Apr 23 03:05:28 [kernel] input: USB HID v0.01 Mouse [QEMU 0.8.2 QEMU
USB Mouse] on usb-dummy_hcd-1
Apr 23 03:06:08 [kernel] gadgetfs: disconnected
Apr 23 03:06:08 [kernel] usb 3-1: USB disconnect, address 35


Apr 24 18:11:09 [kernel] gadgetfs: bound to dummy_udc driver
Apr 24 18:11:10 [kernel] usb 3-1: new full speed USB device using
dummy_hcd and address 15
Apr 24 18:11:10 [kernel] gadgetfs: connected
Apr 24 18:11:10 [kernel] gadgetfs: disconnected
Apr 24 18:11:10 [kernel] gadgetfs: connected
Apr 24 18:11:10 [kernel] usb 3-1: Product: RNDIS/QEMU USB Network Device
Apr 24 18:11:10 [kernel] usb 3-1: Manufacturer: QEMU
Apr 24 18:11:10 [kernel] usb 3-1: SerialNumber: 1
Apr 24 18:11:10 [kernel] usb 3-1: configuration #2 chosen from 1 choice
Apr 24 18:11:10 [kernel] gadgetfs: configuration #2
Apr 24 18:11:10 [kernel] eth1: register 'cdc_ether' at
usb-dummy_hcd-1, CDC Ethernet Device, 40:01:02:03:04:05
Apr 24 18:11:10 [kernel] usbcore: registered new interface driver cdc_ether
Apr 24 18:12:30 [kernel] gadgetfs: disconnected
Apr 24 18:12:30 [kernel] usb 3-1: USB disconnect, address 15
Apr 24 18:12:30 [kernel] eth1: unregister 'cdc_ether' usb-dummy_hcd-1,
CDC Ethernet Device


Apr 24 21:18:44 [kernel] gadgetfs: bound to dummy_udc driver
Apr 24 21:18:45 [kernel] usb 3-1: new full speed USB device using
dummy_hcd and address 17
Apr 24 21:18:45 [kernel] gadgetfs: connected
Apr 24 21:18:45 [kernel] gadgetfs: disconnected
Apr 24 21:18:45 [kernel] gadgetfs: connected
Apr 24 21:18:45 [kernel] usb 3-1: Product:  IrDA/USB Bridge
Apr 24 21:18:45 [kernel] usb 3-1: Manufacturer:  Sigmatel Inc
Apr 24 21:18:45 [kernel] usb 3-1: configuration #1 chosen from 1 choice
Apr 24 21:18:45 [kernel] gadgetfs: configuration #1
               - Last output repeated twice -
Apr 24 21:18:45 [kernel] SigmaTel STIr4200 IRDA/USB found at address
17, Vendor: 66f, Product: 4200
Apr 24 21:18:45 [kernel] drivers/net/irda/stir4200.c: IrDA: Registered
SigmaTel device irda0
Apr 24 21:19:09 [kernel] gadgetfs: disconnected
Apr 24 21:19:09 [kernel] usb 3-1: USB disconnect, address 17

Regards,
Andrzej

Attachment: qemu-gadgetfs.patch
Description: Binary data

Attachment: qemu-usb-net-gadget.patch
Description: Binary data


reply via email to

[Prev in Thread] Current Thread [Next in Thread]