Ubuntu – How to route KVM virtual machine audio to Ubuntu 11.10 host using virt-manager

11.10kvmsoundvirtualizationwindows xp

I've been using KVM in combination with Virt-Manager and Remmina at a fair success up until now. The issue I need to solve now is to get audio from a virtualized Windows XP and make it audible on the Ubuntu 11.10 host.

Remmina / RDP works for 'simple' audio (system sounds and such), but when the source gets trickier (e.g. Flash audio), Remmina / RDP messes up. So I figured I'd just connect to the machine directly using Virt-Manager. Unfortunately, it seems that even though I have successfully configured the AC97 audio device on WinXP, it's unable to get it's output to the Ubuntu host. This is probably because Virt-Manager uses VNC (and AFAIK, VNC doesn't transport audio).

Does anyone know if there is a solution to fix this? I've heard of Spice, but the installation required so much voodoo last time I checked, I figured I'd let that solution boil to maturity a little longer 😉

But perhaps there are other options I haven't thought of yet (which don't require switching to VirtualBox / VMware)…

Best Answer

Somebody clicked a link above that put the URL for this page into one of my logs and I stumbled on it just now. I'm sure the subject is no longer important but just in case it might help somebody:

I'd like to point out a small detail for people who are still using K/Ubuntu 11.04: The PulseAudio system is quite sophisticated and the people who maintain it consider it to have some security issues. As such, in 11.04, they had a bunch of features that were turned OFF by default. They were related to the permissions that a VM could get so that it would talk to Pulse.

If you rummage around the various configuration files for virt-manager, KVM and Pulse Audio you can just change the settings to allow VM's to talk to the local pulse installation without restriction (well, it makes sense if you are the only user on a desktop - don't do it if you are sharing a server with multiple users.) Sorry I can't remember the specifics. I have had no reason to look at any of this stuff since upgrading to K/Ubuntu 12.04.

Regarding RDP: For a long time there were bugs in rdesktop related to audio. At some point the problems were resolved and I used rdesktop without any difficulty. Unfortunately I can't remember if it was the rdesktop group that changed their code or if the solution was to change the permissions in Pulse. In any case I don't remember any significant difficulty under K/Ubuntu 11.10 and, once again, I'm not having any sound issues as of K/Ubuntu 12.04

Finally, FYI, some months after I wrote the above-mentioned howto about spice (which has moved, btw, to this link and remains one of the most popular articles on my site,) Canonical did incorporate the most excellent SPICE work of Mr. Derzhavets into the main Ubuntu repos. So, if you upgrade now to K/Ubuntu 12 you will find that SPICE just works - out of the box, no voodoo - with both WinXP and Linux VM's.

I should mention that K/Ubuntu 12.04 gave me choppy video (I was watching Netflix over a local network to a WinXP VM,) but it did work. Now I've upgraded to 12.10 and the video is smooth, audio is excellent. Again: this is out of the box. Just create your VM and, if it's WinXP, install the appropriate SPICE drivers. Instructions are available in the same howto

If you have VM's that you created under K/Ubuntu 11 you can follow the instructions under "Modifying a VM's Hardware Configuration" to add SPICE support.

Note that your video drivers might give you better/different results on 12.04 and even 12.10. Also I am using the simple spicec client, not the more sophisticated client that is called via virt-manager.)

HTH and thanks for the link! All the best, God bless, --Sam.