aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel P. Berrange <berrange@redhat.com>2012-09-26 16:23:24 +0100
committerDoug Goldstein <cardoe@cardoe.com>2012-10-05 13:26:16 -0500
commitc18d5d57fc782121020e11af6a48d1d669aaa4d2 (patch)
tree8a91058e4f6575c32850e77d9bbf5051047e5d32
parentFix (rare) deadlock in QEMU monitor callbacks (diff)
downloadlibvirt-c18d5d57fc782121020e11af6a48d1d669aaa4d2.tar.gz
libvirt-c18d5d57fc782121020e11af6a48d1d669aaa4d2.tar.bz2
libvirt-c18d5d57fc782121020e11af6a48d1d669aaa4d2.zip
Fix potential deadlock when agent is closed
If the qemuAgentClose method is called from a place which holds the domain lock, it is theoretically possible to get a deadlock in the agent destroy callback. This has not been observed, but the equivalent code in the QEMU monitor destroy callback has seen a deadlock. Remove the redundant locking while unrefing the object and the bogus assignment Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
-rw-r--r--src/qemu/qemu_process.c12
1 files changed, 3 insertions, 9 deletions
diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c
index f67495f34..f30493877 100644
--- a/src/qemu/qemu_process.c
+++ b/src/qemu/qemu_process.c
@@ -128,7 +128,8 @@ qemuProcessHandleAgentEOF(qemuAgentPtr agent,
virDomainObjLock(vm);
priv = vm->privateData;
- priv->agent = NULL;
+ if (priv->agent == agent)
+ priv->agent = NULL;
virDomainObjUnlock(vm);
qemuDriverUnlock(driver);
@@ -166,16 +167,9 @@ qemuProcessHandleAgentError(qemuAgentPtr agent ATTRIBUTE_UNUSED,
static void qemuProcessHandleAgentDestroy(qemuAgentPtr agent,
virDomainObjPtr vm)
{
- qemuDomainObjPrivatePtr priv;
-
VIR_DEBUG("Received destroy agent=%p vm=%p", agent, vm);
- virDomainObjLock(vm);
- priv = vm->privateData;
- if (priv->agent == agent)
- priv->agent = NULL;
- if (virObjectUnref(vm))
- virDomainObjUnlock(vm);
+ virObjectUnref(vm);
}