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>
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)
{
int ret = -1;
+ /* Check whether qemu quited unexpectedly */
+ if (mon->lastErrno) {
+ msg->lastErrno = mon->lastErrno;
+ return -1;
+ }
+
mon->msg = msg;
qemuMonitorUpdateWatch(mon);