qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Stefan Hajnoczi <stefanha@gmail.com>
To: Stefan Hajnoczi <stefanha@redhat.com>
Cc: mario.dechenno@unina2.it, Paolo Bonzini <pbonzini@redhat.com>,
	qemu-devel@nongnu.org, Kevin Wolf <kwolf@redhat.com>
Subject: Re: [Qemu-devel] [PATCH] osdep: initialize glib threads in all QEMU tools
Date: Sun, 23 Mar 2014 16:56:58 +0100	[thread overview]
Message-ID: <20140323155658.GA18228@stefanha-thinkpad.hitronhub.home> (raw)
In-Reply-To: <1381226311-23489-1-git-send-email-stefanha@redhat.com>

On Tue, Oct 08, 2013 at 11:58:31AM +0200, Stefan Hajnoczi wrote:
> glib versions prior to 2.31.0 require an explicit g_thread_init() call
> to enable multi-threading.
> 
> Failure to initialize threading causes glib to take single-threaded code
> paths without synchronization.  For example, the g_slice allocator will
> crash due to race conditions.
> 
> Fix this for all QEMU tool programs (qemu-nbd, qemu-io, qemu-img) by
> moving the g_thread_init() call from vl.c:main() into a new
> osdep.c:thread_init() constructor function.
> 
> thread_init() has __attribute__((constructor)) and is automatically
> invoked by the runtime during startup.
> 
> We can now drop the "simple" trace backend's g_thread_init() call since
> thread_init() already called it.
> 
> Note that we must keep coroutine-gthread.c's g_thread_init() call which
> is located in a constructor function.  There is no guarantee for
> constructor function ordering so thread_init() may only be called later.
> 
> Reported-by: Mario de Chenno <mario.dechenno@unina2.it>
> Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
> ---
>  trace/simple.c |  9 ---------
>  util/osdep.c   | 18 ++++++++++++++++++
>  vl.c           |  8 --------
>  3 files changed, 18 insertions(+), 17 deletions(-)

Applied to my block tree, we need this for QEMU 2.0:
https://github.com/stefanha/qemu/commits/block

Stefan

      parent reply	other threads:[~2014-03-23 15:57 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-10-08  9:58 [Qemu-devel] [PATCH] osdep: initialize glib threads in all QEMU tools Stefan Hajnoczi
2013-10-08 12:25 ` Kevin Wolf
2013-10-08 13:08   ` Paolo Bonzini
2013-10-08 13:58     ` Kevin Wolf
2013-10-09  8:31       ` Stefan Hajnoczi
2014-03-23 15:56 ` Stefan Hajnoczi [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20140323155658.GA18228@stefanha-thinkpad.hitronhub.home \
    --to=stefanha@gmail.com \
    --cc=kwolf@redhat.com \
    --cc=mario.dechenno@unina2.it \
    --cc=pbonzini@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=stefanha@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).