From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:48323) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UXW6A-0008N2-4a for qemu-devel@nongnu.org; Wed, 01 May 2013 08:25:27 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UXW68-0008LW-Q9 for qemu-devel@nongnu.org; Wed, 01 May 2013 08:25:26 -0400 Received: from mx1.redhat.com ([209.132.183.28]:12986) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UXW68-0008LQ-IZ for qemu-devel@nongnu.org; Wed, 01 May 2013 08:25:24 -0400 Date: Wed, 1 May 2013 13:25:00 +0100 From: "Daniel P. Berrange" Message-ID: <20130501122500.GG13875@redhat.com> References: <1367265445-27365-1-git-send-email-saguchi@redhat.com> <20130501120550.GC28932@stefanha-thinkpad.redhat.com> <518107A1.7050906@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <518107A1.7050906@redhat.com> Subject: Re: [Qemu-devel] [RFC][PATCH v2]Add timestamp to error message Reply-To: "Daniel P. Berrange" List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Eric Blake Cc: kwolf@redhat.com, aliguori@us.ibm.com, Seiji Aguchi , stefanha@redhat.com, mst@redhat.com, Stefan Hajnoczi , mtosatti@redhat.com, qemu-devel@nongnu.org, armbru@redhat.com, dle-develop@lists.sourceforge.net, av1474@comtv.ru, tomoki.sekiyama@hds.com, pbonzini@redhat.com, lcapitulino@redhat.com, Seiji Aguchi On Wed, May 01, 2013 at 06:16:33AM -0600, Eric Blake wrote: > On 05/01/2013 06:05 AM, Stefan Hajnoczi wrote: > > >> + error_printf( > >> + "%4d-%02d-%02d %02d:%02d:%02d.%03lld+0000 ", > >> + fields.tm_year + 1900, fields.tm_mon + 1, fields.tm_mday, > >> + fields.tm_hour, fields.tm_min, fields.tm_sec, > >> + now % 1000); > > > > Can strftime(3) be used instead of copying code from glibc? > > No, because glibc's strftime() is not async-signal safe, and therefore > is not safe to call between fork() and exec() (libvirt hit actual > deadlocks[1] where a child was blocked on a mutex associated with > time-related functions that happened to be held by another parent > thread, but where the fork nuked that other thread so the mutex would > never clear). This code is copied from libvirt, which copied the > no-lock-needed safe portions of glibc for a reason. > > [1] https://www.redhat.com/archives/libvir-list/2011-November/msg01609.html NB the original libvirt code had this & other related functions in a standalone file, along with a significant test suite. I think it is better from a maintenence POV to keep this functionality in a file that's separate from the qemu error file, so it can be reused elsewhere in QEMU if needed. It should also copy the test suite, since it is bad practice to throw away tests which already exist. 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 :|