macOS-Simple-KVM icon indicating copy to clipboard operation
macOS-Simple-KVM copied to clipboard

Sound stops working after GPU passthrough

Open sparksh opened this issue 2 years ago • 3 comments

Is there a way to to make the built-in kvm sound (ich9 or ich6) work after passing through a GPU?

When I create a new High Sierra vm using virt-manager GUI, everything works including sound.

When I add my PCI GPU pass-through items, I have to remove "Display Spice" and "Video QXL".

Now when I boot OSX, sound does not work. The Preferences panel lets me select "Audio line-out port", so it sees that something is there.

This may be related to the problem and solution posted by Elias Sailenei at the end of the thread Sound only works with basic.sh, not virt-manager #57

He succeeded by starting over and performing a ritual I found difficult to follow. Evidently he managed to change "the order of something." Perhaps someone here can explain why that might work. I would think that using "virsh edit" on the vm could do whatever is required to change the order of events.

Maybe I'm the only one who has this problem: Do others succeed with kvm built-in sound after adding GPU pass-through? Is this just a virt-manager problem?

Thanks!

sparksh avatar Nov 10 '21 19:11 sparksh

u have to setup pulse/pipewire audio passthru

mei10101 avatar Nov 11 '21 00:11 mei10101

Thanks for the quick reply. Please help me understand (I know about pipewire, but I'm trying to figure out something else.)

My host sound system is PulseAudio. When I installed the basic "macOS-Simple-KVM" system, sound was working with the virt-manager built-in "sound" device configured as ich9. Wasn't that thing simply connecting my host PulseAudio to the guest hardware model? (That's not a rhetorical question. I really don't know how it works.)

After I had sound working, I added two host PCI devices: my real GPU and it's HDMI audio device. Back in MacOS, the new GPU is working. The sound preferences panel now shows the original "Audio line-out port" and four HDMI audio channels. (My video card has four HDMI ports.) The HDMI audio ports work: If I hook up a sound bar and select one of them, I hear sound. But the "Audio line-out port" that was working no longer works. With this VM, it's not convenient for me to use a gigantic HDMI sound bar from my home theater system. I want to use a simple pair of analog speakers connected to the hackintosh with a regular 3mm audio cable.

I also tried removing the PCI device for the GPU audio. That made the HDMI ports disappear from the OSX Sound preference panel. The "Audio line-out port" was still there. And it still didn't work.

So let me rephrase my original question as clearly as I can:

Why does simply adding a PCI GPU pass-though device break a previously-working built-in kvm sound device?

It would also be useful for me to know if anyone here has been successful with built-in virt-manager sound while using PCI GPU pass-through. There might be some well known reason why it can't work. I'd like to know when to quit trying.

Thanks for any insights.

sparksh avatar Nov 11 '21 03:11 sparksh

I have an answer (I think) It was implicit in what Elia Sailenei discovered.

When spice is configured and you have a sound element, audio is not routed directly to the host, but rather through the spice server in some convoluted way that eventually comes out on the host. When spice is removed, that path is removed and you must configure the audio device by hand as rei-hino-gaming observed. It is not the case that having a sound element in the domain sends audio to the host by default.

Doing this is well documented everywhere. Summary (for pulse audio):

Add these elements inside the domain:

<qemu:commandline>
	...
	<qemu:arg value='-audiodev'/>
	<qemu:arg value='pa,id=pa1,server=/run/user/1000/pulse/native'/>
</qemu:commandline>

(Where 1000 should be replaced by your user number.)

Edit /etc/libvirt/qemu.conf to set the user variable to your account name.

user = "smith"

sparksh avatar Nov 12 '21 23:11 sparksh