]> git.proxmox.com Git - mirror_qemu.git/blobdiff - util/osdep.c
util/qemu-sockets.c: Avoid unused variable warnings
[mirror_qemu.git] / util / osdep.c
index 685c8ae8892d5fb5ffaa304a36eeb82208782b57..b2bd1542c52c023c419e800134958fab6b6c664f 100644 (file)
@@ -46,7 +46,6 @@ extern int madvise(caddr_t, size_t, int);
 #endif
 
 #include "qemu-common.h"
-#include "trace.h"
 #include "qemu/sockets.h"
 #include "monitor/monitor.h"
 
@@ -207,6 +206,13 @@ int qemu_open(const char *name, int flags, ...)
     }
 #endif
 
+#ifdef O_DIRECT
+    if (ret == -1 && errno == EINVAL && (flags & O_DIRECT)) {
+        error_report("file system may not support O_DIRECT");
+        errno = EINVAL; /* in case it was clobbered */
+    }
+#endif /* O_DIRECT */
+
     return ret;
 }
 
@@ -430,6 +436,21 @@ int socket_init(void)
     return 0;
 }
 
+#if !GLIB_CHECK_VERSION(2, 31, 0)
+/* Ensure that glib is running in multi-threaded mode
+ * 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.
+ */
+static void __attribute__((constructor)) thread_init(void)
+{
+    if (!g_thread_supported()) {
+       g_thread_init(NULL);
+    }
+}
+#endif
+
 #ifndef CONFIG_IOVEC
 /* helper function for iov_send_recv() */
 static ssize_t