Skip Navigation

Enabling Sound in QEMU Virtual Machines

QEMU is capable of emulating a sound card for virtual machines. In order to hear sound produced by the virtual machine, it is necessary to map the sound card to a sound server or library on the host system.

Page Contents

The -audiodev

The first step in adding sound support to a virtual machine is to create a mapping from the virtual machine to the sound server or library on the host system. This mapping is created with the -audiodev argument to QEMU. The argument looks a little different, depending on your host system:

Linux Hosts

-audiodev pa,id=Sound

macOS Hosts

-audiodev coreaudio,id=Sound

Windows Hosts

-audiodev dsound,id=Sound

Adding a Sound Card

Once you have the mapping to the host in place, add a sound card, and attach it to your host audio device. The Intel HD Audio sound card should be supported by any reasonably modern guest system and is probably a safe choice:

-device intel-hda \
-device hda-output,audiodev=Sound

Note that the audiodev in the second -device line needs to match the id of the audio device defined with the -audiodev option above. I chose to use “Sound” for this identifier, but you can name it something else.

On macOS and Windows hosts, only sound playback is supported with the respective coreaudio and dsound interfaces. On Linux hosts, both sound playback and sound recording are supported; to use bidirectional audio, change the “hda-output” device to “hda-duplex” instead. Sound recording on Mac and Windows hosts is left as an exercise for the reader, but it might be possible using either the “sdl” audiodev or perhaps by installing the respective PulseAudio ports for those platforms.

Creative Commons License
This work is licensed under a Creative Commons Attribution-ShareAlike 4.0 International License.