From 30c551ab4e64f02f2cfb148fcac8658b018d31cb Mon Sep 17 00:00:00 2001 From: Hu Tao Date: Tue, 12 Apr 2011 18:29:27 +0800 Subject: [PATCH] qemu: fix a dead-lock problem In qemuDomainObjBeginJobWithDriver, when virCondWaitUntil timeouts, the function tries to call qemuDriverLock with virDomainObj locked, this causes the dead-lock problem. This patch fixes this. --- src/qemu/qemu_domain.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index c2a1f9a0ad..a947b4e08a 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -506,15 +506,17 @@ int qemuDomainObjBeginJobWithDriver(struct qemud_driver *driver, while (priv->jobActive) { if (virCondWaitUntil(&priv->jobCond, &obj->lock, then) < 0) { - /* Safe to ignore value since ref count was incremented above */ - ignore_value(virDomainObjUnref(obj)); if (errno == ETIMEDOUT) qemuReportError(VIR_ERR_OPERATION_TIMEOUT, "%s", _("cannot acquire state change lock")); else virReportSystemError(errno, "%s", _("cannot acquire job mutex")); + virDomainObjUnlock(obj); qemuDriverLock(driver); + virDomainObjLock(obj); + /* Safe to ignore value since ref count was incremented above */ + ignore_value(virDomainObjUnref(obj)); return -1; } } -- GitLab