Sound in lxd vm?

when i google about this, there are some hits, most old, one here with no response.
but no official docs, and it feels like it might be directly supported somehow as opposed to custom qemu command line options as per top search result from 2022
that post also mentions “At the LXD level, we’re waiting for virtio-sound to be more widely available and supported before introducing a sound card device to our VMs”. virtio_snd is definitely available now in the default kernel, so is there official support?
is the solution in that post i linked to still the way to go ?

i’ve got raw.qemu as -device intel-hda -device hda-duplex -audio spice and then using lxc console... and that’s not working at all

Hi Eric,

Sound inside the VMs isn’t something we’ve been focussing on.

What would be the use-case here? Are you looking to get sound from a desktop VM outputted over the lxc console connection to the client machine?

The LXD snap includes a custom qemu build with non-virtio devices disabled so that is likely why the intel-hda device isn’t working.

yes that’s exactly the use case!
and oh ok that explains why the usual pointers online don’t work
i’ll try with the virtio audio drivers, though i’m in trial and error rn; but i do understand it’s not a focus
thanks for replying. tom!

1 Like

for anyone else with the same problem, i ended up doing

lxc config set m24c raw.qemu='-device virtio-sound-pci,audiodev=m24c_audiodev -audiodev spice,id=m24c_audiodev'

(m24c is just my vm name)
that’s on a ubuntu 25.05 host, which has the required kernel modules, and has qemu 8.2 which supports this. my understanding is that it won’t work with older releases. vm is 24.04.

this still didn’t work with the spicy viewer, but it does work when i rdp into the vm with remina, so i’m fine (and rdp performance is pretty much on part with spicy)

1 Like

Thanks @esj0 !

Was this a Windows VM btw?

no, ubuntu - a vm for work things, running on my ubuntu desktop
presumably, this trick would also work for a windows vm, assuming drivers exist for the virtio-sound device under windows

1 Like

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