mirror of https://github.com/proxmox/mirror_qemu
qemu-thread: always keep the posix wrapper layer
We will conditionally have a wrapper layer depending on whether the host has the PTHREAD_SETNAME capability. It complicates stuff. Let's keep the wrapper there; we opt out the pthread_setname_np() call only. Signed-off-by: Peter Xu <peterx@redhat.com> Message-Id: <20180412053444.17801-1-peterx@redhat.com> Reviewed-by: Fam Zheng <famz@redhat.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>master
parent
48564041a7
commit
d820fa5b62
|
@ -482,7 +482,6 @@ static void __attribute__((constructor)) qemu_thread_atexit_init(void)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#ifdef CONFIG_PTHREAD_SETNAME_NP
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
void *(*start_routine)(void *);
|
void *(*start_routine)(void *);
|
||||||
void *arg;
|
void *arg;
|
||||||
|
@ -495,16 +494,18 @@ static void *qemu_thread_start(void *args)
|
||||||
void *(*start_routine)(void *) = qemu_thread_args->start_routine;
|
void *(*start_routine)(void *) = qemu_thread_args->start_routine;
|
||||||
void *arg = qemu_thread_args->arg;
|
void *arg = qemu_thread_args->arg;
|
||||||
|
|
||||||
|
#ifdef CONFIG_PTHREAD_SETNAME_NP
|
||||||
/* Attempt to set the threads name; note that this is for debug, so
|
/* Attempt to set the threads name; note that this is for debug, so
|
||||||
* we're not going to fail if we can't set it.
|
* we're not going to fail if we can't set it.
|
||||||
*/
|
*/
|
||||||
pthread_setname_np(pthread_self(), qemu_thread_args->name);
|
if (name_threads && qemu_thread_args->name) {
|
||||||
|
pthread_setname_np(pthread_self(), qemu_thread_args->name);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
g_free(qemu_thread_args->name);
|
g_free(qemu_thread_args->name);
|
||||||
g_free(qemu_thread_args);
|
g_free(qemu_thread_args);
|
||||||
return start_routine(arg);
|
return start_routine(arg);
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
void qemu_thread_create(QemuThread *thread, const char *name,
|
void qemu_thread_create(QemuThread *thread, const char *name,
|
||||||
void *(*start_routine)(void*),
|
void *(*start_routine)(void*),
|
||||||
|
@ -513,6 +514,7 @@ void qemu_thread_create(QemuThread *thread, const char *name,
|
||||||
sigset_t set, oldset;
|
sigset_t set, oldset;
|
||||||
int err;
|
int err;
|
||||||
pthread_attr_t attr;
|
pthread_attr_t attr;
|
||||||
|
QemuThreadArgs *qemu_thread_args;
|
||||||
|
|
||||||
err = pthread_attr_init(&attr);
|
err = pthread_attr_init(&attr);
|
||||||
if (err) {
|
if (err) {
|
||||||
|
@ -527,22 +529,13 @@ void qemu_thread_create(QemuThread *thread, const char *name,
|
||||||
sigfillset(&set);
|
sigfillset(&set);
|
||||||
pthread_sigmask(SIG_SETMASK, &set, &oldset);
|
pthread_sigmask(SIG_SETMASK, &set, &oldset);
|
||||||
|
|
||||||
#ifdef CONFIG_PTHREAD_SETNAME_NP
|
qemu_thread_args = g_new0(QemuThreadArgs, 1);
|
||||||
if (name_threads) {
|
qemu_thread_args->name = g_strdup(name);
|
||||||
QemuThreadArgs *qemu_thread_args;
|
qemu_thread_args->start_routine = start_routine;
|
||||||
qemu_thread_args = g_new0(QemuThreadArgs, 1);
|
qemu_thread_args->arg = arg;
|
||||||
qemu_thread_args->name = g_strdup(name);
|
|
||||||
qemu_thread_args->start_routine = start_routine;
|
|
||||||
qemu_thread_args->arg = arg;
|
|
||||||
|
|
||||||
err = pthread_create(&thread->thread, &attr,
|
err = pthread_create(&thread->thread, &attr,
|
||||||
qemu_thread_start, qemu_thread_args);
|
qemu_thread_start, qemu_thread_args);
|
||||||
} else
|
|
||||||
#endif
|
|
||||||
{
|
|
||||||
err = pthread_create(&thread->thread, &attr,
|
|
||||||
start_routine, arg);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (err)
|
if (err)
|
||||||
error_exit(err, __func__);
|
error_exit(err, __func__);
|
||||||
|
|
Loading…
Reference in New Issue