https://linux-kvm.org/index.php?title=USB&feed=atom&action=historyUSB - Revision history2024-03-29T14:04:09ZRevision history for this page on the wikiMediaWiki 1.39.5https://linux-kvm.org/index.php?title=USB&diff=2904&oldid=prevKevinWolf at 14:38, 1 March 20102010-03-01T14:38:50Z<p></p>
<table style="background-color: #fff; color: #202122;" data-mw="interface">
<col class="diff-marker" />
<col class="diff-content" />
<col class="diff-marker" />
<col class="diff-content" />
<tr class="diff-title" lang="en">
<td colspan="2" style="background-color: #fff; color: #202122; text-align: center;">← Older revision</td>
<td colspan="2" style="background-color: #fff; color: #202122; text-align: center;">Revision as of 10:38, 1 March 2010</td>
</tr><tr><td colspan="2" class="diff-lineno" id="mw-diff-left-l17">Line 17:</td>
<td colspan="2" class="diff-lineno">Line 17:</td></tr>
<tr><td class="diff-marker"></td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div>= Detailed =</div></td><td class="diff-marker"></td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div>= Detailed =</div></td></tr>
<tr><td class="diff-marker"></td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div>== Building ==</div></td><td class="diff-marker"></td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div>== Building ==</div></td></tr>
<tr><td class="diff-marker" data-marker="−"></td><td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;"><div>When building qemu for x86_64-<del style="font-weight: bold; text-decoration: none;">softemu </del>with default options, you</div></td><td class="diff-marker" data-marker="+"></td><td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><div>When building qemu for x86_64-<ins style="font-weight: bold; text-decoration: none;">softmmu </ins>with default options, you</div></td></tr>
<tr><td class="diff-marker"></td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div>get all of the mentioned devices with the expection of OHCI. To build it, add</div></td><td class="diff-marker"></td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div>get all of the mentioned devices with the expection of OHCI. To build it, add</div></td></tr>
<tr><td class="diff-marker" data-marker="−"></td><td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;"><div>the following line to x86_64-<del style="font-weight: bold; text-decoration: none;">softemu</del>/config-devices.mak before running make:</div></td><td class="diff-marker" data-marker="+"></td><td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><div>the following line to x86_64-<ins style="font-weight: bold; text-decoration: none;">softmmu</ins>/config-devices.mak before running make:</div></td></tr>
<tr><td class="diff-marker"></td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><br/></td><td class="diff-marker"></td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><br/></td></tr>
<tr><td class="diff-marker"></td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div><pre>CONFIG_USB_OHCI = y</pre></div></td><td class="diff-marker"></td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div><pre>CONFIG_USB_OHCI = y</pre></div></td></tr>
<!-- diff cache key kvmwiki-kvmwiki_:diff::1.12:old-2832:rev-2904 -->
</table>KevinWolfhttps://linux-kvm.org/index.php?title=USB&diff=2832&oldid=prevKevinWolf at 17:01, 29 January 20102010-01-29T17:01:36Z<p></p>
<p><b>New page</b></p><div>= Feature functional description =<br />
This feature is about providing virtual USB devices to guests. For passing<br />
through real USB hardware from the host, see [[UsbPassthrough]].<br />
<br />
qemu provides three different USB controllers that can be used:<br />
* PIIX3 UHCI controller (called ''piix3-usb-uhci'', default on PC)<br />
* PIIX4 UHCI controller (called ''piix4-usb-uhci'')<br />
* Apple OHCI controller (called ''pci-ohci'')<br />
<br />
It provides a bunch of virtual USB devices. To see all of the devices built<br />
into your qemu binary, run ''qemu -device ?'' and look for entries with a<br />
"bus USB" on them. The most interesting ones are probably:<br />
* USB tablet (called ''usb-tablet''): Provides an absolute pointer device which often helps with getting a consistent mouse cursor position in VNC.<br />
* USB disk (called ''usb-storage'')<br />
* Keyboard (''usb-kbd'') and mouse (''usb-mouse'')<br />
<br />
= Detailed =<br />
== Building ==<br />
When building qemu for x86_64-softemu with default options, you<br />
get all of the mentioned devices with the expection of OHCI. To build it, add<br />
the following line to x86_64-softemu/config-devices.mak before running make:<br />
<br />
<pre>CONFIG_USB_OHCI = y</pre><br />
<br />
== Running ==<br />
To be able to use USB at all, you need to start qemu with a USB controller. If<br />
you use the legacy ''-usb'' and ''-usbdevice'' options, you will automatically<br />
get a ''piix3-usb-uhci'' for PCs unless you specify something else. The new<br />
method works like this:<br />
<br />
<pre>qemu-system-x86_64 -device piix3-usb-uhci ...</pre><br />
<br />
Do the same for any USB devices that you want to be present from start. Some of<br />
them need some more options, like in the following example for a USB disk:<br />
<br />
<pre>qemu-system-x86_64 -device piix3-usb-uhci \<br />
-drive id=my_usb_disk,file=usbdisk.img,if=none \<br />
-device usb-storage,drive=my_usb_disk</pre><br />
<br />
== Hotplugging ==<br />
Just like in real hardware, USB allows hotplugging. You can use the monitor<br />
commands ''device_add'' and ''device_del'' to attach a new device or remove<br />
a previously attached one. For device_add, use the same format as for -device.<br />
Attaching a new USB disk would look like this:<br />
<br />
<pre>(qemu) drive_add 0 id=my_usb_disk,if=none,file=usbdisk.img<br />
OK<br />
(qemu) device_add usb-storage,id=my_usb_disk,drive=my_usb_disk</pre><br />
<br />
For removing the disk you need the ID that you have assigned in the device_add<br />
call:<br />
<br />
<pre>(qemu) device_del my_usb_disk</pre><br />
<br />
= Test cases =<br />
The following sections describe test cases to verify correct function of the<br />
USB emulation in qemu. Each of the test cases should be run with multiple guest<br />
OSes. Consider variation of the USB host controller, though piix3-usb-uhci is<br />
the most important one for PCs.<br />
<br />
== Basic usage ==<br />
This sections contains test cases which only consider coldplugged USB devices.<br />
<br />
=== Input devices ===<br />
* Keyboard: Type a few lines to see if there is any unexpected behaviour like missing or additional characters, or if the keymap is wrong. This can be tested both in different OSes with a proper USB HID driver and in DOS or bootloaders like GRUB (testing the PS/2 keyboard emulation).<br />
* Pointer devices (''usb-mouse'', ''usb-tablet'' and ''usb-wacom-tablet''): Can the mouse cursor be moved? Do all three buttons work? Does the mouse wheel work?<br />
<br />
=== USB disks ===<br />
* Attach a raw image as a USB disk to the VM (no filesystem needed on it). Write some data to it and get the md5sum in the guest. Compare it to the md5sum of the image on the host.<br />
<br />
== Hotplugging devices ==<br />
=== Basic hotplugging ===<br />
* Attach a USB disk during runtime and check if it's accessible by the OS. You can run the same test as for coldplugged USB disks.<br />
* Detach the USB disk and check if the OS correctly detects this.<br />
<br />
=== Unusual numbers of input devices ===<br />
* What happens if the keyboard is unplugged and you type some text? Expected result is that nothing happens. After re-attaching an usb-kbd, it should be possible again to enter text.<br />
* Same test with unplugging and re-attaching the pointer device.<br />
* What happens with multiple keyboards or pointer devices attached? Expected result is that inputs are passed to one of the attached device (e.g. no duplicate characters). After removing the first keyboard, inputs should be directed to the keyboard that was attached later (i.e. you should still be able to input text as long as at least one keyboard is attached).<br />
<br />
=== Repeated hotplug/unplug ===<br />
* Attach 15 USB devices to the VM. USB hubs should automatically be added (check with ''info qtree'' in the monitor)<br />
* Attach a USB device and detach it. Repeat this for a large number of iterations (probably best to do using a shell script). Check if no devices are left in the end and if the OS's USB driver is still fine (check dmesg, for example)<br />
* Attach 15 USB devices and detach them again. Repeat this. Are automatically created hubs reused or are new hubs created each time?</div>KevinWolf