From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:32935) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aTqP6-0004Qy-M8 for qemu-devel@nongnu.org; Thu, 11 Feb 2016 07:31:30 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aTqP4-0000qw-0y for qemu-devel@nongnu.org; Thu, 11 Feb 2016 07:31:24 -0500 Received: from mx1.redhat.com ([209.132.183.28]:57882) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aTqP3-0000qA-Sd for qemu-devel@nongnu.org; Thu, 11 Feb 2016 07:31:21 -0500 References: <1450284981-10641-1-git-send-email-apyrgio@arrikto.com> <56B86013.1050504@redhat.com> <20160211121230.GB7256@arr> From: Paolo Bonzini Message-ID: <56BC7F15.9090603@redhat.com> Date: Thu, 11 Feb 2016 13:31:17 +0100 MIME-Version: 1.0 In-Reply-To: <20160211121230.GB7256@arr> Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: quoted-printable Subject: Re: [Qemu-devel] [PATCH] os-posix: Log to logfile in case of daemonize List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Dimitris Aragiorgis Cc: Alex Pyrgiotis , qemu-devel@nongnu.org On 11/02/2016 13:12, Dimitris Aragiorgis wrote: > Besides that, when one executes a daemon, shell redirection is > hardly, if ever, used. More so if the daemon already has a logfile > option. >=20 > So, we decided to give it a go and find the least painful way to > log the stderr of a QEMU process to a logfile. >=20 > To our understanding, the logfile (-D option) is used only for > messages generated by qemu_log()/qemu_log_mask(). The current > situation however is that fprintf(stderr, ...) is used in various > places throughout the codebase for logging/debug purposes. Right, mostly through error_report. Actually I like your approach (log to -D if daemonize is used). I just was not sure of the best way to implement it. Perhaps when the logfile is opened you can replace the straight fopen wit= h qemu_logfile =3D fopen(...); if (daemonized) { dup2(fileno(qemu_logfile), STDERR_FILENO); fclose(qemu_logfile); qemu_logfile =3D stderr; } Then the logfile will never be closed by qemu_log_close, and stderr will always be sent to it. Does this look sane? Paolo