aboutsummaryrefslogtreecommitdiff
path: root/util/qemu-thread-posix.c
diff options
context:
space:
mode:
Diffstat (limited to 'util/qemu-thread-posix.c')
-rw-r--r--util/qemu-thread-posix.c16
1 files changed, 14 insertions, 2 deletions
diff --git a/util/qemu-thread-posix.c b/util/qemu-thread-posix.c
index 37dd298631..45113b464d 100644
--- a/util/qemu-thread-posix.c
+++ b/util/qemu-thread-posix.c
@@ -27,6 +27,13 @@
#include "qemu/thread.h"
#include "qemu/atomic.h"
+static bool name_threads;
+
+void qemu_thread_naming(bool enable)
+{
+ name_threads = enable;
+}
+
static void error_exit(int err, const char *msg)
{
fprintf(stderr, "qemu: %s: %s\n", msg, strerror(err));
@@ -387,8 +394,7 @@ void qemu_event_wait(QemuEvent *ev)
}
}
-
-void qemu_thread_create(QemuThread *thread,
+void qemu_thread_create(QemuThread *thread, const char *name,
void *(*start_routine)(void*),
void *arg, int mode)
{
@@ -414,6 +420,12 @@ void qemu_thread_create(QemuThread *thread,
if (err)
error_exit(err, __func__);
+#ifdef _GNU_SOURCE
+ if (name_threads) {
+ pthread_setname_np(thread->thread, name);
+ }
+#endif
+
pthread_sigmask(SIG_SETMASK, &oldset, NULL);
pthread_attr_destroy(&attr);