Qemu is a great open source virtualization solution. I use it to test linux distributions, new configurations, etc...
The spice protocol, if you don't know it, allow you to run the virtual machine on a computer, and to access it remotly on another one. In short, it is just like vnc, but optimised for virtualization.
I never really tried to attach an usb device to a virtual machine before yesterday. It was to test a new udisks2 option (see http://forums.fedoraforum.org/showthread.php?t=290920). I used the qemu interface to do it. It worked fine. But a menu in spicy (the spice client I use) was intriguing: it was about 'usb redirection'. So what is that?
Just look here: http://hansdegoede.livejournal.com/11686.html
In short, it allows usb hot-plugging in the virtual machine, just like if it was a "real" machine. Simply amazing. You can hot-plug an usb device from the client, even if the virtual machine is running on another computer. Who said qemu is not user-friendly?
This feature is two years old, but I have never heard of it. I guess (hope) that I am not the only one who missed it, so I am reporting it to the forum.
Here the steps, if you don't want to read the article, for 3 usb ports.
Download the configuration file http://cgit.freedesktop.org/spice/qe...-ehci-uhci.cfg and save it in /etc/qemu.
Add to the qemu command line:
In spicy, check the option "auto redirect newly plugged in USB devices". You will be asked for the root password the first time, since a low level access to the usb devices is needed.Code:-readconfig /etc/qemu/ich9-ehci-uhci.cfg \ -chardev spicevmc,name=usbredir,id=usbredirchardev1 \ -device usb-redir,chardev=usbredirchardev1,id=usbredirdev1,debug=3 \ -chardev spicevmc,name=usbredir,id=usbredirchardev2 \ -device usb-redir,chardev=usbredirchardev2,id=usbredirdev2,debug=3 \ -chardev spicevmc,name=usbredir,id=usbredirchardev3 \ -device usb-redir,chardev=usbredirchardev3,id=usbredirdev3,debug=3
Enjoy qemu!
P.S.: for people who prefer graphical interfaces, you can do it with virt-manager: http://www.linux-kvm.com/content/usb...n-over-network (not tested).
---------- Post added at 02:55 PM ---------- Previous post was at 01:57 PM ----------
I forgot to say that the redirection is effective only if spicy has the focus, otherwise the computer will handle the usb device.
And if you don't want to enter a password, just add a policy permission for your user: create the file /etc/polkit-1/localauthority/50-local.d/qemu_spice_usb_redirection_permissions.pkla
where you replace <USER> by your user name. After that, put spicy in fullscreen, and there will be no difference with a non-virtual machine!Code:[Allow usb redirections for some users] Identity=unix-user:<USER> Action=org.spice-space.lowlevelusbaccess ResultAny=no ResultInactive=no ResultActive=yes



. I guess (hope) that I am not the only one who missed it, so I am reporting it to the forum.
Reply With Quote
