KVM has supported USB for some time... although I hadn't had a reason to try USB inside of a KVM virtual machine until now. I got a hand-me-down USB webcam. I plug the webcam into any of my desktop systems and it works great... but can I use it in a KVM virtual machine? Can I use my webcam with any KVM virtual machine even if the virtual machine isn't running on the same physical machine where the webcam is plugged in? It turns out that the answers are all yes... thanks to USB support being added to qemu and the SPICE remoting protocol and client applications.
Here is my scenerio. I have a rack mount server that I run a number of KVM virtual machines on. Some of the virtual machines are setup as servers and don't run any graphical environment whereas others are desktop virtual machines with graphical environments. I have a physical desktop system where I run a SPICE client application that allows me to graphically connect to the desktop VMs. The SPICE remoting protocol does a good job of giving me a good user experience complete with bi-directional sound... which means I can both play back sound and I can create new sound with a sound input like a microphone. I found a recipe for using USB devices with KVM:
After following those instructions I was able to record the following video with the USB webcam and microphone (regular audio jack) plugged into my physical desktop but used within the remote KVM virtual machine. As you can hear, the sound is a bit weird and I'm not sure why that is but it seems to work.
Direct link, right-click save as:
usb-webcam-inside-kvm-vm-20121112.webm (6.2 MB)
I've been keeping up with the virtualization related developments in the upcoming Fedora 15... but even if I weren't... Fedora offers a fedora-virt-preview repository that makes it easy to ckeck out the new stuff on Fedora 14.
Adding SPICE support to virt-manager is one of the upcoming features in Fedora 15 and as of 2011-03-28 it appears to be 100% done. I decided to use the fedora-virt-preview repository to check it out on my Fedora 14 workstation.
If you aren't familiar with virt-manager, it is the default GUI-based management application for virtual machines on Fedora and Red Hat Enterprise Linux... as well as a few other distros. virt-manager uses libvirt so it can support a number of virtual machine types but it is primarily used for KVM and Xen. I use it with KVM and KVM is the only virtualization product that offers SPICE support currently.
Then I deleted the existing VNC-based Graphics device and added a SPICE server. There are a number of different SPICE related options... what port to run it on... whether only the local machine can access it or if it is accessible remotely... use a password or not. There is a setting for SSL port but I'm not sure if that is actually operational... as I have not figured out the SSL stuff yet.
In virt-manager's preferences they have added a toggle for the default graphic device, either VNC or SPICE. Of course you can always delete one and add the other if the default isn't what you wanted.
What is SPICE? - It stands for "Simple Protocol for Independent Computing Environments". What does that mean exactly? SPICE is a remote display protocol designed specifically for use with the Linux kernel's built-in virtualization hypervisor KVM. SPICE is similar to terminal services but rather than multiple users sharing a single, remote physical machine, SPICE allows you to graphically connect to and use a local or a remote KVM virtual machine.
For those who want to just watch a video, here it is. Please note that I kept bumping the tripod by accident and autofocus can be annoying in some spots... and it isn't the highest quality... BUT it does give you a good idea of how well SPICE works.
If you can't see it, your browser probably doesn't support the WEBM video format yet. Right-click on any of the links below (webm and ogv) and download. Then play the file you downloaded in a recent version of VLC.
Red Hat actually opened up the SPICE protocol yesterday during their Virtual Experience 2009 event. Somehow I missed that. Have a look at the press release if you are interested... as well as their site to house the new open source project - spice-space.org.
This seems to have caused some buzz in certain corners of the virtualization websphere (does anyone still use that word?) but so far no one has said what it could mean for us run-of-the-mill Linux users looking for a good, fast remote desktop protocol. I asked a couple of questions on the fedora-virt mailing list and received some informative replies. I haven't had a chance to actually check out the SPICE website in depth yet though. For those wanting technical documentation, I've attached their spice_for_newbies and spice_user_manual PDFs.
I did want to share with you my response to one of the articles about the SPICE release that I ran across. You can go there and see the context this came from but it is pretty self explanatory.
As has been reported elsewhere, take the front page of Red Hat's website for example, Red Hat has "acquired" Qumranet Inc for a little over $100 million. In a presentation a month or two back for the BozemanLUG meeting... I played some demo videos of Qumranet's Solid ICE product and discussed KVM. Just in case you weren't aware, Qumranet is the company that sponsors the development of the Kernel Based Virtual Machine which got merged into the mainline Linux kernel starting with version 2.6.20. KVM requires hardware support for virtualization to be present in the CPU (Intel VT / AMD-V).
Doesn't Red Hat already use Xen in RHEL?
Yes, Red Hat does use Xen in RHEL although they prefer the term, Red Hat Virtualization. Fedora added support for KVM some time ago... and Red Hat has been working hard to help KVM get to the point where it is mature enough to become a replacement for Xen. They have also been funding a number FOSS virtualization related projects (see oVirt for example) several which support KVM.