Daniel P. Berrangé <berrange@redhat.com> writes:
On Tue, Jan 13, 2026 at 10:27:04AM +0100, Markus Armbruster wrote:
Daniel P. Berrangé <berrange@redhat.com> writes:
This will be used to include the thread name in error reports in a later patch. It returns a const string stored in a thread local to avoid memory allocation when it is called repeatedly in a single thread. The thread name should be set at the very start of the thread execution, which is the case when using qemu_thread_create.
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com> --- include/qemu/thread.h | 1 + meson.build | 21 +++++++++++++++++ util/qemu-thread-posix.c | 33 ++++++++++++++++++++++++++- util/qemu-thread-win32.c | 49 ++++++++++++++++++++++++++++++++++++---- 4 files changed, 99 insertions(+), 5 deletions(-)
Tempted to store the thread name in TLS and call it a day.
Using the official APIs in this way ensures that the thread name is visible outside QEMU. For example when debugging in GDB, which IMHO is an important benefit.
I didn't mean to suggest not to set the "official" thread name. This patch retrieves the "official" thread name back. Takes a bit of system-specific code, including Meson magic. We could instead hold on to our own copy, and just use that.