From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:49926) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aTuQo-0007ob-J1 for qemu-devel@nongnu.org; Thu, 11 Feb 2016 11:49:27 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aTuQl-0004dv-8b for qemu-devel@nongnu.org; Thu, 11 Feb 2016 11:49:26 -0500 Received: from mx0.arrikto.com ([212.71.252.59]:57969) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aTuQl-0004db-2L for qemu-devel@nongnu.org; Thu, 11 Feb 2016 11:49:23 -0500 Date: Thu, 11 Feb 2016 18:49:19 +0200 From: Dimitris Aragiorgis Message-ID: <20160211164919.GC7256@arr> References: <1450284981-10641-1-git-send-email-apyrgio@arrikto.com> <56B86013.1050504@redhat.com> <20160211121230.GB7256@arr> <56BC7F15.9090603@redhat.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="xo44VMWPx7vlQ2+2" Content-Disposition: inline In-Reply-To: <56BC7F15.9090603@redhat.com> 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: Paolo Bonzini Cc: Alex Pyrgiotis , qemu-devel@nongnu.org --xo44VMWPx7vlQ2+2 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Hi, * Paolo Bonzini [2016-02-11 13:31:17 +0100]: >=20 >=20 > 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. >=20 > Right, mostly through error_report. >=20 > Actually I like your approach (log to -D if daemonize is used). I > just was not sure of the best way to implement it. >=20 Well my apprach was based on the extra option so that the current behavior does not change and logfiles become too noisy out of the blue. I have a patch already that: - modifies do_qemu_set_log() so that if -log-stderr is given to: + open the logfile + dup stderr to it + skip qemu_log_close() - modifies os_setup_post() to dup stderr to /dev/null only if qemu_logfile is NULL. If we do not want this extra option, I guess we are talking about logging stderr to -D *only* if daemonize is used, right? > Perhaps when the logfile is opened you can replace the straight fopen with >=20 > qemu_logfile =3D fopen(...); > if (daemonized) { > dup2(fileno(qemu_logfile), STDERR_FILENO); > fclose(qemu_logfile); > qemu_logfile =3D stderr; > } >=20 > Then the logfile will never be closed by qemu_log_close, and stderr > will always be sent to it. Does this look sane? >=20 I guess the above snippet will go in do_qemu_set_log(), right? If true, we have to open the logfile even if the -d option is not given. Besides that, log.c should become aware of daemonize. Depending on your answers I'll prepare the corresponding patch. Thanks, dimara > Paolo --xo44VMWPx7vlQ2+2 Content-Type: application/pgp-signature; name="signature.asc" Content-Description: Digital signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.12 (GNU/Linux) iQEcBAEBAgAGBQJWvLuPAAoJEHFDHex6CBG9Xz4H/RlbByeoihEFm/TxXT05KuUR X48DxaBGAGe8vIEq6Of81BPQ0AzcGM2P3ITNka7FGcv5IQYs8gQ0ofZoJ2qJUGVd FNO87mdJROClv10XMbQUFKvZxDxBzao3teEPolW9NbxPbguO7/Dru8pP2AQCkN2+ JhbyWhqjCWu5LuFoerfyKQoY1+fhoSw57hhEFY2EzoIHj56XnkqkKVmiAFl9gY6C 7qo4oOMjmlz28RnRyRICuHSMjKIqcxmtk4mqwJRPF5KObo934bASpHK73RYJ553l F74wg07EwGLQ+6ZxGpG2ikfr0/YpFdh+KKSIutK/+YpTdIw/luFBI+u4GWieyZM= =GreV -----END PGP SIGNATURE----- --xo44VMWPx7vlQ2+2--