libvirt sometimes hangs when using pulseaudio

Bug #453453 reported by Jamie Strandboge on 2009-10-16
14
This bug affects 2 people
Affects Status Importance Assigned to Milestone
apparmor (Ubuntu)
Undecided
Unassigned
Karmic
Undecided
Unassigned
Lucid
Undecided
Unassigned
libvirt (Ubuntu)
Medium
Unassigned
Karmic
Medium
Unassigned
Lucid
Medium
Unassigned
pulseaudio (Ubuntu)
Undecided
Unassigned
Karmic
High
Unassigned
Lucid
Undecided
Unassigned
qemu-kvm (Ubuntu)
High
Unassigned
Karmic
High
Unassigned
Lucid
High
Unassigned
virt-manager (Ubuntu)
High
Unassigned
Karmic
High
Unassigned
Lucid
High
Unassigned

Bug Description

Occasionally, a virtual machine will hang during boot when started from virt-manager. This seems to be racy or related to some interaction with pulseaudio. I saw this when using an 8.10 and 9.10 desktop livecd. During the boot process, the VM would hang and all of libvirt would be unresponsive (ie 'virsh list' would also hang). This happens here maybe 1 out of 10 times.

Until bug #453329 is fixed, you will have to disable apparmor for libvirt with:
$ sudo apparmor_parser -R /etc/apparmor.d/usr.sbin.libvirtd
$ sudo /etc/init.d/libvirt-bin restart

This is because that bug masks the problem by denying access to pulseaudio, and therefore audio is not available in the guest and the boot proceeds like normal. I will try to obtain an 'strace -p' of the kvm process when I see another hang. I have witnessed 4 hangs in maybe 20 boots (3 in a row, a couple successful boots and 1 outlier).

ProblemType: Bug
Architecture: amd64
Date: Fri Oct 16 15:07:59 2009
DistroRelease: Ubuntu 9.10
LiveMediaBuild: Ubuntu 9.04 "Jaunty Jackalope" - Release amd64 (20090420.1)
Package: libvirt-bin 0.7.0-1ubuntu11
ProcEnviron:
 PATH=(custom, user)
 LANG=en_US.UTF-8
 SHELL=/bin/bash
ProcVersionSignature: Ubuntu 2.6.31-14.47-generic
SourcePackage: libvirt
Uname: Linux 2.6.31-14-generic x86_64

Jamie Strandboge (jdstrand) wrote :
Jamie Strandboge (jdstrand) wrote :

This has nothing to do with the apparmor plugin. If you disable apparmor it will still hang.

Changed in apparmor (Ubuntu):
status: New → Invalid
Chuck Short (zulcss) wrote :

<jdstrand> zul: 453453 is not fixed. apparmor didn't cause the problem. fixing #453329 only makes #453453 noticeable. I talked to kirkland about it at length on friday. he said he was able to reproduce it, though I don't recall how
<zul> k
 so im gonig to set it to confirmed
<jdstrand> zul: that sounds fine. I invalidated the apparmor task
<zul> thanks for the heads up

Changed in libvirt (Ubuntu):
importance: Undecided → Medium
status: New → Confirmed
tags: added: regression-potential
Matt Zimmerman (mdz) on 2009-10-20
Changed in libvirt (Ubuntu Karmic):
status: Confirmed → Triaged
Dustin Kirkland  (kirkland) wrote :

Marking won't fix for karmic.

If someone has or finds a good patch, this could be a candidate for an SRU.

:-Dustin

Changed in libvirt (Ubuntu Karmic):
status: Triaged → Won't Fix
milestone: none → karmic-updates
Daniel Nelson (packetcollision) wrote :

This affects me on 2 computers, 100% of the time, and finding information about the problem was quite hard. If this isn't going to be fixed, perhaps a warning that having a soundcard in the VM may cause libvirt to hang would be a good idea.

Interestingly, the exact same VM booted directly with the exact same kvm line as the one libvirt uses (as pulled from ps -ef |grep kvm) works fine.

I haven't yet been able to test this extensively, but it appears that removing the sound card from the VM is indeed a workaround.

Jamie Strandboge (jdstrand) wrote :

One idea might be to not add the soundcard when people create VMs using virt-manager. This of cource doesn't address existing VMs....

Dustin Kirkland  (kirkland) wrote :

I'm moving this to priority Critical. This is happening to me every time. It makes virt-manager basically unusable.

:-Dustin

Changed in libvirt (Ubuntu):
importance: Medium → Critical
Changed in virt-manager (Ubuntu Karmic):
status: New → Triaged
importance: Undecided → Critical
Changed in qemu-kvm (Ubuntu Karmic):
status: New → Confirmed
Changed in libvirt (Ubuntu):
status: Triaged → Confirmed
Changed in qemu-kvm (Ubuntu Karmic):
importance: Undecided → Critical
Changed in virt-manager (Ubuntu Karmic):
status: Triaged → Confirmed
Dustin Kirkland  (kirkland) wrote :

