summary refs log tree commit diff stats
path: root/util/qemu-thread-posix.c
diff options
context:
space:
mode:
authorDr. David Alan Gilbert <dgilbert@redhat.com>2014-01-30 10:20:32 +0000
committerMichael S. Tsirkin <mst@redhat.com>2014-03-09 21:09:38 +0200
commit4900116e6f0edef6877c0e8a9ca19957d47765c9 (patch)
tree8ecc45f0f28d012d2ffc8dad01352654444b89c9 /util/qemu-thread-posix.c
parent8f480de0c91a18d550721f8d9af969ebfbda0793 (diff)
downloadfocaccia-qemu-4900116e6f0edef6877c0e8a9ca19957d47765c9.tar.gz
focaccia-qemu-4900116e6f0edef6877c0e8a9ca19957d47765c9.zip
Add a 'name' parameter to qemu_thread_create
If enabled, set the thread name at creation (on GNU systems with
  pthread_set_np)
Fix up all the callers with a thread name

Signed-off-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
Acked-by: Michael S. Tsirkin <mst@redhat.com>
Reviewed-by: Laszlo Ersek <lersek@redhat.com>
Diffstat (limited to 'util/qemu-thread-posix.c')
-rw-r--r--util/qemu-thread-posix.c9
1 files changed, 7 insertions, 2 deletions
diff --git a/util/qemu-thread-posix.c b/util/qemu-thread-posix.c
index 0fa6c81c0a..45113b464d 100644
--- a/util/qemu-thread-posix.c
+++ b/util/qemu-thread-posix.c
@@ -394,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)
 {
@@ -421,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);