QEMU/VM audio design

So I have a Ryzen 2700x running Ubuntu 20.04 with a Windows 10 VM for those games that I can’t get to run in Linux or WINE. It’s using a PCIE passthrough setup with a Vega 64 and it works well except for one problem.

The audio doesn’t work.

I’ve been messing around with Pulse Audio and I’ve tried various incarnations of adding “-audiodev id=pa,driver=pa” to the QEMU 4.2 command line. In the best case, I get “pa_context_connect() failed: connection refused” and in the worst case, the sound device appears in Windows, but plays no sound.

Then I took a step back and thought about it. I do a little bit of music composition just as a hobby and I thought, “I have this nice audio chip on the Vega anyway, why not just use that?” The only thing is, I’d need to somehow “multiplex” that into my existing sound system.

One idea I thought of was to use an external device, but I don’t know what I should get. I’ve got parts for a spare PC lying around, so I could use that as a mixer, perhaps, by using Jack, but again, I’m not sure what parts I would need.

Or perhaps I could find some way of using Jack to use the passed-through card as an audio source? I’m not sure how I’d do it as passthrough is supposed to hide the card from the operating system.

So I guess my question is this. Given that I have a PC that’s running two operating systems, what’s the best way to get sound working? Is it to use the video card as a second audio source, or continue to try to fight to get PA working?

Would appreciate opinions on this…

For passing the Audio from the guest to the host I use the following:

<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>

It is important to note that I am using a Q35 Chipset for the VM. As far as I remember for the i440FX Chipset you need to modify it to:

    <qemu:arg value="ich9-intel-hda,bus=pci.0,addr=0x1b"/>

Adding that and doing a restart of the host made it work for me.

Edit: I think I needed to get the addr part from somewhere too, but I do not fuily remember this part. Maybe I have it somewhere in my logs.

I was able to follow this link and get it, well, sort of working. It turns out AppArmor was to blame, and the “connection refused” errors that I saw were due to that.

But the sound quality is just awful. There are skips, pops, cracks. I’m not sure what to do about it.

This topic was automatically closed 273 days after the last reply. New replies are no longer allowed.