From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:33783) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aailm-0006Mj-Le for qemu-devel@nongnu.org; Tue, 01 Mar 2016 06:47:15 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aailj-0007WC-U3 for qemu-devel@nongnu.org; Tue, 01 Mar 2016 06:47:14 -0500 Received: from mx1.redhat.com ([209.132.183.28]:38643) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aailj-0007W4-O9 for qemu-devel@nongnu.org; Tue, 01 Mar 2016 06:47:11 -0500 Date: Tue, 1 Mar 2016 11:47:07 +0000 From: "Daniel P. Berrange" Message-ID: <20160301114707.GG26728@redhat.com> References: <56BCCB44.4060203@redhat.com> <1455795518-19205-1-git-send-email-dimara@arrikto.com> <1456830921.23994.14.camel@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <1456830921.23994.14.camel@redhat.com> Subject: Re: [Qemu-devel] [PATCH] log: Redirect stderr to logfile if deamonized Reply-To: "Daniel P. Berrange" List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Gerd Hoffmann Cc: pbonzini@redhat.com, Dimitris Aragiorgis , qemu-devel@nongnu.org On Tue, Mar 01, 2016 at 12:15:21PM +0100, Gerd Hoffmann wrote: > On Do, 2016-02-18 at 13:38 +0200, Dimitris Aragiorgis wrote: > > In case of daemonize, use the logfile passed with the -D option in > > order to redirect stderr to it instead of /dev/null. > > > > Also remove some unused code in log.h. > > Patch breaks interaction with libvirt. libvirt hangs on startup, while > probing qemu capabilities. qemu runs in probing mode (command line is > "/home/kraxel/projects/qemu/build-default/x86_64-softmmu/qemu-system-x86_64 -S -no-user-config -nodefaults -nographic -M none -qmp unix:/var/lib/libvirt/qemu/capabilities.monitor.sock,server,nowait -pidfile /var/lib/libvirt/qemu/capabilities.pidfile -daemonize" according to "systemctl status libvirtd -l"), apparently both qemu and libvirt wait for each other. When libvirt is probing capabilities it passes a pipe file descriptor for stderr. It reads from this pipe to detect any errors printed by QEMU before daemonizing. When QEMU daemonizes, it closes this FD and sets stderr to /dev/null. Libvirt knows qemu has successfully started up at this point. With this patch though, this code: @@ -275,7 +276,10 @@ void os_setup_post(void) dup2(fd, 0); dup2(fd, 1); - dup2(fd, 2); + /* In case -D is given do not redirect stderr to /dev/null */ + if (!qemu_logfile) { + dup2(fd, 2); + } close(fd); means that QEMU will never close stderr anymore, so libvirt things QEMU is still starting up....forever. Given current libvirt behaviour / expectations, I think the only option is to revert this change. IMHO if applications want qemu logs to go to stderr, they should explicitly ask for that to happen via a CLI arg. Regards, Daniel -- |: http://berrange.com -o- http://www.flickr.com/photos/dberrange/ :| |: http://libvirt.org -o- http://virt-manager.org :| |: http://autobuild.org -o- http://search.cpan.org/~danberr/ :| |: http://entangle-photo.org -o- http://live.gnome.org/gtk-vnc :|