VFIO Audio

Hey everyone, I’ve got vfio working with looking glass and evdev and everything is awesome except for audio. I for the life of me cannot figure out how to get it to work! I would very much appreciate if anyone could help me out with this. I’m currently running the vm with the command (also I am on Antergos):

sudo virsh start win10

I used this Archwiki guide and this guide here (starting at #8) to try to fix it. Neither of these worked. Another thing I am unsure of is if the audio is broken within windows itself, I hooked up a sound system to my gpu with hdmi and that still doesn’t produce any audio. Also initially my monitor’s speakers would play audio but now they do not. My VM’s xml is here if it helps.

I think you need this in /etc/libvirt/qemu.conf as well, didn’t see it mentioned there.

nographics_allow_host_audio = 1

EDIT: Also, you’re running all this as root?

1 Like

<qemu:env name=‘QEMU_PA_SERVER’ value=’/run/USER/0/pulse/native’/>

You have to change the “user” to your actual username, and as @lessaj pointed out, configure QEMU to run as your user.

2 Likes

@lessaj Sorry forgot to mention that I already have this set to 1 in qemu.conf and yes I have been.
@FeelsBanjo If I change that path to 'run/gandalf/0/pulse/native’ it doesn’t exist. From what I understand the number indicates the user which I set to 0 since 0 is the uid for root. I do have qemu.conf set to run as user=“gandalf” however if I try to run the virsh command as my user I get permission errors, shown below:

virsh start win10
error: Failed to start domain win10
error: Failed to open config space file '/sys/bus/pci/devices/0000:01:00.0/config': Permission denied

Why are you running pulse as root instead of your user? Sorry just never seen that done before unless natively logged in as root.

Check that you have the socket file for your user. In my case:

    <qemu:env name='QEMU_AUDIO_DRV' value='pa'/>
    <qemu:env name='QEMU_PA_SERVER' value='/run/user/1000/pulse/native'/>
ls -la /run/user/1000/pulse/native
srw-rw-rw- 1 lessaj users 0 Jan  1 21:36 /run/user/1000/pulse/native
1 Like

When I don’t run it as root I get the permission error from above so I can’t start the vm. Yeah I have that one.

Can you provide the output of lspci -nnk

1 Like

Sure

GPU:

01:00.0 VGA compatible controller [0300]: Advanced Micro Devices, Inc. [AMD/ATI] Hawaii PRO [Radeon R9 290/390] [1002:67b1]
        Subsystem: Micro-Star International Co., Ltd. [MSI] Hawaii PRO [Radeon R9 290/390] [1462:3081]
        Kernel driver in use: vfio-pci
        Kernel modules: radeon, amdgpu
01:00.1 Audio device [0403]: Advanced Micro Devices, Inc. [AMD/ATI] Hawaii HDMI Audio [Radeon R9 290/290X / 390/390X] [1002:aac8]
        Subsystem: Micro-Star International Co., Ltd. [MSI] Hawaii HDMI Audio [Radeon R9 290/290X / 390/390X] [1462:aac8]
        Kernel driver in use: vfio-pci
        Kernel modules: snd_hda_intel

Complete output:

00:00.0 Host bridge [0600]: Intel Corporation 4th Gen Core Processor DRAM Controller [8086:0c00] (rev 06)
Subsystem: Micro-Star International Co., Ltd. [MSI] 4th Gen Core Processor DRAM Controller [1462:7916]
Kernel driver in use: hsw_uncore
00:01.0 PCI bridge [0604]: Intel Corporation Xeon E3-1200 v3/4th Gen Core Processor PCI Express x16 Controller [8086:0c01] (rev 06)
Kernel driver in use: pcieport
Kernel modules: shpchp
00:02.0 VGA compatible controller [0300]: Intel Corporation Xeon E3-1200 v3/4th Gen Core Processor Integrated Graphics Controller [8086:0412] (rev 06)
Subsystem: Micro-Star International Co., Ltd. [MSI] Xeon E3-1200 v3/4th Gen Core Processor Integrated Graphics Controller [1462:7916]
Kernel driver in use: i915
Kernel modules: i915
00:03.0 Audio device [0403]: Intel Corporation Xeon E3-1200 v3/4th Gen Core Processor HD Audio Controller [8086:0c0c] (rev 06)
Subsystem: Micro-Star International Co., Ltd. [MSI] Xeon E3-1200 v3/4th Gen Core Processor HD Audio Controller [1462:7916]
Kernel driver in use: snd_hda_intel
Kernel modules: snd_hda_intel
00:14.0 USB controller [0c03]: Intel Corporation 9 Series Chipset Family USB xHCI Controller [8086:8cb1]
Subsystem: Micro-Star International Co., Ltd. [MSI] 9 Series Chipset Family USB xHCI Controller [1462:7916]
Kernel driver in use: xhci_hcd
Kernel modules: xhci_pci
00:16.0 Communication controller [0780]: Intel Corporation 9 Series Chipset Family ME Interface #1 [8086:8cba]
Subsystem: Micro-Star International Co., Ltd. [MSI] 9 Series Chipset Family ME Interface [1462:7916]
Kernel driver in use: mei_me
Kernel modules: mei_me
00:1a.0 USB controller [0c03]: Intel Corporation 9 Series Chipset Family USB EHCI Controller #2 [8086:8cad]
Subsystem: Micro-Star International Co., Ltd. [MSI] 9 Series Chipset Family USB EHCI Controller [1462:7916]
Kernel driver in use: ehci-pci
Kernel modules: ehci_pci
00:1b.0 Audio device [0403]: Intel Corporation 9 Series Chipset Family HD Audio Controller [8086:8ca0]
Subsystem: Micro-Star International Co., Ltd. [MSI] 9 Series Chipset Family HD Audio Controller [1462:d916]
Kernel driver in use: snd_hda_intel
Kernel modules: snd_hda_intel
00:1c.0 PCI bridge [0604]: Intel Corporation 9 Series Chipset Family PCI Express Root Port 1 [8086:8c90] (rev d0)
Kernel driver in use: pcieport
Kernel modules: shpchp
00:1c.2 PCI bridge [0604]: Intel Corporation 9 Series Chipset Family PCI Express Root Port 3 [8086:8c94] (rev d0)
Kernel driver in use: pcieport
Kernel modules: shpchp
00:1c.3 PCI bridge [0604]: Intel Corporation 9 Series Chipset Family PCI Express Root Port 4 [8086:8c96] (rev d0)
Kernel driver in use: pcieport
Kernel modules: shpchp
00:1c.4 PCI bridge [0604]: Intel Corporation 9 Series Chipset Family PCI Express Root Port 5 [8086:8c98] (rev d0)
Kernel driver in use: pcieport
Kernel modules: shpchp
00:1c.6 PCI bridge [0604]: Intel Corporation 9 Series Chipset Family PCI Express Root Port 7 [8086:8c9c] (rev d0)
Kernel driver in use: pcieport
Kernel modules: shpchp
00:1d.0 USB controller [0c03]: Intel Corporation 9 Series Chipset Family USB EHCI Controller #1 [8086:8ca6]
Subsystem: Micro-Star International Co., Ltd. [MSI] 9 Series Chipset Family USB EHCI Controller [1462:7916]
Kernel driver in use: ehci-pci
Kernel modules: ehci_pci
00:1f.0 ISA bridge [0601]: Intel Corporation 9 Series Chipset Family Z97 LPC Controller [8086:8cc4]
Subsystem: Micro-Star International Co., Ltd. [MSI] 9 Series Chipset Family Z97 LPC Controller [1462:7916]
Kernel driver in use: lpc_ich
Kernel modules: lpc_ich
00:1f.2 SATA controller [0106]: Intel Corporation 9 Series Chipset Family SATA Controller [AHCI Mode] [8086:8c82]
Subsystem: Micro-Star International Co., Ltd. [MSI] 9 Series Chipset Family SATA Controller [AHCI Mode] [1462:7916]
Kernel driver in use: ahci
Kernel modules: ahci
00:1f.3 SMBus [0c05]: Intel Corporation 9 Series Chipset Family SMBus Controller [8086:8ca2]
Subsystem: Micro-Star International Co., Ltd. [MSI] 9 Series Chipset Family SMBus Controller [1462:7916]
Kernel driver in use: i801_smbus
Kernel modules: i2c_i801
01:00.0 VGA compatible controller [0300]: Advanced Micro Devices, Inc. [AMD/ATI] Hawaii PRO [Radeon R9 290/390] [1002:67b1]
Subsystem: Micro-Star International Co., Ltd. [MSI] Hawaii PRO [Radeon R9 290/390] [1462:3081]
Kernel driver in use: vfio-pci
Kernel modules: radeon, amdgpu
01:00.1 Audio device [0403]: Advanced Micro Devices, Inc. [AMD/ATI] Hawaii HDMI Audio [Radeon R9 290/290X / 390/390X] [1002:aac8]
Subsystem: Micro-Star International Co., Ltd. [MSI] Hawaii HDMI Audio [Radeon R9 290/290X / 390/390X] [1462:aac8]
Kernel driver in use: vfio-pci
Kernel modules: snd_hda_intel
03:00.0 SATA controller [0106]: ASMedia Technology Inc. ASM1062 Serial ATA Controller [1b21:0612] (rev 01)
Subsystem: Micro-Star International Co., Ltd. [MSI] ASM1062 Serial ATA Controller [1462:7916]
Kernel driver in use: ahci
Kernel modules: ahci
04:00.0 Ethernet controller [0200]: Qualcomm Atheros Killer E220x Gigabit Ethernet Controller [1969:e091] (rev 13)
Subsystem: Micro-Star International Co., Ltd. [MSI] Killer E220x Gigabit Ethernet Controller [1462:7916]
Kernel driver in use: alx
Kernel modules: alx
05:00.0 USB controller [0c03]: ASMedia Technology Inc. ASM1042A USB 3.0 Host Controller [1b21:1142]
Subsystem: Micro-Star International Co., Ltd. [MSI] ASM1042A USB 3.0 Host Controller [1462:7916]
Kernel driver in use: xhci_hcd
Kernel modules: xhci_pci
06:00.0 PCI bridge [0604]: ASMedia Technology Inc. Device [1b21:1184]
Kernel driver in use: pcieport
Kernel modules: shpchp
07:01.0 PCI bridge [0604]: ASMedia Technology Inc. Device [1b21:1184]
Kernel driver in use: pcieport
Kernel modules: shpchp
07:03.0 PCI bridge [0604]: ASMedia Technology Inc. Device [1b21:1184]
Kernel driver in use: pcieport
Kernel modules: shpchp
07:05.0 PCI bridge [0604]: ASMedia Technology Inc. Device [1b21:1184]
Kernel driver in use: pcieport
Kernel modules: shpchp
07:07.0 PCI bridge [0604]: ASMedia Technology Inc. Device [1b21:1184]
Kernel driver in use: pcieport
Kernel modules: shpchp

1 Like

As you get permission errors my first guess would be that you’re not a member of one or more groups needed. Please do a ‘id’ in a terminal and paste your output here for us to examine.

2 Likes

Ah yes, my brain messed up there sorry, but you should be running these programs as your user.

1 Like

Sure thing here it is:

uid=1000(gandalf) gid=100(users) groups=100(users),10(wheel),97(input),618(libvirt),999(kvm)

In qemu.conf I tried setting groups=“kvm” but it didn’t work.

@FeelsBanjo no worries :smiley: Not entirely sure if I’m doing that correctly.

Okay thanks I just wanted to see what that device was, thought it would be the GPU but wanted to make sure.

For reference this is my UID, GID and groups, I think you might need to be part of the libvirt group, not kvm.

uid=1000(lessaj) gid=100(users) groups=100(users),10(wheel),92(audio),95(storage),98(power),994(libvirt)

This is really all that’s not commented or blank line in my qemu.conf, mostly default options.

cat /etc/libvirt/qemu.conf | egrep -v "^$|^#"

nographics_allow_host_audio = 1
user = "lessaj"
group="users"
nvram = [
    "/usr/share/ovmf/OVMF-pure-efi.fd:/usr/share/ovmf/OVMF_VARS-pure-efi.fd",
    "/usr/share/AAVMF/AAVMF_CODE.fd:/usr/share/AAVMF/AAVMF_VARS.fd"
]

So based on your UID and GID you can use the same as what I have for the PA arguments inside the domain XML. If adding your user to some more groups doesn’t work I tried to clean up your domain XML a bit, you had a bunch of extra things that just didn’t need to be in there, such as since you have the OS installed you don’t need those disks anymore or their controllers. Trying to limit how many devices are there, also makes it easier to read. Can you try this domain XML?

Okay thanks for the help. I set my qemu.conf to be mostly like yours the only difference is that I have cgroup_device_acl set for the evdev stuff. I restarted libvirtd and my pc just to be sure but I get the following error:

virsh start win10  
error: Failed to start domain win10
error: error creating macvtap interface macvtap0@enp4s0 (52:54:00:e7:76:65): Operation not permitted

I tried to remove the network interface just to see if it would run but even with that removed I get this:

 virsh start win10
 error: Failed to start domain win10
 error: internal error: Process exited prior to exec: libvirt:  error : cannot limit locked memory to 11811160064: Operation not permitted

Can you try with sudo? Not familiar with any evdev stuff so reaching the end of my experience here…

With sudo everything works just not the audio. Sorry just saw your edit, the evdev stuff I don’t think will cause this but I’ll remove it just in case.

The ac97 driver requires a bit of manual work to install. Do you see an unknown device in device manager or have you done that? It’s not actually mentioned on either of those pages you linked.

Okay tried without the evdev stuff same result. No I haven’t done anything on the windows side I didn’t realize I needed to. I just checked device manager and it says that “Multimedia Audio Controller” is missing a driver. I tried to do the auto search but it failed.

Well this could have solved much easier, haha, follow this.

Alright I feel pretty dumb. It’s been so long I’ve forgot about some of the driver management stuff from windows! Thanks so much for the help! I’ve got audio now but it crackles, I used the patched qemu from the aur thats supposed to fix it but I remember someone said MSI might help.

I was able to fix the audio crackling with the following

  <qemu:env name='QEMU_PA_SAMPLES' value='1024'/>
  <qemu:env name='QEMU_AUDIO_TIMER_PERIOD' value='150'/>

Thanks for all the help everything is working! :grinning: :grinning: :grinning: :grinning: :grinning: