aboutsummaryrefslogtreecommitdiff
path: root/util
diff options
context:
space:
mode:
authorPeter Maydell <peter.maydell@linaro.org>2014-03-25 15:23:08 +0000
committerPeter Maydell <peter.maydell@linaro.org>2014-03-25 15:23:08 +0000
commitd4cc1a213f8cb22fa0861ae2a907c60cf00796ff (patch)
tree80ea19c13fa7c1cee21854bc1b96fdbf30fd25ac /util
parent839a5547574e57cce62f49bfc50fe1f04b00589a (diff)
parent7b770c720b28b8ac5b82ae431f2f354b7f8add91 (diff)
downloadqemu-d4cc1a213f8cb22fa0861ae2a907c60cf00796ff.zip
qemu-d4cc1a213f8cb22fa0861ae2a907c60cf00796ff.tar.gz
qemu-d4cc1a213f8cb22fa0861ae2a907c60cf00796ff.tar.bz2
Merge remote-tracking branch 'remotes/stefanha/tags/block-pull-request' into staging
Block pull request # gpg: Signature made Tue 25 Mar 2014 14:34:45 GMT using RSA key ID 81AB73C8 # gpg: Good signature from "Stefan Hajnoczi <stefanha@redhat.com>" # gpg: aka "Stefan Hajnoczi <stefanha@gmail.com>" # gpg: WARNING: This key is not certified with a trusted signature! # gpg: There is no indication that the signature belongs to the owner. # Primary key fingerprint: 8695 A8BF D3F9 7CDA AC35 775A 9CA4 ABB3 81AB 73C8 * remotes/stefanha/tags/block-pull-request: mirror: fix early wake from sleep due to aio mirror: fix throttling delay calculation Fixed various typos qemu-img: mandate argument to 'qemu-img check --repair' osdep: initialize glib threads in all QEMU tools Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Diffstat (limited to 'util')
-rw-r--r--util/osdep.c18
1 files changed, 18 insertions, 0 deletions
diff --git a/util/osdep.c b/util/osdep.c
index bd4f530..a9029f8 100644
--- a/util/osdep.c
+++ b/util/osdep.c
@@ -436,6 +436,24 @@ int socket_init(void)
return 0;
}
+/* Ensure that glib is running in multi-threaded mode */
+static void __attribute__((constructor)) thread_init(void)
+{
+ if (!g_thread_supported()) {
+#if !GLIB_CHECK_VERSION(2, 31, 0)
+ /* Old versions of glib require explicit initialization. Failure to do
+ * this results in the single-threaded code paths being taken inside
+ * glib. For example, the g_slice allocator will not be thread-safe
+ * and cause crashes.
+ */
+ g_thread_init(NULL);
+#else
+ fprintf(stderr, "glib threading failed to initialize.\n");
+ exit(1);
+#endif
+ }
+}
+
#ifndef CONFIG_IOVEC
/* helper function for iov_send_recv() */
static ssize_t