mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-11 15:27:47 +00:00
do not send monitor command after monitor meet error
If the monitor met a error, and we will call qemuProcessHandleMonitorEOF(). But we may try to send monitor command after qemuProcessHandleMonitorEOF() returned. Then libvirtd will be blocked in qemuMonitorSend(). Steps to reproduce this bug: 1. use gdb to attach libvirtd, and set a breakpoint in the function qemuConnectMonitor() 2. start a vm 3. let the libvirtd to run until qemuMonitorOpen() returns. 4. kill the qemu process 5. continue running libvirtd Signed-off-by: Wen Congyang <wency@cn.fujitsu.com>
This commit is contained in:
parent
025e199810
commit
cc2424fc65
@ -587,6 +587,15 @@ qemuMonitorIO(int watch, int fd, int events, void *opaque) {
|
||||
void (*eofNotify)(qemuMonitorPtr, virDomainObjPtr, int)
|
||||
= mon->cb->eofNotify;
|
||||
virDomainObjPtr vm = mon->vm;
|
||||
|
||||
/* If qemu quited unexpectedly, and we may try to send monitor
|
||||
* command later. But we have no chance to wake up it. So set
|
||||
* mon->lastErrno to EIO, and check it before sending monitor
|
||||
* command.
|
||||
*/
|
||||
if (!mon->lastErrno)
|
||||
mon->lastErrno = EIO;
|
||||
|
||||
/* Make sure anyone waiting wakes up now */
|
||||
virCondSignal(&mon->notify);
|
||||
if (qemuMonitorUnref(mon) > 0)
|
||||
@ -725,6 +734,12 @@ int qemuMonitorSend(qemuMonitorPtr mon,
|
||||
{
|
||||
int ret = -1;
|
||||
|
||||
/* Check whether qemu quited unexpectedly */
|
||||
if (mon->lastErrno) {
|
||||
msg->lastErrno = mon->lastErrno;
|
||||
return -1;
|
||||
}
|
||||
|
||||
mon->msg = msg;
|
||||
qemuMonitorUpdateWatch(mon);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user