From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:56540) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YsaLY-0004E4-6l for qemu-devel@nongnu.org; Wed, 13 May 2015 13:21:29 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YsaLU-0008TQ-G5 for qemu-devel@nongnu.org; Wed, 13 May 2015 13:21:28 -0400 Received: from mx1.redhat.com ([209.132.183.28]:42586) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YsaLU-0008TG-Al for qemu-devel@nongnu.org; Wed, 13 May 2015 13:21:24 -0400 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by mx1.redhat.com (Postfix) with ESMTPS id DBDA84B for ; Wed, 13 May 2015 17:21:23 +0000 (UTC) Date: Wed, 13 May 2015 18:21:19 +0100 From: "Daniel P. Berrange" Message-ID: <20150513172119.GR23627@redhat.com> References: <1429280557-8887-1-git-send-email-berrange@redhat.com> <1429280557-8887-9-git-send-email-berrange@redhat.com> <20150513170415.GA28703@redhat.com> <55538600.8090303@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <55538600.8090303@redhat.com> Subject: Re: [Qemu-devel] [PATCH v1 RFC 08/34] crypto: introduce new module for computing hash digests Reply-To: "Daniel P. Berrange" List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Paolo Bonzini Cc: qemu-devel@nongnu.org, Stefan Hajnoczi , Gerd Hoffmann On Wed, May 13, 2015 at 07:12:32PM +0200, Paolo Bonzini wrote: > > > On 13/05/2015 19:04, Daniel P. Berrange wrote: > > I'm thinking perhaps a better approach could be for the crypto related > > APIs to call qcrypto_init() on an as-needed basis. The downside would > > be that this could delay the point at which the user sees a gnutls > > initialization failure to only after QEMU has been running for a while, > > instead of being upfront at startup. The plus side is obviously that > > we'd not need to update every binary program main() method. > > > > I notice though that QEMU does not make use of pthread_once() for > > global initializers. Is there any particular reason for this ? With > > this crypto code it is not safe to rely on being single threaded, > > since the crypto code can be invoked from I/O threads as well as > > the main event loop. So ideally I would use a pthread_once() instead > > of having a static 'bool is_initialized' protected by a pthread_mutex > > Yes---though you'd use a GOnce instead for portability. > > In fact you would likely keep both, and use a GOnce from qcrypto_init. > Then you can always call qcrypto_init from main if that helps making > early failures clearer. Ok, I'll go with GOnce and keep an init call in vl.c for clear error reporting. 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 :|