提交 f2a4e5f1 编写于 作者: M Michal Privoznik

qemu_agent: Remove agent reference only when disposing it

https://bugzilla.redhat.com/show_bug.cgi?id=892079

With current code, if user calls virDomainPMSuspendForDuration()
followed by virDomainDestroy(), the former API checks for qemu agent
presence, which will evaluate as true (if agent is configured). While
talking to qemu agent, the qemu driver is unlocked, so the latter API
starts executing.  However, if machine dies meanwhile, libvirtd gets
EOF on the agent socket and qemuProcessHandleAgentEOF() is called. The
handler clears reference to qemu agent while the destroy API already
holding a reference to it. This leads to NULL dereferencing later in
the code. Therefore, the agent pointer should be set to NULL only if
we are the exclusive owner of it.
上级 daef7c9e
...@@ -133,7 +133,8 @@ qemuProcessHandleAgentEOF(qemuAgentPtr agent, ...@@ -133,7 +133,8 @@ qemuProcessHandleAgentEOF(qemuAgentPtr agent,
virDomainObjLock(vm); virDomainObjLock(vm);
priv = vm->privateData; priv = vm->privateData;
if (priv->agent == agent) if (priv->agent == agent &&
!virObjectUnref(priv->agent))
priv->agent = NULL; priv->agent = NULL;
virDomainObjUnlock(vm); virDomainObjUnlock(vm);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册