No sound in virt-manager (QEMU_AUDIO_DRV set to none by libvirtd)

Bug #591489 reported by Victor J. Orlikowski
142
This bug affects 26 people
Affects Status Importance Assigned to Milestone
libvirt (Ubuntu)
Confirmed
Wishlist
Unassigned

Bug Description

When using virt-manager and libvirtd to manage VMs, VMs that use VNC for graphical consoles
have the QEMU_AUDIO_DRV environment variable automatically set to "none" in Lucid.

This prevents audio from working, at all, if one is using virt-manager for controlling VMs.

Tags: iso-testing
Revision history for this message
Mathias Gug (mathiaz) wrote :

Could you paste the libvirt configuration of guest that doesn't have the audio working?

Changed in libvirt (Ubuntu):
importance: Undecided → Low
status: New → Incomplete
Revision history for this message
Victor J. Orlikowski (vjo) wrote :

Certainly, but the complaint about sound not working for guests applies to *all*
guests on the machine that have a VNC console. I have pasted a guest configuration
that is a representative example.

The guest configuration file is named:
/etc/libvirt/qemu/windows7.xml

Its contents are:

<domain type='kvm'>
  <name>windows7</name>
  <uuid>a522d67b-7a31-0163-04d5-e97816dd7000</uuid>
  <memory>524288</memory>
  <currentMemory>524288</currentMemory>
  <vcpu>1</vcpu>
  <os>
    <type arch='x86_64' machine='pc-0.11'>hvm</type>
    <boot dev='hd'/>
  </os>
  <features>
    <acpi/>
    <apic/>
    <pae/>
  </features>
  <clock offset='localtime'/>
  <on_poweroff>destroy</on_poweroff>
  <on_reboot>restart</on_reboot>
  <on_crash>destroy</on_crash>
  <devices>
    <emulator>/usr/bin/kvm</emulator>
    <disk type='file' device='disk'>
      <source file='/opt/vm_images/windows7.img'/>
      <target dev='hda' bus='ide'/>
    </disk>
    <disk type='file' device='cdrom'>
      <target dev='hdc' bus='ide'/>
      <readonly/>
    </disk>
    <interface type='network'>
      <mac address='54:52:00:3f:91:e8'/>
      <source network='default'/>
      <model type='e1000'/>
    </interface>
    <serial type='pty'>
      <target port='0'/>
    </serial>
    <console type='pty'>
      <target port='0'/>
    </console>
    <input type='tablet' bus='usb'/>
    <input type='mouse' bus='ps2'/>
    <graphics type='vnc' port='-1' autoport='yes' listen='127.0.0.1' keymap='en-us'/>
    <sound model='ac97'/>
    <video>
      <model type='vga' vram='9216' heads='1'/>
    </video>
  </devices>
</domain>

When I check the log (/var/log/libvirt/qemu/windows7.log) corresponding to this virtual machine, I see:
LC_ALL=C PATH=/usr/local/sbin:/usr/local/bin:/usr/bin:/usr/sbin:/sbin:/bin QEMU_
AUDIO_DRV=none /usr/bin/kvm -S -M pc-0.11 -enable-kvm -m 512 -smp 1 -name window
s7 -uuid a522d67b-7a31-0163-04d5-e97816dd7000 -chardev socket,id=monitor,path=/v
ar/lib/libvirt/qemu/windows7.monitor,server,nowait -monitor chardev:monitor -loc
altime -boot c -drive file=/opt/vm_images/windows7.img,if=ide,index=0,boot=on -d
rive if=ide,media=cdrom,index=2 -net nic,macaddr=54:52:00:3f:91:e8,vlan=0,model=
e1000,name=e1000.0 -net tap,fd=37,vlan=0,name=tap.0 -chardev pty,id=serial0 -ser
ial chardev:serial0 -parallel none -usb -usbdevice tablet -vnc 127.0.0.1:1 -k en
-us -vga std -soundhw ac97
char device redirected to /dev/pts/0

What concerns me, is that QEMU_AUDIO_DRV is set to "none", with no action on my part.

Revision history for this message
Victor J. Orlikowski (vjo) wrote :

One additional comment -
The VM is running 32-bit Windows 7, which does have a driver for the ac97 virtual sound card.
This same VM *did* produce sound on Karmic and on Jaunty.

Revision history for this message
El Diablo (el-diablo) wrote :

I also am encountering this bug, with all guests. I have looked for many hours for a resolution but nothing so far. However I can also say ALL guests:

Windows 7 (32bit)
Windows XP (32bit)
OpenSUSE 11.2 (32bit)

In the log files also show the AUDIO_DRV=none

One additional thing I tried was to add the following like to /etc/default/libvirt-bin

export QEMU_AUDIO_DRV=pa

But this still did not resolve the issue, still the log files show none.

Revision history for this message
El Diablo (el-diablo) wrote :

OK, I have sound working. I manually launched the Windows 7 guest via command line, but changing the none to pa and I had audio. So now I will investigate as to how to ensure than libvirt respects the env. var.

Changed in libvirt (Ubuntu):
status: Incomplete → Confirmed
Revision history for this message
Tristan Schmelcher (tschmelcher) wrote :

