Re: Generic way to detect qemu linux-user emulation

2025-04-05 Thread Andreas Schwab
On Mär 18 2025, Helge Deller wrote: > My current (unreliable) way to detect it is using uname. > The kernel string and arch name don't match: > > (sid_hppa)root@paq:/# uname -a > Linux paq 6.1.0-31-amd64 #1 SMP PREEMPT_DYNAMIC Debian 6.1.128-1 (2025-02-07) > parisc GNU/Linux > > (sid_hppa)root@pa

Re: Generic way to detect qemu linux-user emulation

2025-04-05 Thread Daniel P . Berrangé
On Tue, Mar 18, 2025 at 01:06:17PM +, Peter Maydell wrote: > On Tue, 18 Mar 2025 at 12:43, Daniel P. Berrangé wrote: > > > > On Tue, Mar 18, 2025 at 01:34:57PM +0100, Andreas Schwab wrote: > > > On Mär 18 2025, Daniel P. Berrangé wrote: > > > > > > > Whereever practical, it is preferrable to c

Re: Generic way to detect qemu linux-user emulation

2025-04-04 Thread Andreas Schwab
On Mär 18 2025, Daniel P. Berrangé wrote: > Whereever practical, it is preferrable to check a discrete feature > or behaviour in a functional way, rather than matching on "is it QEMU" Do you know a way to detect support for CLONE_VFORK that isn't too expensive? -- Andreas Schwab, SUSE Labs, sch

Re: Generic way to detect qemu linux-user emulation

2025-03-18 Thread Helge Deller
On 3/18/25 11:18, Andreas Schwab wrote: Is there a generic way for a program to detect that is it being run inside the linux-user emulation? Yes, having a reliable way to detect it would be good. My current (unreliable) way to detect it is using uname. The kernel string and arch name don't mat

Re: Generic way to detect qemu linux-user emulation

2025-03-18 Thread Peter Maydell
On Tue, 18 Mar 2025 at 13:55, Daniel P. Berrangé wrote: > > On Tue, Mar 18, 2025 at 01:06:17PM +, Peter Maydell wrote: > > The difficulty with vfork() (and, more generally, with various of > > the clone() syscall flag combinations) is that because we use the > > host libc we are restricted to

Re: Generic way to detect qemu linux-user emulation

2025-03-18 Thread Daniel P . Berrangé
On Tue, Mar 18, 2025 at 01:34:57PM +0100, Andreas Schwab wrote: > On Mär 18 2025, Daniel P. Berrangé wrote: > > > Whereever practical, it is preferrable to check a discrete feature > > or behaviour in a functional way, rather than matching on "is it QEMU" > > Do you know a way to detect support f

Re: Generic way to detect qemu linux-user emulation

2025-03-18 Thread Peter Maydell
On Tue, 18 Mar 2025 at 10:36, Helge Deller wrote: > > On 3/18/25 11:18, Andreas Schwab wrote: > > Is there a generic way for a program to detect that is it being run > > inside the linux-user emulation? > > Yes, having a reliable way to detect it would be good. > > My current (unreliable) way to d

Re: Generic way to detect qemu linux-user emulation

2025-03-18 Thread Peter Maydell
On Tue, 18 Mar 2025 at 15:04, Peter Maydell wrote: > More generally, AIUI glibc expects that it has control over what's > happening with threads, so it can set up its own data structures > for the new thread (e.g. for TLS variables). This email from the > glibc mailing list is admittedly now two d

Re: Generic way to detect qemu linux-user emulation

2025-03-18 Thread Peter Maydell
On Tue, 18 Mar 2025 at 17:18, Daniel P. Berrangé wrote: > > On Tue, Mar 18, 2025 at 05:08:52PM +, Peter Maydell wrote: > > On Tue, 18 Mar 2025 at 15:04, Peter Maydell > > wrote: > > > More generally, AIUI glibc expects that it has control over what's > > > happening with threads, so it can s

Re: Generic way to detect qemu linux-user emulation

2025-03-18 Thread Daniel P . Berrangé
On Tue, Mar 18, 2025 at 03:17:33PM +0100, Andreas Schwab wrote: > On Mär 18 2025, Daniel P. Berrangé wrote: > > > That would get the synchronization behaviour of Linux vfork, > > but I'm not sure it'd get the performance benefits (of avoiding > > page table copying) which is what Andreas mentione

Re: Generic way to detect qemu linux-user emulation

2025-03-18 Thread Daniel P . Berrangé
On Tue, Mar 18, 2025 at 05:08:52PM +, Peter Maydell wrote: > On Tue, 18 Mar 2025 at 15:04, Peter Maydell wrote: > > More generally, AIUI glibc expects that it has control over what's > > happening with threads, so it can set up its own data structures > > for the new thread (e.g. for TLS varia

Re: Generic way to detect qemu linux-user emulation

2025-03-18 Thread Peter Maydell
On Tue, 18 Mar 2025 at 12:43, Daniel P. Berrangé wrote: > > On Tue, Mar 18, 2025 at 01:34:57PM +0100, Andreas Schwab wrote: > > On Mär 18 2025, Daniel P. Berrangé wrote: > > > > > Whereever practical, it is preferrable to check a discrete feature > > > or behaviour in a functional way, rather than

Re: Generic way to detect qemu linux-user emulation

2025-03-18 Thread Andreas Schwab
On Mär 18 2025, Daniel P. Berrangé wrote: > That would get the synchronization behaviour of Linux vfork, > but I'm not sure it'd get the performance benefits (of avoiding > page table copying) which is what Andreas mentioned as the > desired thing ? For an emulation performance isn't a thing, wh

Re: Generic way to detect qemu linux-user emulation

2025-03-18 Thread Daniel P . Berrangé
On Tue, Mar 18, 2025 at 10:53:27AM +, Peter Maydell wrote: > On Tue, 18 Mar 2025 at 10:36, Helge Deller wrote: > > > > On 3/18/25 11:18, Andreas Schwab wrote: > > > Is there a generic way for a program to detect that is it being run > > > inside the linux-user emulation? > > > > Yes, having a

Re: Generic way to detect qemu linux-user emulation

2025-03-18 Thread Helge Deller
On 3/18/25 11:36, Helge Deller wrote: On 3/18/25 11:18, Andreas Schwab wrote: Is there a generic way for a program to detect that is it being run inside the linux-user emulation? Yes, having a reliable way to detect it would be good. In qemu-user emulation we could change the return values o