From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([140.186.70.92]:56434) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Rmq7z-00078B-D3 for qemu-devel@nongnu.org; Mon, 16 Jan 2012 12:13:55 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Rmq7t-0008Pb-BJ for qemu-devel@nongnu.org; Mon, 16 Jan 2012 12:13:51 -0500 Received: from mx1.redhat.com ([209.132.183.28]:28619) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Rmq7t-0008PP-3F for qemu-devel@nongnu.org; Mon, 16 Jan 2012 12:13:45 -0500 Date: Mon, 16 Jan 2012 17:13:39 +0000 From: "Daniel P. Berrange" Message-ID: <20120116171339.GA2297@redhat.com> References: <1326482122-12619-1-git-send-email-lcapitulino@redhat.com> <1326482122-12619-3-git-send-email-lcapitulino@redhat.com> <4F10A694.8030900@redhat.com> <20120116150853.40626823@doriath> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20120116150853.40626823@doriath> Subject: Re: [Qemu-devel] [PATCH 2/2] qemu-ga: Add the guest-suspend command Reply-To: "Daniel P. Berrange" List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Luiz Capitulino Cc: jcody@redhat.com, Eric Blake , qemu-devel@nongnu.org, mdroth@linux.vnet.ibm.com On Mon, Jan 16, 2012 at 03:08:53PM -0200, Luiz Capitulino wrote: > On Fri, 13 Jan 2012 14:48:04 -0700 > Eric Blake wrote: > > > > + > > > + pid = fork(); > > > + if (!pid) { > > > + char buf[32]; > > > + FILE *sysfile; > > > + const char *arg; > > > + const char *pmutils_bin = "pm-is-supported"; > > > + > > > + if (strcmp(mode, "hibernate") == 0) { > > > > Strangely enough, POSIX doesn't include strcmp() in its list of > > async-signal-safe functions (which is what you should be restricting > > yourself to, if qemu-ga is multi-threaded), but in practice, I think > > that is a bug of omission in POSIX, and not something you have to change > > in your code. > > memset() ins't either... sigaction() either, which begins to get > annoying. > > For those familiar with glib: isn't it possible to confirm it's using > threads and/or acquire a global mutex or something? The most that GLib says is "The GLib threading system used to be initialized with g_thread_init(). This is no longer necessary. Since version 2.32, the GLib threading system is automatically initialized at the start of your program, and all thread-creation functions and synchronization primitives are available right away. Note that it is not safe to assume that your program has no threads even if you don't call g_thread_new() yourself. GLib and GIO can and will create threads for their own purposes in some cases, such as when using g_unix_signal_source_new() or when using GDBus. " The latter paragraph is rather fuzzy, which is probably intentional. So I think the only safe thing, in order to be future proof wrt later GLib releases, is to just assume you have threads at all times. 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 :|