From Fedora Project Wiki

< Features

Revision as of 08:57, 26 July 2011 by Jwrdegoede (talk | contribs) (How To Test)

= USB redirection over the network


Allow redirecting a USB device to another machine over the network. For example use an USB webcam attached to machine A on machine B. For Fedora 16 the focus will be on allowing using USB devices attached to some machine (not necessarily the host machine) inside a qemu-kvm virtual machine.


  • Name: Hans de Goede
  • Email:

Current status

  • Targeted release: Fedora 16
  • Last updated: Jul 26, 2011
  • Percentage of completion: 75%

Detailed Description

The intend is to deliver the following for Fedora 16:

  • A usbredir package (done) with libraries for:
    • parsing the usbnetredir protocol
    • redirecting a local attached usb-device through an application provided pipe
  • Support for qemu to receive data from a usbredir pipe, and make the redirected USB device show up as being attached to the emulated host controller inside the virtual machine (done)
  • Support for spice-server (80% done) and spice-gtk (the gtk spice client widget) to use usbredir
  • A nice UI for redirecting USB devices from a spice-gtk based virtual machine viewer

Benefit to Fedora

Currently many Fedora users choose to not use qemu-kvm for virtual machines, but instead use a less open alternative not shipped with Fedora. One of the stated reasons for doing so is the less then stellar support for USB redirection with qemu-kvm. Besides adding support for USB redirection over the network, qemu's USB redirection support is being improved in general, including adding support for USB 2.


The needed changes are isolated to the new usbredir package, qemu and spice. Work is already underway to try and get all changes upstream.

How To Test

Right now, to test the usb2 support:

  • start qemu from the cmdline with your usual arguments and add: "-device ich9-usb-ehci1,addr=1d.7,multifunction=on,id=ehci -device ich9-usb-uhci1,addr=1d.0,multifunction=on,id=uhci-1,masterbus=ehci.0,firstport=0 -device ich9-usb-uhci2,addr=1d.1,multifunction=on,id=uhci-2,masterbus=ehci.0,firstport=2, -device ich9-usb-uhci3,addr=1d.2,multifunction=on,id=uhci-3,masterbus=ehci.0,firstport=4"
  • A bug has been filed to add support for this to libvirt, see:

Right now, to test the usb network redirection support:

  • install the usbredir-server package
  • run lsusb and find the vendor-id:product-id of the device you want to redirect
  • run usbredirserver as root like this: "usbredirserver -p 4000 vendor-id:product-id", ie: "usbredirserver -p 4000 15d9:0a41"
  • start qemu from the cmdline with your usual arguments add then usb2 arguments from above and add: "-chardev socket,id=usbredirchardev,host=localhost,port=4000 -device usb-redir,chardev=usbredirchardev,id=usbredirdev,bus=ehci.0"
  • note that:
    • If the redirected device is on a different machine then were qemu is running localhost should be replaced by the hostname or ip-address of that machine
    • You can use a different port by changing the "-p 4000" parameter to usbredirserver, this way you can also redirect multiple devices

Once most bits are in place:

  • Create a virtual machine with virt-manager, select Spice as display protocol and select the QXL graphics card
  • Connect to the virtual machine from some machine with a gtk based spice-client to the virtual machine
  • Select a random USB device attached to your local machine to redirect to the vm
  • Check that the USB device shows up in the vm, and works normally.

User Experience

Users wishing to redirect USB devices to virtual machines can do so easily from the virtual machine viewer UI, and can do so even when connected to the virtual machine from another machine then the host.



Contingency Plan

The plan is to deliver the various bits mentioned under "Detailed Description" one by one. If time runs out before we can deliver the lower bullets, the already delivered bits will stay in place and can still be used, but only from the cmdline rather then from a nice integrated UI experience.



Release Notes

Fedora 16 now comes with improved USB support for qemu-kvm virtual machines. The virtual machines are now capable of emulating or passing through USB 2 devices. It is now also possible to redirect a USB device over the network, this allows passing through a USB device from another pc then the host to a virtual machine. See: for detailed instructions on how to enable these new features.

Comments and Discussion