#649442 libvirt-bin: please document how to have sound with/without VNC

Package:
libvirt-bin
Source:
libvirt
Submitter:
Luca Capello
Date:
2023-04-17 15:57:08 UTC
Severity:
normal
Tags:
#649442#5
Date:
2011-11-20 23:01:36 UTC
From:
To:
Hi there!

I have an up-to-date sid guest and I wanted to add sound to use the
Empathy IM there [1][2] via `ssh -X` and I thought this would have been
rather simple, which is actually not ;-)

[1] I do not want to install 130 MB of new packages on my host to simply
    use an IM client.
[2] unfortunately there are other non-libvirt problems, see #619636, but
    this is another story.

First of all, I am aware that libvirt does not fully support sounds
through VNC [3][4], so I disabled the VNC output commenting out the
graphics XML tag and adding the sound XML tag.  Below the results.

[3] <https://bugzilla.redhat.com/show_bug.cgi?id=508317>
[4] <https://bugzilla.redhat.com/show_bug.cgi?id=595880>

1) default configuration
   => no sound, but with ac97 the domain is not started while with
      es1370 it does
=====
ALSA lib confmisc.c:768:(parse_card) cannot find card '0'
ALSA lib conf.c:4184:(_snd_config_evaluate) function snd_func_card_driver returned error: No such file or directory
ALSA lib confmisc.c:392:(snd_func_concat) error evaluating strings
ALSA lib conf.c:4184:(_snd_config_evaluate) function snd_func_concat returned error: No such file or directory
ALSA lib confmisc.c:1251:(snd_func_refer) error evaluating name
ALSA lib conf.c:4184:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory
ALSA lib conf.c:4663:(snd_config_expand) Evaluate error: No such file or directory
ALSA lib pcm.c:2212:(snd_pcm_open_noupdate) Unknown PCM default
alsa: Could not initialize ADC
alsa: Failed to open `default':
alsa: Reason: No such file or directory
[similar output repeated]
=====

2) /etc/libvirt/qemu.conf:user = "libvirt-qemu"
   => same as point 1 above

3) /etc/libvirt/qemu.conf:user = "luca"
   => sound with both ac97 and es1370

This means that I guess a user with login capabilities (is this the user
who accesses the VM?) must own the QEmu process to have sound.  If this
is the case, can it be documented in the README.Debian?

If I re-enable the VNC output, the only way to get sound (even through
SSH), is setting 'vnc_allow_host_audio = 1' in /etc/libvirt/qemu.conf,
together with 'user = "luca"' in the same file, otherwise you get the
same error as point 1 above.  It seems that 'export QEMU_AUDIO_DRV=alsa'
in /etc/default/libvirt-bin has no effect, is this the correct behavior?
I have found #533585, but I am not sure it is still relevant.

[5] <http://bugs.debian.org/533585>

Considering the two results above, here a simple patch:

#649442#10
Date:
2011-12-03 13:59:32 UTC
From:
To:
Hi Luca,
Thanks for taking the time to document this.

On Mon, Nov 21, 2011 at 12:01:36AM +0100, Luca Capello wrote:
[..snip..]
instead of qemu:///system. This way setting vnc_allow_host_audio should
do the trick. Did you try that?
Cheers,
 -- Guido

P.S.: There are patches on the gtk-vnc list to enable sound via VNC
using puluseaudio which will hopefully make this very easy in the near
future.
There's also spice which also supports audio but since it's not
available for all platforms having this working (and documented!) is
still a good thing.