KVM/QEMU audio not working with Pulseaudio


So I have recently setup a new PC for KVM VGA Passthrough. I wanted to try out LookingGlass and was hoping to have the audio passed through to my Linux host speaks by way of pulseaudio. Sadly I cannot seem to get this to work. Also not sure where too put this but #helpdesk

CPU: Threadripper 2950x
MOBO: ASRock X399 Professional Gaming
RAM: 32Gb 3466mhz Vengeance
Video Cards: VEGA 56 on Host, VEGA 64 on VM

OpenSuSE Tumbleweed latest updates (Kernel: 4.19.1)
Windows 10

Relavant Config files: (I will point out the import bits below but just in case you wanted to see the whole thing I will post pastbin links here) I apparently cannot post all my links because I am a new user. :frowning: I can provide the pulse audio confi files later i guess.
Libvirt VM XML config file: https://pastebin.com/B0cjzcAD
libvirt.conf: https://pastebin.com/zqV7fBpB
qemu.conf: https://pastebin.com/R61N9FKc

Ok so I have read a bunch of different setup guides for this but all of them mention similar things.

  1. If should run QEMU as your user.

    #grep -v “^#” /etc/libvirt/qemu.conf | egrep “user =|group =”
    user = “rye”
    group = “users”

  2. Make sure qemu is configured to pass audio through even if there isn’t a screen.

    #grep -v “^#” /etc/libvirt/qemu.conf | egrep “audio”
    vnc_allow_host_audio = 0
    nographics_allow_host_audio = 1

  3. Add QEMU arguments to your libvirt XML.

     <qemu:env name='QEMU_AUDIO_DRV' value='pa'/>
     <qemu:env name='QEMU_PA_SAMPLES' value='8192'/>
     <qemu:env name='QEMU_AUDIO_ADC_FIXED_FREQ' value='48000'/>
     <qemu:env name='QEMU_PA_SERVER' value='unix:/run/user/1000/pulse/native'/>
  4. One of the many troubleshooting steps I took was to enable annoymous users for pulse.

    #grep -v “^#” /etc/pulse/default.pa | egrep “native”
    load-module module-native-protocol-unix auth-anonymous=1


#ll /run/user/1000/pulse/native
srwxrwxrwx 1 rye users 0 Nov 18 23:20 /run/user/1000/pulse/native


pactl --server=unix:/run/user/1000/pulse/native info
Server String: unix:/run/user/1000/pulse/native
Library Protocol Version: 32
Server Protocol Version: 32
Is Local: yes
Client Index: 24
Tile Size: 65472
User Name: rye
Host Name: linux-57qw
Server Name: pulseaudio
Server Version: 12.2-rebootstrapped
Default Sample Specification: s16le 2ch 44100Hz
Default Channel Map: front-left,front-right
Default Sink: alsa_output.usb-Corsair_Corsair_VOID_Wireless_Gaming_Dongle-00.analog-stereo
Default Source: alsa_input.usb-Corsair_Corsair_VOID_Wireless_Gaming_Dongle-00.analog-mono
Cookie: a29c:0070

Also the ‘value’ for the ‘QEMU_PA_SEVER’ I have switched that to both just the file and starting it with ‘unix:’.

The VM loads fine and there are no entries for pulse audio in syslog. I also enabled debug level logging in libvirt. That is the most furstrating part. There are no failures for pulseaudio. So I have nothing to work with.

Help Level1techs you are my only hope.

  • Also side noob question here but how do I add tags to the post? I want to add the helpdesk tag but there doesn’t appear to be a way to do so.

Try changing to ac97 and turning off driver signing to install the ac97 driver (can find this on google fairly easily). Should work after that.

@lessaj, Thanks for your advice. I just revisited this page after ‘Turkey Day’ to update it that I have solved the issue.

Its a pretty silly solution that makes me feel all sorts of dumb as well as a tad angry at OpenSuSE. Running:

/usr/bin/qemu-system-x86_64 -audio-help | grep Name:
Name: pa
Name: spice
Name: wav
Name: none

Shows that I have ‘pa’ support. However, running QEMU with the flag ‘-audio-help’ didn’t show ‘pa’ before. OpenSuSE doesn’t have ‘pa’ or ‘alsa’ support in QEMU by default. I guess the lesson is if you are having sound issues first make sure QEMU even supports sound. sigh.

The fix is to install the correct package.

zypper in qemu-audio-pa

poof it works! It is crackly and so on. I tried adjusting the settings the best I could but it never fully went away. I did find that the best option for sound quality was AC97 as @lessaj suggested.

However, turning off driver signing appears to be pretty hard when I cannot reboot. :frowning: I have the same reset bug that other topics on this forum. Until I get that fix I cannot get AC97 working.

In order to hear the sound, for the time being, I am passing the audio into the LINE IN of my Host sound card. Then using pulseaudio loopback module. I had to tweak the GAIN and volumes a tad but it works well enough for the time being.

Ah, yes that will do it. :slight_smile: Seems to be a part of my QEMU package on Arch. What you could probably do is just use Spice/Cirrus to get the driver installed (remove the GPU from the config for now). But since you have -some- sound at this point, interestingly enough, it may just need tweaks. In the case of my configuration I use:

    <qemu:env name='QEMU_AUDIO_DRV' value='pa'/>
    <qemu:env name='QEMU_PA_SERVER' value='/run/user/1000/pulse/native'/>
    <qemu:env name='QEMU_PA_SAMPLES' value='1024'/>
    <qemu:env name='QEMU_AUDIO_TIMER_PERIOD' value='150'/>

There is a little bit of crackle sometimes if I’m playing something on the host when I start the VM but I’ve found adjusting the volume up and down fixes that, and sometimes it doesn’t crackle at all. Not sure if that’s due to the PA patches that have been going in or not but aside from that it works really well.

Excellent! Thanks. There are sooo many posts out there putting the Pulseaudio settings differently I thought I must have been doing something wrong.

I switched to SPICE, got the AC97 drivers installed, changed my config to have settings like yours and boom it works! Yay! I do get a crackle sometimes but it is actually better then that darn LINE IN setup.

I haven’t really noticed any crackling beyond the start, maybe you need to use different sample values or something, I had tried several myself and finally 1024 worked the best, but great I’m glad it’s working!

Same problem here.

Alternative solution.
If you’re using a fancy KVM switch:
TESmart HDMI [email protected] Ultra HD 2x1

And it has audio out, pipe that back into your sound card’s line in with a physical audio cable. Some of the nicer KVMs take the video line out and convert to analog audio for you. To get the sound ‘through’ your sound card issue command:

pactl load-module module-loopback

will feed the line-in to the output (for regular sound card). If your’re running basic speakers this will work. (also loops back microphone so feedback warning here)

Yeah I actually mentioned that I was using LINE IN with loopback in order to hear the audio. With a lot of careful tweaking of the ‘gain’ and volume of the output I was able to get the audio to sound good.

Its a solid alternative but I noticed the soundcard that had the LINE IN sometimes generated a lot of ‘white noise’ as if it was getting interface. I also found it more difficult at switching the default output from one speaker to the other. I switch between headphones and my main speakers often. And lastly it doesn’t support a MIC. Having a Mic supported helps with some of the awkwardness of switching between Linux and Windows.


There is a tool called msi_util_v2. Run this on your windows vm. It can force MSI on supported devices (ie your hdmi audio device). That seems to have fixed my own crackling audio issues. Easy button.