Example assigning Host USB device to a Guest VM
This example was based on QEMU-KVM (0.15.0) as installed in Fedora 15. Would first show how does this manually, and second how to do it using the the Virt-manager tool. This HOWTO are limited to UHCI devices (no USB2 EHCI).
Here we'll use a phone attached to the host:
# Lsusb ... Bus 002 Device 003:id 18D1:4E11 Google Inc. Nexus One
(Note the Bus and device numbers).
manually, using QEMU-KVM command line
Here we add -usb
the to add a host controller, and add to -device usb-host,hostbus=2,hostaddr=3
add the host's USB device at Bus 2, device 3. Simple as that.
Now, we can verify the guest:
$ lspci ... 00:01.2 USB Controller:intel Corporation 82371SB PIIX3 USB [Natoma/triton II] (rev 01)
$ lsusbbus 001 Device 001:id 1d6b:0001 Linux Foundation 1.1 root hubbus 001 Device 002:id 18d1:4e11 Google Inc Nexus on E Phone
And on the phone enable USB Mass Storage, and the guest should display a dialog seeing a new USB filesystem. Open it and ...
$ Ls/media/[mountpoint]android/ data/ dcim/...
Managed, using Virt-manager
This assumes already has created a VM using Virt-manager. The VM is not running, and you're a like-to-add a USB host device to the VM. Start Virt-manager, and open your VM by double clicking on it. Click the virtual hardware details (lightbulb). Now Click Add Hardware, and Choose USB Host Device. Here, we are choosing the same Phone device.
Start the VM and verify the USB host controller and device show up like above. Now on the phone enable USB Mass Storage, and the guest should display a dialog seeing a new USB filesystem.
Assigning Host USB device to a Guest VM