qemuProcessReconnectHelper has hold the doms lock, if create
qemuProcessReconnect thread failed, it will get the doms lock
again to remove the dom from doms list.
add obj->inReconnetCtx flag to avoid deadlock.
Signed-off-by: Wang Yechao <wang.yechao255(a)zte.com.cn>
---
src/conf/domain_conf.h | 1 +
src/conf/virdomainobjlist.c | 6 ++++--
src/qemu/qemu_process.c | 1 +
3 files changed, 6 insertions(+), 2 deletions(-)
diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h
index e30a4b2..5bc5771 100644
--- a/src/conf/domain_conf.h
+++ b/src/conf/domain_conf.h
@@ -2608,6 +2608,7 @@ struct _virDomainObj {
virDomainSnapshotObjPtr current_snapshot;
bool hasManagedSave;
+ bool inReconnectCtx;
void *privateData;
void (*privateDataFreeFunc)(void *);
diff --git a/src/conf/virdomainobjlist.c b/src/conf/virdomainobjlist.c
index 805fe94..30300b4 100644
--- a/src/conf/virdomainobjlist.c
+++ b/src/conf/virdomainobjlist.c
@@ -397,11 +397,13 @@ virDomainObjListRemove(virDomainObjListPtr doms,
dom->removing = true;
virObjectRef(dom);
virObjectUnlock(dom);
- virObjectRWLockWrite(doms);
+ if (!dom->inReconnectCtx)
+ virObjectRWLockWrite(doms);
virObjectLock(dom);
virDomainObjListRemoveLocked(doms, dom);
virObjectUnref(dom);
- virObjectRWUnlock(doms);
+ if (!dom->inReconnectCtx)
+ virObjectRWUnlock(doms);
}
diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c
index eb9904b..8c30850 100644
--- a/src/qemu/qemu_process.c
+++ b/src/qemu/qemu_process.c
@@ -8029,6 +8029,7 @@ qemuProcessReconnectHelper(virDomainObjPtr obj,
*/
qemuProcessStop(src->driver, obj, VIR_DOMAIN_SHUTOFF_FAILED,
QEMU_ASYNC_JOB_NONE, 0);
+ obj->inReconnectCtx = true;
qemuDomainRemoveInactiveJob(src->driver, obj);
virDomainObjEndAPI(&obj);
--
1.8.3.1