提交 bba16ff1 编写于 作者: W Wang Yechao 提交者: John Ferlan

qemu: agent: Avoid agentError when closing the QEMU agent

The commit 89563efc fix the
monitor error when closing the QEMU monitor. The QEMU agent
has a problem similar to QEMU monitor. So fix the QEMU agent
with the same method.
Signed-off-by: NWang Yechao <wang.yechao255@zte.com.cn>
Reviewed-by: NJohn Ferlan <jferlan@redhat.com>
上级 a5dc6001
......@@ -530,6 +530,9 @@ static void qemuAgentUpdateWatch(qemuAgentPtr mon)
VIR_EVENT_HANDLE_HANGUP |
VIR_EVENT_HANDLE_ERROR;
if (!mon->watch)
return;
if (mon->lastError.code == VIR_ERR_OK) {
events |= VIR_EVENT_HANDLE_READABLE;
......@@ -555,6 +558,12 @@ qemuAgentIO(int watch, int fd, int events, void *opaque)
VIR_DEBUG("Agent %p I/O on watch %d fd %d events %d", mon, watch, fd, events);
#endif
if (mon->fd == -1 || mon->watch == 0) {
virObjectUnlock(mon);
virObjectUnref(mon);
return;
}
if (mon->fd != fd || mon->watch != watch) {
if (events & (VIR_EVENT_HANDLE_HANGUP | VIR_EVENT_HANDLE_ERROR))
eof = true;
......@@ -788,8 +797,10 @@ void qemuAgentClose(qemuAgentPtr mon)
virObjectLock(mon);
if (mon->fd >= 0) {
if (mon->watch)
if (mon->watch) {
virEventRemoveHandle(mon->watch);
mon->watch = 0;
}
VIR_FORCE_CLOSE(mon->fd);
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册