On Thu, Sep 10, 2009 at 02:13:56PM +0900, Ryota Ozaki wrote:
Hi,
This patch closes logfile fd after spawing qemu in qemudStartVMDaemon.
The fd seems to be closed in the error path, but not in the normal path.
The fd is passed to virExecDaemonize though, but looks not being closed
inside it. Eventually, the fd is never closed during libvirtd lifetime.
Thanks,
ozaki-r
>From b3d3e0f24c5df5c7677e539bbc2598f2d7fbc3b8 Mon Sep 17 00:00:00 2001
From: Ryota Ozaki <ozaki.ryota(a)gmail.com>
Date: Thu, 10 Sep 2009 12:53:56 +0900
Subject: [PATCH] Close logfile fd after spawning qemu
---
src/qemu_driver.c | 1 +
1 files changed, 1 insertions(+), 0 deletions(-)
diff --git a/src/qemu_driver.c b/src/qemu_driver.c
index 8f16e72..f2182c4 100644
--- a/src/qemu_driver.c
+++ b/src/qemu_driver.c
@@ -2187,6 +2187,7 @@ static int qemudStartVMDaemon(virConnectPtr conn,
VIR_EXEC_NONBLOCK | VIR_EXEC_CLEAR_CAPS,
qemudSecurityHook, &hookData,
pidfile);
+ close(logfile);
VIR_FREE(pidfile);
/* wait for qemu process to to show up */
Hum, it's not quite simple. It's passed down to __virExec()
where it is provided as the stdout/stderr to use, it's not closed
there on the parent though. I guess it's safe to close it at that
point at the end of qemudStartVMDaemon() since only the child can
use it (up to the exec because it is been close on exec'ed).
So looks fine to me but I would appreciate a second opinion :-)
Daniel
--
Daniel Veillard | libxml Gnome XML XSLT toolkit
http://xmlsoft.org/
daniel(a)veillard.com | Rpmfind RPM search engine
http://rpmfind.net/
http://veillard.com/ | virtualization library
http://libvirt.org/