Changing to confirmed since the reporter has provided the requested information.

I too am experiencing this bug. Looking at the libvirt source code, it specifies QEMU_AUDIO_DRV=none whenever using VNC for graphics. The comments say this is because it tunnels audio over the VNC connection.

        /* QEMU implements a VNC extension for providing audio, so we
         * set the audio backend to none, to prevent it opening the
         * host OS audio devices since that causes security issues
         * and is non-sensical when using VNC.
         */
        ADD_ENV_LIT("QEMU_AUDIO_DRV=none");

However, the VNC viewer that virt-manager uses apparently doesn't support the audio extension. That's why sound is broken. (http://osdir.com/ml/fedora-virt/2010-01/msg00006.html)

Revision history for this message
Tristan Schmelcher (tschmelcher) wrote :
Revision history for this message
Sachin Garg (sgarg-bugreporter) wrote :

Since the VNC viewer does not support the audio extension, shouldn't we have an "easy" option to turn ON the QEMU_AUDIO_DRV to something - overriding the hardcoded behaviour to allow users to get sound till VNC viewer is fixed.

Revision history for this message
Tristan Schmelcher (tschmelcher) wrote :

I don't think that would improve things as much as one would expect. I think most people use virt-manager with VMs in the root QEMU instance rather than the per-user "QEMU Usermode" one (because it doesn't work well, as per bug 521428), so the VM process wouldn't be able to output any sound because it runs as root and won't have access to the user's PulseAudio process. So for sound to work, the user needs to either use ALSA or use the "QEMU Usermode" domain. Neither option is very attractive (though if virt-manager worked better with QEMU Usermode then that would be a viable option).

Revision history for this message
Ian Ward (ian-excess) wrote :

Here's my dirty hack that enables local sound:

    cd /usr/bin
    mv kvm kvm.bin
    cat >kvm <<END
    #!/bin/sh
    QEMU_AUDIO_DRV=alsa /usr/bin/kvm.bin $@
    END
    chmod +x kvm

I also tried QEMU_AUDIO=pa, but that didn't give any mic input for some reason.

Revision history for this message
nutznboltz (nutznboltz-deactivatedaccount) wrote :

Instead of
QEMU_AUDIO_DRV=alsa /usr/bin/kvm.bin $@

use
QEMU_AUDIO_DRV=alsa exec /usr/bin/kvm.bin $@

also in /etc/libvirt/qemu.conf

# QEMU implements an extension for providing audio over a VNC connection,
# though if your VNC client does not support it, your only chance for getting
# sound output is through regular audio backends. By default, libvirt will
# disable all QEMU sound backends if using VNC, since they can cause
# permissions issues. Enabling this option will make libvirtd honor the
# QEMU_AUDIO_DRV environment variable when using VNC.
#
# vnc_allow_host_audio = 0

So add

vnc_allow_host_audio = 1

but that will only suppress libvirt from adding "QEMU_AUDIO_DRV=none"

Revision history for this message
nutznboltz (nutznboltz-deactivatedaccount) wrote :
Revision history for this message
Samir Ibradžić (sibradzic) wrote :

Seems like apparmor can be fixed without disabling it, at least in 12.10;

Add these lines to /etc/apparmor.d/abstractions/libvirt-qemu:

  ####
    /{dev,run}/shm/pulse-shm* r,
    /{dev,run}/shm/pulse-shm* rwk,
    /usr/bin/pulseaudio Ux,
    @{HOME}/.pulse/ rwk,
  ####

  /etc/init.d/apparmor restart

Now, one need to fix /etc/libvirt/qemu.conf:

  vnc_allow_host_audio = 1
  user = "yourusernamehere"
  group = "yourusernamehere"

  /etc/init.d/apparmor restart

komputes (komputes)
summary: - QEMU_AUDIO_DRV set to none by libvirtd in Lucid
+ QEMU_AUDIO_DRV set to none by libvirtd
Changed in libvirt (Ubuntu):
importance: Low → Medium
komputes (komputes)
summary: - QEMU_AUDIO_DRV set to none by libvirtd
+ No sound in virt-manager (QEMU_AUDIO_DRV set to none by libvirtd)
Revision history for this message
Ubuntu QA Website (ubuntuqa) wrote :

This bug has been reported on the Ubuntu ISO testing tracker.

A list of all reports related to this bug can be found here:
http://iso.qa.ubuntu.com/qatracker/reports/bugs/591489

tags: added: iso-testing
Revision history for this message
Serge Hallyn (serge-hallyn) wrote :

This is not a bug, but rather is by design. I would mark it invalid, but the information on how to enable it if you want it is valuable.

I will mark it a duplicate of (the much newer) bug 1246929 instead. Then only to decide what to do with that one.

Changed in libvirt (Ubuntu):
importance: Medium → Wishlist
Revision history for this message
cooloutac (cooloutac) wrote :

Ty Samir Ibradžić (sibradzic) , that did it!

Revision history for this message
Shannon Barber (sgbarber) wrote :

Stop using pulse-audio and these problems go away.
Please just use ALSA.

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.