Audio lag from VM (W10) to host (Linux)

Hey everybody,

I had a VFIO/KVM with W11 just for gaming. Everything was grand, except W11 itself. I was fed up, so I decided to go back to W10. Without changing anything in the KVM XML, I booted up with W10 ISO and did a clean install of Windows.
All looked good, until I noticed there is an audio lag of about 1-3 seconds all the time, resulting in some intense games to be unplayable.

I had this issue long ago, but then I was using pulse audio, and the solution I applied and worked, was this one (from my notes):

<qemu:commandline>
  <qemu:arg value='-device'/>
  <qemu:arg value='ich9-intel-hda,bus=pcie.0,addr=0x1b'/>
  <qemu:arg value='-device'/>
  <qemu:arg value='hda-micro,audiodev=hda'/>
  <qemu:arg value='-audiodev'/>
  <qemu:arg value='pa,id=hda,server=unix:/run/user/1000/pulse/native'/>
</qemu:commandline>



Append the following lines to /etc/apparmor.d/abstractions/libvirt-qemu

/etc/pulse/client.conf.d/ r,
/etc/pulse/client.conf.d/* r,
/run/user/1000/pulse/native rw,
/home/wizard/.config/pulse/* r,
/home/wizard/.config/pulse/cookie k,

However, I am running pipewire now, so I assume this won’t work.

Any ideas how to make it work, or if there is another solution for pipewire?

inxi -F  :heavy_check_mark:

System:
  Host: manjaro-pc Kernel: 5.10.131-1-MANJARO arch: x86_64 bits: 64
    Desktop: KDE Plasma v: 5.24.6 Distro: Manjaro Linux
Machine:
  Type: Desktop System: Gigabyte product: X570 AORUS MASTER v: -CF
    serial: <superuser required>
  Mobo: Gigabyte model: X570 AORUS MASTER serial: <superuser required>
    UEFI: American Megatrends LLC. v: F36b date: 02/16/2022
CPU:
  Info: 12-core model: AMD Ryzen 9 5900X bits: 64 type: MT MCP cache:
    L2: 6 MiB
  Speed (MHz): avg: 3101
    min/max: 2200/5994:6294:6442:6146:5846:5102:4950:5698:5550:5398:5250 cores:
    1: 3938 2: 3799 3: 2880 4: 2879 5: 2879 6: 2879 7: 3599 8: 2877 9: 2878
    10: 2876 11: 2871 12: 3599 13: 3374 14: 3598 15: 2878 16: 2879 17: 2879
    18: 2874 19: 2879 20: 2897 21: 2878 22: 2875 23: 2875 24: 3598
Graphics:
  Device-1: AMD Navi 21 [Radeon RX 6800/6800 XT / 6900 XT] driver: vfio-pci
    v: 0.2
  Device-2: AMD Navi 14 [Radeon RX 5500/5500M / Pro 5500M] driver: amdgpu
    v: kernel
  Device-3: Logitech HD Pro Webcam C920 type: USB
    driver: snd-usb-audio,uvcvideo
  Display: x11 server: X.Org v: 21.1.4 with: Xwayland v: 22.1.3 driver: X:
    loaded: amdgpu unloaded: modesetting,radeon gpu: amdgpu resolution:
    1: 1200x1920~60Hz 2: 2560x1440~60Hz
  OpenGL: renderer: AMD Radeon RX 5500 XT (navi14 LLVM 14.0.6 DRM 3.40
  5.10.131-1-MANJARO)
    v: 4.6 Mesa 22.1.3
Audio:
  Device-1: AMD Navi 21/23 HDMI/DP Audio driver: vfio-pci
  Device-2: AMD Navi 10 HDMI Audio driver: snd_hda_intel
  Device-3: AMD Starship/Matisse HD Audio driver: snd_hda_intel
  Device-4: Creative Sound Blaster GC7 type: USB
    driver: cdc_acm,hid-generic,snd-usb-audio,usbhid
  Device-5: Logitech HD Pro Webcam C920 type: USB
    driver: snd-usb-audio,uvcvideo
  Sound Server-1: ALSA v: k5.10.131-1-MANJARO running: yes
  Sound Server-2: PipeWire v: 0.3.56 running: yes
Network:
  Device-1: Intel Wi-Fi 6 AX200 driver: iwlwifi
  IF: wlp6s0 state: down mac: 6e:bf:5c:cb:9e:fe
  Device-2: Intel I211 Gigabit Network driver: igb
  IF: enp7s0 state: up speed: 1000 Mbps duplex: full mac: b4:2e
  Device-3: Realtek RTL8125 2.5GbE driver: vfio-pci
  IF-ID-1: virbr0 state: down mac: 52:54
Bluetooth:
  Device-1: Intel AX200 Bluetooth type: USB driver: btusb
  Report: rfkill ID: hci0 state: up address: see --recommends
Drives:
  Local Storage: total: 5.93 TiB used: 1.13 TiB (19.1%)
  ID-1: /dev/nvme0n1 vendor: Samsung model: SSD 970 EVO 500GB
    size: 465.76 GiB
  ID-2: /dev/nvme1n1 vendor: Seagate model: XPG GAMMIX S50 Lite
    size: 953.87 GiB
  ID-3: /dev/nvme2n1 vendor: Samsung model: SSD 970 EVO 250GB
    size: 232.89 GiB
  ID-4: /dev/sda vendor: Toshiba model: HDWE140 size: 3.64 TiB
  ID-5: /dev/sdb vendor: Samsung model: SSD 840 EVO 250GB size: 232.89 GiB
  ID-6: /dev/sdc vendor: Samsung model: SSD 850 EVO 500GB size: 465.76 GiB
Partition:
  ID-1: / size: 448.43 GiB used: 204.72 GiB (45.7%) fs: ext4
    dev: /dev/nvme0n1p2
  ID-2: /boot/efi size: 299.4 MiB used: 288 KiB (0.1%) fs: vfat
    dev: /dev/nvme0n1p1
Swap:
  ID-1: swap-1 type: partition size: 8.8 GiB used: 0 KiB (0.0%)
    dev: /dev/nvme0n1p3
Sensors:
  System Temperatures: cpu: 43.5 C mobo: N/A gpu: amdgpu temp: 58.0 C
  Fan Speeds (RPM): N/A gpu: amdgpu fan: 1316
Info:
  Processes: 530 Uptime: 49m Memory: 62.73 GiB used: 23.44 GiB (37.4%)
  Shell: Zsh inxi: 3.3.19

ps. I posted this yesterday, but I deleted it as I thought I fixed… well…no…

While not a “solution” to your issue, I will offer that I have had good luck passing through a PCI-e sound card or a PCI-e USB card with a USB audio adapter plugged into it for low-latency audio on games

Could be a solution, although totally inconvenient for me, however it was working well with W10 before, W11 too and the problem started when I re-installed W10. So it must be some sort of setting.

There has been an issue with wireplumber that prevents audio in a VM from working, you could try switching to pipewire-media-session temporarily until they fix it. If you do that the pulseaudio solution you have above might work as long as you have pipewire-pulse installed.

If that doesn’t work, passing through the audio chipset can also work if you don’t need audio on the host while using the VM.

I’m doing the chip passthrough personally and the only issue I’ve encountered is that I can’t restart the VM, I have to shut it down and start it back up because for whatever reason the audio chip doesn’t reset properly when doing a regular restart.

But that is an issue I can deal with since it means no problems with latency.