[PATCH] util: fix use of pthread_get_name_np on OpenBSD

Daniel P. Berrangé posted 1 patch 1 month, 1 week ago
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/qemu tags/patchew/20260417120531.2215549-1-berrange@redhat.com
Maintainers: Paolo Bonzini <pbonzini@redhat.com>, Brad Smith <brad@comstyle.com>
util/qemu-thread-posix.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
[PATCH] util: fix use of pthread_get_name_np on OpenBSD
Posted by Daniel P. Berrangé 1 month, 1 week ago
The pthread_get_name_np function is present on FreeBSD and OpenBSD
and has 'void' return not 'int'. We didn't notice this build problem
on FreeBSD since it also has pthread_getname_np which does return
int like Linux and we use the latter preferentially.

Fixes: 215235d365e49c72a85ea2940751e45419676031
Closes: https://gitlab.com/qemu-project/qemu/-/work_items/3399
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
---

This is a regression in the 11.0 release, but on the assumption it
is too late for further fixes, I'm CC'ing qemu-stable so this can
go into the future stable-11.0 branch

 util/qemu-thread-posix.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/util/qemu-thread-posix.c b/util/qemu-thread-posix.c
index bd1c2ad2a5..089606c93f 100644
--- a/util/qemu-thread-posix.c
+++ b/util/qemu-thread-posix.c
@@ -568,7 +568,8 @@ const char *qemu_thread_get_name(void)
 # if defined(CONFIG_PTHREAD_GETNAME_NP)
     rv = pthread_getname_np(pthread_self(), namebuf, sizeof(namebuf));
 # elif defined(CONFIG_PTHREAD_GET_NAME_NP)
-    rv = pthread_get_name_np(pthread_self(), namebuf, sizeof(namebuf));
+    pthread_get_name_np(pthread_self(), namebuf, sizeof(namebuf));
+    rv = 0;
 # else
     rv = -1;
 # endif
-- 
2.53.0


Re: [PATCH] util: fix use of pthread_get_name_np on OpenBSD
Posted by Philippe Mathieu-Daudé 1 month, 1 week ago
On 17/4/26 14:05, Daniel P. Berrangé wrote:
> The pthread_get_name_np function is present on FreeBSD and OpenBSD
> and has 'void' return not 'int'. We didn't notice this build problem
> on FreeBSD since it also has pthread_getname_np which does return
> int like Linux and we use the latter preferentially.
> 
> Fixes: 215235d365e49c72a85ea2940751e45419676031
> Closes: https://gitlab.com/qemu-project/qemu/-/work_items/3399
> Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
> ---
> 
> This is a regression in the 11.0 release, but on the assumption it
> is too late for further fixes, I'm CC'ing qemu-stable so this can
> go into the future stable-11.0 branch
> 
>   util/qemu-thread-posix.c | 3 ++-
>   1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/util/qemu-thread-posix.c b/util/qemu-thread-posix.c
> index bd1c2ad2a5..089606c93f 100644
> --- a/util/qemu-thread-posix.c
> +++ b/util/qemu-thread-posix.c
> @@ -568,7 +568,8 @@ const char *qemu_thread_get_name(void)
>   # if defined(CONFIG_PTHREAD_GETNAME_NP)
>       rv = pthread_getname_np(pthread_self(), namebuf, sizeof(namebuf));
>   # elif defined(CONFIG_PTHREAD_GET_NAME_NP)
> -    rv = pthread_get_name_np(pthread_self(), namebuf, sizeof(namebuf));
> +    pthread_get_name_np(pthread_self(), namebuf, sizeof(namebuf));
> +    rv = 0;
>   # else
>       rv = -1;
>   # endif

Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>


Re: [PATCH] util: fix use of pthread_get_name_np on OpenBSD
Posted by Thomas Huth 1 month, 1 week ago
On 17/04/2026 14.05, Daniel P. Berrangé wrote:
> The pthread_get_name_np function is present on FreeBSD and OpenBSD
> and has 'void' return not 'int'. We didn't notice this build problem
> on FreeBSD since it also has pthread_getname_np which does return
> int like Linux and we use the latter preferentially.
> 
> Fixes: 215235d365e49c72a85ea2940751e45419676031
> Closes: https://gitlab.com/qemu-project/qemu/-/work_items/3399
> Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
> ---
> 
> This is a regression in the 11.0 release, but on the assumption it
> is too late for further fixes, I'm CC'ing qemu-stable so this can
> go into the future stable-11.0 branch
> 
>   util/qemu-thread-posix.c | 3 ++-
>   1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/util/qemu-thread-posix.c b/util/qemu-thread-posix.c
> index bd1c2ad2a5..089606c93f 100644
> --- a/util/qemu-thread-posix.c
> +++ b/util/qemu-thread-posix.c
> @@ -568,7 +568,8 @@ const char *qemu_thread_get_name(void)
>   # if defined(CONFIG_PTHREAD_GETNAME_NP)
>       rv = pthread_getname_np(pthread_self(), namebuf, sizeof(namebuf));
>   # elif defined(CONFIG_PTHREAD_GET_NAME_NP)
> -    rv = pthread_get_name_np(pthread_self(), namebuf, sizeof(namebuf));
> +    pthread_get_name_np(pthread_self(), namebuf, sizeof(namebuf));
> +    rv = 0;
>   # else
>       rv = -1;
>   # endif

Reviewed-by: Thomas Huth <thuth@redhat.com>