I am using my gentoo as host os for kvm with vga passthrough for playing on windows, but I have problem with sound, it is not good quality, I hear something like crackles in sound. I am using pulseaudio (with --system mode) on host os, and tried different sample rates but didnt helped. My command for vm:
qemu-system-x86_64 \
-vga none \
-enable-kvm -m 10000 -cpu host -smp 8,cores=4,threads=2,sockets=1 \
-device ioh3420,bus=pci.0,addr=1c.0,multifunction=on,port=1,chassis=1,id=root.1 \
-device vfio-pci,host=01:00.0,bus=root.1,addr=00.0,multifunction=on,x-vga=on \
-net nic,macaddr=50:E5:49:57:74:E3 -net bridge,vlan=0 \
-soundhw hda \
-boot d \
-hda /dev/sdb \
-usb -usbdevice host:09da:000a
I tried setting PULSE_LATENCY_MSEC, QEMU_PA_SAMPLES, but didnt helped. I also checked with live cd on guest vm, to make sure if its not windows problem, but the result is the same. I also tried setting -soundhw ac97, but there is no official support for ac97 on windows 10 and I have some delays with sounds, but less interference.
my audio is:
00:1f.3 Audio device [0403]: Intel Corporation Sunrise Point-H HD Audio [8086:a170] (rev 31) (snd_hda_intel on msi z170a m7),
and versions of qemu and pulseaudio:
QEMU emulator version 2.3.0, Copyright (c) 2003-2008 Fabrice Bellard
pulseaudio 5.0
Could anyone help with this?
I just saw your question after searching for pretty much this same problem myself and then found the solution on a you tube video about 5 mins later. Here is what I did and a link to the YouTube video is at the end. This little guide assumes Windows 10, you didn't specify so I have had to guess here:
First you need to switch Qemu to use AC97, for the soundhw option use ac97 i.e. -soundhw ac97
and also set QEMU_AUDIO_DRV to alsa (I also am setting the QEMU_PA_SAMPLES to 128 and not sure if that will affect things or not) QEMU_PA_SAMPLES=128 QEMU_AUDIO_DRV=alsa
Then start Windows and go to the Realtek website and download the AC97 Driver for Vista / Win7 Realtek AC97 download link, once downloaded extract this somewhere you will find it again.
Then for the next section you need to disable driver signature enforcement, I recommend watching the video for this part as it makes it a bit easier to see which option to click but it basically is:
Open Settings, go to Update & Security, Choose Recovery in the left pane, Choose Advanced Start-up, Choose Troubleshoot, Advanced Options, Choose Start Up Settings and then press the restart button.
Once restarted you need to choose option 7 which disables driver signature enforcement.
Once Windows comes back go into Device Manager, Right click the multimedia device and choose 'Update Driver Software' click browse on the next page and navigate to the realtek driver you downloaded earlier.
Let windows do its thing and hey presto crystal clear audio :) The Youtube video I followed