Re: [PATCH v2 1/2] util/log: Derive thread id from getpid() on hosts w/o gettid() syscall

2022-10-21 Thread Greg Kurz
On Thu, 20 Oct 2022 12:39:41 +0200 Paolo Bonzini wrote: > On 10/19/22 17:57, Daniel P. Berrangé wrote: > >> +if (my_id == -1) { > >> +my_id = getpid() + qatomic_fetch_inc(&counter); > >> +} > >> +return my_id; > > This doesn't look safe for linux-user when we fork, but don't e

Re: [PATCH v2 1/2] util/log: Derive thread id from getpid() on hosts w/o gettid() syscall

2022-10-20 Thread Paolo Bonzini
On 10/19/22 17:57, Daniel P. Berrangé wrote: +if (my_id == -1) { +my_id = getpid() + qatomic_fetch_inc(&counter); +} +return my_id; This doesn't look safe for linux-user when we fork, but don't exec. Linux-user won't ever get here, however bsd-user might. We should have g

Re: [PATCH v2 1/2] util/log: Derive thread id from getpid() on hosts w/o gettid() syscall

2022-10-20 Thread Greg Kurz
On Wed, 19 Oct 2022 16:57:54 +0100 Daniel P. Berrangé wrote: > On Wed, Oct 19, 2022 at 05:16:50PM +0200, Greg Kurz wrote: > > A subsequent patch needs to be able to differentiate the main QEMU > > thread from other threads. An obvious way to do so is to compare > > log_thread_id() and getpid(), b

Re: [PATCH v2 1/2] util/log: Derive thread id from getpid() on hosts w/o gettid() syscall

2022-10-19 Thread Daniel P . Berrangé
On Wed, Oct 19, 2022 at 05:16:50PM +0200, Greg Kurz wrote: > A subsequent patch needs to be able to differentiate the main QEMU > thread from other threads. An obvious way to do so is to compare > log_thread_id() and getpid(), based on the fact that they are equal > for the main thread on systems t

[PATCH v2 1/2] util/log: Derive thread id from getpid() on hosts w/o gettid() syscall

2022-10-19 Thread Greg Kurz
A subsequent patch needs to be able to differentiate the main QEMU thread from other threads. An obvious way to do so is to compare log_thread_id() and getpid(), based on the fact that they are equal for the main thread on systems that have the gettid() syscall (e.g. linux). Adapt the fallback cod