Consistent Audio and KVM reboot issues

Hey everyone, I have a Windows 10 VM with a GPU passed through to it. I’m having problems getting a consistent audio experience with Pulseaudio. The VM is configured with an ich9 sound device. I have added the recomended settings that I found from various forums that I can’t find anymore. My qemu command line section of the VM XML file is this:

<qemu:commandline>
<qemu:arg value='-cpu'/>
<qemu:arg value='host,hv_time,kvm=off,hv_vendor_id=null'/>
<qemu:env name='QEMU_AUDIO_DRV' value='pa'/>
<qemu:env name='QEMU_PA_SAMPLES' value='1024'/>
<qemu:env name='QEMU_AUDIO_TIMER_PERIOD' value='150'/>
<qemu:env name='QEMU_PA_SERVER' value='/run/user/1000/pulse/native'/>
</qemu:commandline>

I could try ac97, but I had a blue screen when installing the drivers with the driver signing disabled.

I am also now having a problem where once I shut the VM down, I can’t start it back up again. If I try to restart Ubuntu it either takes a long time to shutdown or hangs. Either way I end up pressing the reset button.

1 Like

I currently have a working Windows 10 VM + Pulseaudio sound with an ich6 device.

My VM is running in a qemu system session and pulseaudio as user process. I didn’t even setup the env parameters and it’s working.

Might I know what kernel and software versions (qemu) in general you have running there?

I’ll have a look at my config and see if I did something specific to make it work, but I believe that at least with 4.17.11 it’s now working out of the box.

EDIT: Yeah didn’t do anything specific to the config

qemu-x86_64 version 2.12.0
libvirtd (libvirt) 4.5.0
Kernel 4.17.11

Works out of the box.
Pulseaudio just running as user process via systemd
systemctl --user enable [email protected] --now

and disabled the root pulseaudio service .

I’m dumb and forgot to mention that it is working, but sometimes I’ll boot the machine up and everything will start crackling. Other times its near perfect. It seemed to depend on what audio device is selected in Ubuntu when I start, but I haven’t found a consistent way to get it to work every time.

QEMU emulator version 2.11.1(Debian 1:2.11+dfsg-1ubuntu7.4)

Running Kernel 4.17.11 with 4.17.13 available

The problem is likely related to Line based Interrupts being used instead of Message Signaled interrupts

https://wiki.archlinux.org/index.php/PCI_passthrough_via_OVMF#Passing_VM_audio_to_host_via_PulseAudio

https://wiki.archlinux.org/index.php/PCI_passthrough_via_OVMF#Slowed_down_audio_pumped_through_HDMI_on_the_video_card

But aside from that, alternatively:
I’ve in the past run into crackling due to a mismatch in frequencies between the VM and host. Pulseaudio usually defaults to 44100 Hz. Windows, likes to default to 48000 Hz. This causes some buffer mismatch magic. When you change one to match the other, the crackling may also disappear. Your mileage may vary.

Default sample rate can be changed in /etc/pulse/daemon.conf
Or In windows via sound settings.

Extra articles:

I have moved everything over to 44.1khz and it kinda worked, the problem is consistency. Ubuntu can’t seem to keep track of what my default sound output is so maybe fixing that will help. I used a line in a config file to change it, but the device that number references changes often because I pass through my USB mic which messes things up.

I also tried using the audio output on my USB mic and then routing that to the line in and mic inputs on the sound card. That worked, but there is a grounding problem which results in a high frequency noise in the background.

1 Like