Video: Continuing Adventures with KVM

| |

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)