usb.rst 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140
  1. .. _pcsys_005fusb:
  2. USB emulation
  3. -------------
  4. QEMU can emulate a PCI UHCI, OHCI, EHCI or XHCI USB controller. You can
  5. plug virtual USB devices or real host USB devices (only works with
  6. certain host operating systems). QEMU will automatically create and
  7. connect virtual USB hubs as necessary to connect multiple USB devices.
  8. .. _usb_005fdevices:
  9. Connecting USB devices
  10. ~~~~~~~~~~~~~~~~~~~~~~
  11. USB devices can be connected with the ``-device usb-...`` command line
  12. option or the ``device_add`` monitor command. Available devices are:
  13. ``usb-mouse``
  14. Virtual Mouse. This will override the PS/2 mouse emulation when
  15. activated.
  16. ``usb-tablet``
  17. Pointer device that uses absolute coordinates (like a touchscreen).
  18. This means QEMU is able to report the mouse position without having
  19. to grab the mouse. Also overrides the PS/2 mouse emulation when
  20. activated.
  21. ``usb-storage,drive=drive_id``
  22. Mass storage device backed by drive_id (see
  23. :ref:`disk_005fimages`)
  24. ``usb-uas``
  25. USB attached SCSI device, see
  26. `usb-storage.txt <https://git.qemu.org/?p=qemu.git;a=blob_plain;f=docs/usb-storage.txt>`__
  27. for details
  28. ``usb-bot``
  29. Bulk-only transport storage device, see
  30. `usb-storage.txt <https://git.qemu.org/?p=qemu.git;a=blob_plain;f=docs/usb-storage.txt>`__
  31. for details here, too
  32. ``usb-mtp,rootdir=dir``
  33. Media transfer protocol device, using dir as root of the file tree
  34. that is presented to the guest.
  35. ``usb-host,hostbus=bus,hostaddr=addr``
  36. Pass through the host device identified by bus and addr
  37. ``usb-host,vendorid=vendor,productid=product``
  38. Pass through the host device identified by vendor and product ID
  39. ``usb-wacom-tablet``
  40. Virtual Wacom PenPartner tablet. This device is similar to the
  41. ``tablet`` above but it can be used with the tslib library because in
  42. addition to touch coordinates it reports touch pressure.
  43. ``usb-kbd``
  44. Standard USB keyboard. Will override the PS/2 keyboard (if present).
  45. ``usb-serial,chardev=id``
  46. Serial converter. This emulates an FTDI FT232BM chip connected to
  47. host character device id.
  48. ``usb-braille,chardev=id``
  49. Braille device. This will use BrlAPI to display the braille output on
  50. a real or fake device referenced by id.
  51. ``usb-net[,netdev=id]``
  52. Network adapter that supports CDC ethernet and RNDIS protocols. id
  53. specifies a netdev defined with ``-netdev …,id=id``. For instance,
  54. user-mode networking can be used with
  55. .. parsed-literal::
  56. |qemu_system| [...] -netdev user,id=net0 -device usb-net,netdev=net0
  57. ``usb-ccid``
  58. Smartcard reader device
  59. ``usb-audio``
  60. USB audio device
  61. ``u2f-{emulated,passthru}``
  62. Universal Second Factor device
  63. .. _host_005fusb_005fdevices:
  64. Using host USB devices on a Linux host
  65. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  66. WARNING: this is an experimental feature. QEMU will slow down when using
  67. it. USB devices requiring real time streaming (i.e. USB Video Cameras)
  68. are not supported yet.
  69. 1. If you use an early Linux 2.4 kernel, verify that no Linux driver is
  70. actually using the USB device. A simple way to do that is simply to
  71. disable the corresponding kernel module by renaming it from
  72. ``mydriver.o`` to ``mydriver.o.disabled``.
  73. 2. Verify that ``/proc/bus/usb`` is working (most Linux distributions
  74. should enable it by default). You should see something like that:
  75. ::
  76. ls /proc/bus/usb
  77. 001 devices drivers
  78. 3. Since only root can access to the USB devices directly, you can
  79. either launch QEMU as root or change the permissions of the USB
  80. devices you want to use. For testing, the following suffices:
  81. ::
  82. chown -R myuid /proc/bus/usb
  83. 4. Launch QEMU and do in the monitor:
  84. ::
  85. info usbhost
  86. Device 1.2, speed 480 Mb/s
  87. Class 00: USB device 1234:5678, USB DISK
  88. You should see the list of the devices you can use (Never try to use
  89. hubs, it won't work).
  90. 5. Add the device in QEMU by using:
  91. ::
  92. device_add usb-host,vendorid=0x1234,productid=0x5678
  93. Normally the guest OS should report that a new USB device is plugged.
  94. You can use the option ``-device usb-host,...`` to do the same.
  95. 6. Now you can try to use the host USB device in QEMU.
  96. When relaunching QEMU, you may have to unplug and plug again the USB
  97. device to make it work again (this is a bug).