diff --git a/0dda594d-libvirtd-shutdown-deadlock.patch b/0dda594d-libvirtd-shutdown-deadlock.patch new file mode 100644 index 0000000..b703457 --- /dev/null +++ b/0dda594d-libvirtd-shutdown-deadlock.patch @@ -0,0 +1,45 @@ +commit 0dda594da99aede7621018a3705e7cf4c13b1606 +Author: Jim Fehlig +Date: Thu Jun 21 09:21:44 2012 -0600 + + Fix deadlock on libvirtd shutdown + + When shutting down libvirtd, the virNetServer shutdown can deadlock + if there are in-flight jobs being handled by virNetServerHandleJob(). + virNetServerFree() will acquire the virNetServer lock and call + virThreadPoolFree() to terminate the workers, waiting for the workers + to finish. But in-flight workers will attempt to acquire the + virNetServer lock, resulting in deadlock. + + Fix the deadlock by unlocking the virNetServer lock before calling + virThreadPoolFree(). This is safe since the virNetServerPtr object + is ref-counted and only decrementing the ref count needs to be + protected. Additionally, there is no need to re-acquire the lock + after virThreadPoolFree() completes as all the workers have + terminated. + +Index: libvirt-0.9.11.4/src/rpc/virnetserver.c +=================================================================== +--- libvirt-0.9.11.4.orig/src/rpc/virnetserver.c ++++ libvirt-0.9.11.4/src/rpc/virnetserver.c +@@ -801,10 +801,9 @@ void virNetServerFree(virNetServerPtr sr + virNetServerLock(srv); + VIR_DEBUG("srv=%p refs=%d", srv, srv->refs); + srv->refs--; +- if (srv->refs > 0) { +- virNetServerUnlock(srv); ++ virNetServerUnlock(srv); ++ if (srv->refs > 0) + return; +- } + + for (i = 0 ; i < srv->nservices ; i++) + virNetServerServiceToggle(srv->services[i], false); +@@ -845,7 +844,6 @@ void virNetServerFree(virNetServerPtr sr + dbus_connection_unref(srv->sysbus); + #endif + +- virNetServerUnlock(srv); + virMutexDestroy(&srv->lock); + VIR_FREE(srv); + } diff --git a/libvirt.changes b/libvirt.changes index 3e474af..8e7ad9e 100644 --- a/libvirt.changes +++ b/libvirt.changes @@ -1,3 +1,10 @@ +------------------------------------------------------------------- +Thu Jun 21 11:56:35 MDT 2012 - jfehlig@suse.com + +- Fix libvirtd deadlock on shutdown + 0dda594d-libvirtd-shutdown-deadlock.patch + bnc#767797 + ------------------------------------------------------------------- Wed Jun 20 23:40:14 MDT 2012 - jfehlig@suse.com diff --git a/libvirt.spec b/libvirt.spec index 017a1ac..39a0823 100644 --- a/libvirt.spec +++ b/libvirt.spec @@ -413,6 +413,7 @@ Source99: baselibs.conf # Revert v0.9.11-maint branch commit d8978c90 Patch0: revert-d8978c90.patch Patch1: 57349ffc-lxc-ctrl.patch +Patch2: 0dda594d-libvirtd-shutdown-deadlock.patch # Need to go upstream Patch100: xen-name-for-devid.patch Patch101: clone.patch @@ -550,6 +551,7 @@ Authors: %setup -q %patch0 -p1 %patch1 -p1 +%patch2 -p1 %patch100 -p1 %patch101 %patch102 -p1