
On 07/15/2014 02:32 AM, Jincheng Miao wrote:
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@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)) {
virProcessKill can be called on cleanup paths. I think it might be wiser to rewrite virProcessKill() to guarantee that it does not modify errno than it is to make all callers have to store a temporary. -- Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org