QEMU MacOS host Linux quest audio

I installed qemu via brew. Successfully installed ubuntu 18.04 desktop as a qemu guest.

Following is the start up command:

qemu-system-x86_64 \                                                                                  
-show-cursor \
-M q35,accel=hvf,usb=off,vmport=off \
-cpu host -smp 4 -m 2048 \
-overcommit mem-lock=off \
-overcommit cpu-pm=off \
-rtc base=utc,clock=host \
-audiodev id=coreaudio,driver=coreaudio \
\
-device virtio-blk-pci,bus=pcie.0,addr=0x2,drive=ssd1 \
-device virtio-net-pci,bus=pcie.0,addr=0x3,netdev=nic1,mac=52:54:98:76:54:33 \
-device virtio-tablet-pci,bus=pcie.0,addr=0x4 \
-device virtio-vga \
\
-drive id=ssd1,file=/Users/js/code/VM/qemu/u64d01.qcow2,if=none,format=qcow2 \
-netdev user,id=nic1,ipv4=on,ipv6=on,hostname=u64d01,hostfwd=tcp::2222-:22

Ubuntu desktop startup correctly and is responsive. However I am not able to get audio working. It just show "Dummy Output" in Settings->Sound.

Anyone have any clue?


QEMU devices are typically split into two parts, host backend and guest hardware device. The backend specifies how data from the guest hardware is processed on the host, e.g. audio can be recorded to a file or rerouted straight to the host output. Guest hardware device is a virtual hardware device presented in the guest. The model was introduced to QEMU audio since 4.2.

In the command line you specified Core Audio as host backend, but no hardware device was added, that's why you don't see it in the guest. You need to add a PCI sound card, e.g. Intel HDA and bind its output to the coreaudio backend:

-device intel-hda -device hda-output,audiodev=coreaudio

Full list of sound hardware is available in -device help.