Advertisement
andrejpodzimek

qemu + pulseaudio

Aug 26th, 2021
797
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.23 KB | None | 0 0
  1. Your pulseaudio method appears to be rather complex. I've found a oneliner modification to the XML generated by default by virt-manager (at least for my FreeBSD VM and ArchLinux host) that gets pulseaudio working.
  2.  
  3. So, my very first configuration used to be:
  4.  
  5. <qemu:commandline>
  6. <qemu:env name="QEMU_AUDIO_DRV" value="pa"/>
  7. <qemu:env name="QEMU_PA_SERVER" value="unix:/tmp/pulse-socket-for-freebsd-on-kvm"/>
  8. </qemu:commandline>
  9.  
  10. This^^^ was not necessarily for "4.1 and below"; it actually worked until 5.2.x and the legacy support for these environment variables got ultimately dropped in 6.0. Which brought me to your blogpost. ;-)
  11.  
  12. For the record, your solution worked fine for me. It gave me audio on FreeBSD in KDE:
  13.  
  14. <qemu:commandline>
  15. <qemu:arg value="-device"/>
  16. <qemu:arg value="ich9-intel-hda,bus=pcie.0,addr=0x1b"/>
  17. <qemu:arg value="-device"/>
  18. <qemu:arg value="hda-micro,audiodev=hda"/>
  19. <qemu:arg value="-audiodev"/>
  20. <qemu:arg value="pa,id=hda,server=unix:/tmp/pulse-socket-for-freebsd-on-kvm"/>
  21. </qemu:commandline>
  22.  
  23. However, this^^^ low-level configuration does *not* resemble the audio devices configured by default by virt-manager, which is quite confusing, because it doesn't appear in the left configuration bar in virt-manager etc.
  24.  
  25. So ultimately my solution was to create a "default" ICH9 audio card in virt-manager, which translates into something like this:
  26.  
  27. <devices>
  28. <sound model="ich9">
  29. <address type="pci" domain="0x0000" bus="0x00" slot="0x1b" function="0x0"/>
  30. </sound>
  31. <audio id="1" type="none"/>
  32. </devices>
  33.  
  34. Now this^^^ won't work by default, presumably, because sound goes to nowhere. But it suffices to replace the <audio> element with this:
  35.  
  36. <audio id="1" type="pulseaudio" serverName="unix:/tmp/pulse-socket-for-freebsd-on-kvm"/>
  37.  
  38. There. That makes audio work. One can (presumably) set the ID to something else (instead of the default), say 7, and then set <audio id="7"/> inside <sound>. But with just one sound card the default is the shortest option.
  39.  
  40. Here's the trick in /etc/pulse/default.pa:
  41.  
  42. load-module module-native-protocol-unix auth-group=kvm socket=/tmp/pulse-socket-for-freebsd-on-kvm
  43.  
  44. The last bit of the puzzle is that my qemu runs under the kvm group.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement