On 1/9/26 12:52, Daniel P. Berrangé wrote:
On Fri, Jan 09, 2026 at 12:45:03PM +0100, Paolo Bonzini wrote:
On 1/8/26 18: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.

At least on Linux I don't think we want to call the pthread function.

Since pthread_setname_np writes to /proc/self/task/tid/comm, wouldn't that
cause ps to show qemu processes as "main" instead of "qemu" or "qemu-kvm"?

Hmmm, it depends on the 'ps' options you use:

$ ./build/qemu-system-x86_64  &
[3] 3859009

⚙️ [oci:fedora-43 qemu]$ ps  | grep 3859009
3859009 pts/10   00:00:04 main
⚙️ [oci:fedora-43 qemu]$ ps -a | grep 3859009
3859009 pts/10   00:00:03 main
⚙️ [oci:fedora-43 qemu]$ ps -ax | grep 3859009
3859009 pts/10   Sl     0:03 ./build/qemu-system-x86_64
⚙️ [oci:fedora-43 qemu]$ ps -au | grep 3859009
berrange 3859009  8.6  0.1 3893224 123700 pts/10 Sl   11:49   0:04 
./build/qemu-system-x86_64
⚙️ [oci:fedora-43 qemu]$ ps -af | grep 3859009
berrange 3859009 2085609  8 11:49 pts/10   00:00:04 ./build/qemu-system-x86_64
⚙️ [oci:fedora-43 qemu]$ ps -axuwf | grep 3859009
berrange 3859009 53.4  0.1 3905536 124108 pts/10 Sl   11:49   0:03  |       \_ 
./build/qemu-system-x86_64


and I hadn't noticed since I always use one of the latter
sets of options that give the true name.

FWIW "top" also changes its process name to "main"; there's precedent for Firefox *not* changing it:

$ ps -o "%c" $(pidof firefox)
COMMAND
firefox
forkserver
Socket Process
Privileged Cont
...

Since we can't really know how the COMM is being used by monitoring tools, and there's a simple workaround within QEMU, I'd prefer avoiding this. Sorry for not spotting it earlier.

Paolo

Reply via email to