So I've added a bunch of packages to this bug, as I'm not entirely sure where it's at.

Most likely, most of these will be marked Invalid eventually.

But at this point, the bug is somewhere among:
 * virt-manager
 * libvirt
 * qemu-kvm
 * pulseaudio.

I have noticed that if I stop the pulseaudio process on my host, I do not see the problem.

Also, if I run qemu-kvm directly with `export QEMU_AUDIO_DRV=alsa`, I do not see the problem.

:-Dustin

Daniel T Chen (crimsun) wrote :

If using the alsa backend for qemu makes the symptom go away, it's fairly unlikely that PulseAudio is the culprit, since using the alsa backend still routes through PA on the host due to the pulse alsa-plugin being used.

It might make sense to ship Karmic with that env var (QEMU_AUDIO_DRV=alsa)...

Changed in libvirt (Ubuntu):
importance: Critical → Medium
Changed in qemu-kvm (Ubuntu Karmic):
importance: Critical → High
Changed in virt-manager (Ubuntu Karmic):
importance: Critical → High

I'd be happy to test the env var solution. What file should I add it to?

Soren Hansen (soren) wrote :

I haven't been able to reproduce it, unfortunately. I understand the problem, though.

Simply put, the problem is mostly that since the VMs run as root rather than your user, it's not completely straight forward how to deal with access to the sound device.

The real fix would be to tunnel sound through VNC. However, gtk-vnc and virt-manager do not support this yet (kvm does).

We could hack libvirt to ignore audio devices for VM's on qemu:///system. That would certainly fix this bug, but would remove sound support for people for whom it actually works.

Making virtinst not add sound devices will not fix existing VM's.

Suggestions?

The only way that I can think of solving this for now, is to run PulseAudio at the system level, which however brings its own caviots and issues. Alternatively, we could investivate ulseAudio's TCP communication module, and set kvm up to communicate with pulse via tcp/UDP. I know very little about tat module, but I believe this is what it is for.

Soren Hansen (soren) wrote :

Perhaps I should clarify that I'm looking for an SRUable solution. For
Lucid I'm somewhat hopeful we'll tunnel sound over VNC and have a means
for hooking that up through gtk-vnc(/virt-manager).

Brian Rogers (brian-rogers) wrote :

If virt-manager had to push out audio through pulseaudio, it'd have to handle having no pulseaudio running when it starts, and it'd have to transfer audio output to the correct pulseaudio on demand and correctly handle the daemon being terminated.

What about doing it the other way, pull instead of push? It might be possible for virt-manager to publish an audio stream locally that pulseaudio can then tune into.

tags: added: regression-release
removed: regression-potential
Changed in pulseaudio (Ubuntu Karmic):
importance: Undecided → High
status: New → Triaged
Dustin Kirkland  (kirkland) wrote :

Marking this won't fix for Karmic, adding Lucid task.

Can anyone reproduce this behavior in Lucid?

Changed in qemu-kvm (Ubuntu Karmic):
status: Confirmed → Won't Fix
Changed in virt-manager (Ubuntu Karmic):
status: Confirmed → Won't Fix
Changed in libvirt (Ubuntu Karmic):
milestone: karmic-updates → none
Dustin Kirkland  (kirkland) wrote :

Marking invalid against qemu-kvm. I really don't think the bug is in qemu-kvm. Rather, it must be somewhere among libvirt and pulseaudio.

I have verified that sound works very well in kvm in Lucid and pulseaudio (without libvirt).

I have also noticed that virt-manager in Lucid does not add a sound device by default when creating a virtual machine (you can add one after the fact). I have not gotten guest sound to work correctly under Lucid's virt-manager, though.

Changed in qemu-kvm (Ubuntu Lucid):
status: Confirmed → Invalid
Daniel T Chen (crimsun) wrote :

Need a verbose log (https://wiki.ubuntu.com/PulseAudio/Log) for the PA task when this occurs

Changed in pulseaudio (Ubuntu Lucid):
status: New → Incomplete
Jamie Strandboge (jdstrand) wrote :

I haven't seen this for months on Lucid. I am going to mark the Lucid tasks as Fix Released and reopen them if I happen to see it.

Changed in libvirt (Ubuntu Lucid):
status: Confirmed → Fix Released
Changed in pulseaudio (Ubuntu Lucid):
status: Incomplete → Fix Released
Changed in virt-manager (Ubuntu Lucid):
status: Confirmed → Fix Released
Dustin Kirkland  (kirkland) wrote :

Agreed, Jamie. Sound has been working marvelously for me in Lucid!

Rolf Leggewie (r0lf) on 2011-10-19
Changed in pulseaudio (Ubuntu Karmic):
status: Triaged → Won't Fix
To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers

Remote bug watches

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