In qemuMonitorOpenUnix, after connect(), virProcessKill will be
invoked when cpid is not empty. But if the qemu-kvm process exited
early, virProcessKill will flush errno as ESRCH, so the wrong
message will be recorded in log as:
error: qemuMonitorOpenUnix:309 : failed to connect to monitor socket: No such process
After patched:
error : qemuMonitorOpenUnix:312 : failed to connect to monitor socket: Connection refused
Signed-off-by: Jincheng Miao <jmiao(a)redhat.com>
---
src/qemu/qemu_monitor.c | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/src/qemu/qemu_monitor.c b/src/qemu/qemu_monitor.c
index db3dd73..c8284fe 100644
--- a/src/qemu/qemu_monitor.c
+++ b/src/qemu/qemu_monitor.c
@@ -293,19 +293,22 @@ qemuMonitorOpenUnix(const char *monitor, pid_t cpid)
}
do {
+ int orig_errno;
ret = connect(monfd, (struct sockaddr *) &addr, sizeof(addr));
if (ret == 0)
break;
- if ((errno == ENOENT || errno == ECONNREFUSED) &&
+ orig_errno = errno;
+
+ if ((orig_errno == ENOENT || orig_errno == ECONNREFUSED) &&
(!cpid || virProcessKill(cpid, 0) == 0)) {
/* ENOENT : Socket may not have shown up yet
* ECONNREFUSED : Leftover socket hasn't been removed yet */
continue;
}
- virReportSystemError(errno, "%s",
+ virReportSystemError(orig_errno, "%s",
_("failed to connect to monitor socket"));
goto error;
--
1.8.3.1