From: Richard Henderson <richard.henderson@linaro.org>
To: qemu-devel@nongnu.org
Subject: Re: [PATCH v2 06/14] util: set the name for the 'main' thread
Date: Sun, 31 Aug 2025 08:06:05 +1000 [thread overview]
Message-ID: <497b3e2f-8c60-4fd1-a58e-1b311d0870f2@linaro.org> (raw)
In-Reply-To: <20250829180354.2922145-7-berrange@redhat.com>
On 8/30/25 04:03, Daniel P. Berrangé wrote:
> The default main thread name is undefined, so use a constructor to
> explicitly set it to 'main'. This constructor is marked to run early
> as the thread name is intended to be used in error reporting / logs
> which may be triggered very early in QEMU execution.
>
> Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
> ---
> util/qemu-thread-posix.c | 6 ++++++
> util/qemu-thread-win32.c | 6 ++++++
> 2 files changed, 12 insertions(+)
>
> diff --git a/util/qemu-thread-posix.c b/util/qemu-thread-posix.c
> index ddaa1de4dd..275445ed94 100644
> --- a/util/qemu-thread-posix.c
> +++ b/util/qemu-thread-posix.c
> @@ -22,6 +22,12 @@
> #include <pthread_np.h>
> #endif
>
> +static void __attribute__((__constructor__(QEMU_CONSTRUCTOR_EARLY)))
> +qemu_thread_init(void)
> +{
> + qemu_thread_set_name("main");
> +}
> +
> static void error_exit(int err, const char *msg)
> {
> fprintf(stderr, "qemu: %s: %s\n", msg, strerror(err));
> diff --git a/util/qemu-thread-win32.c b/util/qemu-thread-win32.c
> index 62eaa11026..7a734a7a09 100644
> --- a/util/qemu-thread-win32.c
> +++ b/util/qemu-thread-win32.c
> @@ -22,6 +22,12 @@ typedef HRESULT (WINAPI *pSetThreadDescription) (HANDLE hThread,
> static pSetThreadDescription SetThreadDescriptionFunc;
> static HMODULE kernel32_module;
>
> +static void __attribute__((__constructor__(QEMU_CONSTRUCTOR_EARLY)))
> +qemu_thread_init(void)
> +{
> + qemu_thread_set_name("main");
> +}
> +
> static bool load_set_thread_description(void)
> {
> static gsize _init_once = 0;
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
r~
next prev parent reply other threads:[~2025-08-30 22:06 UTC|newest]
Thread overview: 31+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-08-29 18:03 [PATCH v2 00/14] util: sync error_report & qemu_log output more closely Daniel P. Berrangé
2025-08-29 18:03 ` [PATCH v2 01/14] include: define constant for early constructor priority Daniel P. Berrangé
2025-08-30 21:56 ` Richard Henderson
2025-08-30 22:56 ` Dr. David Alan Gilbert
2025-08-29 18:03 ` [PATCH v2 02/14] monitor: initialize global data from a constructor Daniel P. Berrangé
2025-08-30 21:57 ` Richard Henderson
2025-08-30 23:00 ` Dr. David Alan Gilbert
2025-08-29 18:03 ` [PATCH v2 03/14] system: unconditionally enable thread naming Daniel P. Berrangé
2025-08-30 21:59 ` Richard Henderson
2025-09-11 11:59 ` Ján Tomko
2025-08-29 18:03 ` [PATCH v2 04/14] util: expose qemu_thread_set_name Daniel P. Berrangé
2025-08-30 22:01 ` Richard Henderson
2025-08-30 23:02 ` Dr. David Alan Gilbert
2025-08-29 18:03 ` [PATCH v2 05/14] audio: make jackaudio use qemu_thread_set_name Daniel P. Berrangé
2025-08-30 22:05 ` Richard Henderson
2025-08-30 23:12 ` Dr. David Alan Gilbert
2025-08-29 18:03 ` [PATCH v2 06/14] util: set the name for the 'main' thread Daniel P. Berrangé
2025-08-30 22:06 ` Richard Henderson [this message]
2025-08-30 23:26 ` Dr. David Alan Gilbert
2025-08-29 18:03 ` [PATCH v2 07/14] util: add API to fetch the current thread name Daniel P. Berrangé
2025-08-30 22:14 ` Richard Henderson
2025-09-01 8:49 ` Daniel P. Berrangé
2025-09-02 10:19 ` Richard Henderson
2025-08-29 18:03 ` [PATCH v2 08/14] log: avoid prefix on split qemu_log calls Daniel P. Berrangé
2025-08-29 18:03 ` [PATCH v2 09/14] util: introduce common helper for error-report & log code Daniel P. Berrangé
2025-09-02 10:22 ` Richard Henderson
2025-08-29 18:03 ` [PATCH v2 10/14] util: convert error-report & log to message API for timestamp Daniel P. Berrangé
2025-08-29 18:03 ` [PATCH v2 11/14] util: add support for formatting a workload name in messages Daniel P. Berrangé
2025-08-29 18:03 ` [PATCH v2 12/14] util: add support for formatting a program " Daniel P. Berrangé
2025-08-29 18:03 ` [PATCH v2 13/14] util: add support for formatting thread info " Daniel P. Berrangé
2025-08-29 18:03 ` [PATCH v2 14/14] util: add brackets around guest name in message context Daniel P. Berrangé
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=497b3e2f-8c60-4fd1-a58e-1b311d0870f2@linaro.org \
--to=richard.henderson@linaro.org \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).