mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-12-28 11:21:44 +03:00
qemu: agent: Avoid agentError when closing the QEMU agent
The commit 89563efc02
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: Wang Yechao <wang.yechao255@zte.com.cn>
Reviewed-by: John Ferlan <jferlan@redhat.com>
This commit is contained in:
parent
a5dc60012c
commit
bba16ff111
@ -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);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user