All of lore.kernel.org
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH] linux-user/main.c: Always set QEMU_LD_PREFIX when interp_prefix is changed
@ 2015-09-10  5:43 gang.chen.5i5j
  2015-09-10  5:49 ` Chen Gang
                   ` (2 more replies)
  0 siblings, 3 replies; 9+ messages in thread
From: gang.chen.5i5j @ 2015-09-10  5:43 UTC (permalink / raw)
  To: riku.voipio; +Cc: peter.maydell, Chen Gang, qemu-devel, xili_gchen_5257, rth

From: Chen Gang <gang.chen.5i5j@gmail.com>

If qemu sets interp_prfix via command line '-L' instead of environments
variable QEMU_LD_PREFIX, it will cause syscall execve() failed. Because
the 2nd qemu has no command line '-L'.

So qemu need always set QEMU_LD_PREFIX when interp_prefix is changed.

Signed-off-by: Chen Gang <gang.chen.5i5j@gmail.com>
---
 linux-user/main.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/linux-user/main.c b/linux-user/main.c
index 06dd296..2f31ea6 100644
--- a/linux-user/main.c
+++ b/linux-user/main.c
@@ -3539,7 +3539,11 @@ static void handle_arg_stack_size(const char *arg)
 
 static void handle_arg_ld_prefix(const char *arg)
 {
+    char *buf = g_strdup_printf("QEMU_LD_PREFIX=%s", arg);
+
     interp_prefix = strdup(arg);
+    (void) envlist_setenv(envlist, buf);
+    g_free(buf);
 }
 
 static void handle_arg_pagesize(const char *arg)
-- 
1.9.1

^ permalink raw reply related	[flat|nested] 9+ messages in thread

* Re: [Qemu-devel] [PATCH] linux-user/main.c: Always set QEMU_LD_PREFIX when interp_prefix is changed
  2015-09-10  5:43 [Qemu-devel] [PATCH] linux-user/main.c: Always set QEMU_LD_PREFIX when interp_prefix is changed gang.chen.5i5j
@ 2015-09-10  5:49 ` Chen Gang
       [not found] ` <55F119DE.2030507@hotmail.com>
  2015-09-10  9:02 ` Peter Maydell
  2 siblings, 0 replies; 9+ messages in thread
From: Chen Gang @ 2015-09-10  5:49 UTC (permalink / raw)
  To: riku.voipio; +Cc: peter.maydell, qemu-devel, rth

On 2015年09月10日 13:43, gang.chen.5i5j@gmail.com wrote:
> From: Chen Gang <gang.chen.5i5j@gmail.com>
> 
> If qemu sets interp_prfix via command line '-L' instead of environments
> variable QEMU_LD_PREFIX, it will cause syscall execve() failed. Because
> the 2nd qemu has no command line '-L'.
> 

Oh, sorry for typo, "the 2nd" -> "the second".

> So qemu need always set QEMU_LD_PREFIX when interp_prefix is changed.
> 
> Signed-off-by: Chen Gang <gang.chen.5i5j@gmail.com>


Thanks.
-- 
Chen Gang

Open, share, and attitude like air, water, and life which God blessed

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [Qemu-devel] [PATCH] linux-user/main.c: Always set QEMU_LD_PREFIX when interp_prefix is changed
       [not found] ` <55F119DE.2030507@hotmail.com>
@ 2015-09-10  7:50   ` Chen Gang
  0 siblings, 0 replies; 9+ messages in thread
From: Chen Gang @ 2015-09-10  7:50 UTC (permalink / raw)
  To: Riku Voipio; +Cc: Peter Maydell, qemu-devel, rth

Oh, this issue may be for all command lines (e.g. -d option), I  guess, we need
process them all in main() when process command line options.

----------------------------------------
> Subject: Re: [PATCH] linux-user/main.c: Always set QEMU_LD_PREFIX when interp_prefix is changed
> To: riku.voipio@iki.fi
> CC: rth@twiddle.net; peter.maydell@linaro.org; qemu-devel@nongnu.org
> From: xili_gchen_5257@hotmail.com
> Date: Thu, 10 Sep 2015 13:49:18 +0800
>
> On 2015年09月10日 13:43, gang.chen.5i5j@gmail.com wrote:
>> From: Chen Gang <gang.chen.5i5j@gmail.com>
>>
>> If qemu sets interp_prfix via command line '-L' instead of environments
>> variable QEMU_LD_PREFIX, it will cause syscall execve() failed. Because
>> the 2nd qemu has no command line '-L'.
>>
>
> Oh, sorry for typo, "the 2nd" -> "the second".
>
>> So qemu need always set QEMU_LD_PREFIX when interp_prefix is changed.
>>
>> Signed-off-by: Chen Gang <gang.chen.5i5j@gmail.com>
>
>
> Thanks.
> --
> Chen Gang
>
> Open, share, and attitude like air, water, and life which God blessed
 		 	   		  

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [Qemu-devel] [PATCH] linux-user/main.c: Always set QEMU_LD_PREFIX when interp_prefix is changed
  2015-09-10  5:43 [Qemu-devel] [PATCH] linux-user/main.c: Always set QEMU_LD_PREFIX when interp_prefix is changed gang.chen.5i5j
  2015-09-10  5:49 ` Chen Gang
       [not found] ` <55F119DE.2030507@hotmail.com>
@ 2015-09-10  9:02 ` Peter Maydell
  2015-09-10  9:32   ` Chen Gang
  2 siblings, 1 reply; 9+ messages in thread
From: Peter Maydell @ 2015-09-10  9:02 UTC (permalink / raw)
  To: Chen Gang; +Cc: Riku Voipio, QEMU Developers, Chen Gang, Richard Henderson

On 10 September 2015 at 06:43,  <gang.chen.5i5j@gmail.com> wrote:
> From: Chen Gang <gang.chen.5i5j@gmail.com>
>
> If qemu sets interp_prfix via command line '-L' instead of environments
> variable QEMU_LD_PREFIX, it will cause syscall execve() failed. Because
> the 2nd qemu has no command line '-L'.
>
> So qemu need always set QEMU_LD_PREFIX when interp_prefix is changed.

I think this is user error. If you want exec to work automatically
onto a second QEMU then you need to set up binfmt misc with a
wrapper and probably the environment variables. I don't
think we need to turn all our command line switches into
environment variables: they're not supposed to be somehow
magically inherited by child QEMU processes.

thanks
-- PMM

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [Qemu-devel] [PATCH] linux-user/main.c: Always set QEMU_LD_PREFIX when interp_prefix is changed
  2015-09-10  9:02 ` Peter Maydell
@ 2015-09-10  9:32   ` Chen Gang
  2015-09-10 12:35     ` Peter Maydell
  0 siblings, 1 reply; 9+ messages in thread
From: Chen Gang @ 2015-09-10  9:32 UTC (permalink / raw)
  To: Peter Maydell, gang.chen.5i5j; +Cc: Riku Voipio, qemu-devel, rth

From: peter.maydell@linaro.org
> Date: Thu, 10 Sep 2015 10:02:27 +0100
>
> On 10 September 2015 at 06:43, <gang.chen.5i5j@gmail.com> wrote:
>> From: Chen Gang <gang.chen.5i5j@gmail.com>
>>
>> If qemu sets interp_prfix via command line '-L' instead of environments
>> variable QEMU_LD_PREFIX, it will cause syscall execve() failed. Because
>> the 2nd qemu has no command line '-L'.
>>
>> So qemu need always set QEMU_LD_PREFIX when interp_prefix is changed.
>
> I think this is user error. If you want exec to work automatically
> onto a second QEMU then you need to set up binfmt misc with a
> wrapper and probably the environment variables. I don't
> think we need to turn all our command line switches into
> environment variables: they're not supposed to be somehow
> magically inherited by child QEMU processes.
>

For me, when users type a command line under Linux shell, they always
assume all related executions will know about their commands, they need
not set the environments again (at least, in one process, they assume so).

execve() will not change the pid, so the users will 'feel': they are using only
one process.

I guess all 'users' will support me (this patch will let them a little easier). ;-)


Thanks.
--
Chen Gang

Open, share, and attitude like air, water, and life which God blessed


 		 	   		  

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [Qemu-devel] [PATCH] linux-user/main.c: Always set QEMU_LD_PREFIX when interp_prefix is changed
  2015-09-10  9:32   ` Chen Gang
@ 2015-09-10 12:35     ` Peter Maydell
  2015-09-10 15:15       ` Chen Gang
  0 siblings, 1 reply; 9+ messages in thread
From: Peter Maydell @ 2015-09-10 12:35 UTC (permalink / raw)
  To: Chen Gang; +Cc: qemu-devel, Riku Voipio, gang.chen.5i5j, rth

On 10 September 2015 at 10:32, Chen Gang <xili_gchen_5257@hotmail.com> wrote:
> From: peter.maydell@linaro.org
>> Date: Thu, 10 Sep 2015 10:02:27 +0100
>>
>> On 10 September 2015 at 06:43, <gang.chen.5i5j@gmail.com> wrote:
>>> From: Chen Gang <gang.chen.5i5j@gmail.com>
>>>
>>> If qemu sets interp_prfix via command line '-L' instead of environments
>>> variable QEMU_LD_PREFIX, it will cause syscall execve() failed. Because
>>> the 2nd qemu has no command line '-L'.
>>>
>>> So qemu need always set QEMU_LD_PREFIX when interp_prefix is changed.
>>
>> I think this is user error. If you want exec to work automatically
>> onto a second QEMU then you need to set up binfmt misc with a
>> wrapper and probably the environment variables. I don't
>> think we need to turn all our command line switches into
>> environment variables: they're not supposed to be somehow
>> magically inherited by child QEMU processes.
>>
>
> For me, when users type a command line under Linux shell, they always
> assume all related executions will know about their commands, they need
> not set the environments again (at least, in one process, they assume so).
>
> execve() will not change the pid, so the users will 'feel': they are using only
> one process.

But execve won't do the right thing if it's another target binary,
unless you've set up binfmt_misc. And if you're setting up
binfmt_misc then (a) you should just do it right and (b) you
wouldn't have been directly running QEMU with command line
arguments in the first place.

I really don't think we need to change anything here.

thanks
-- PMM

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [Qemu-devel] [PATCH] linux-user/main.c: Always set QEMU_LD_PREFIX when interp_prefix is changed
  2015-09-10 12:35     ` Peter Maydell
@ 2015-09-10 15:15       ` Chen Gang
  2015-09-10 15:24         ` Peter Maydell
  0 siblings, 1 reply; 9+ messages in thread
From: Chen Gang @ 2015-09-10 15:15 UTC (permalink / raw)
  To: Peter Maydell; +Cc: qemu-devel, Riku Voipio, gang.chen.5i5j, rth

On 9/10/15 20:35, Peter Maydell wrote:
> On 10 September 2015 at 10:32, Chen Gang <xili_gchen_5257@hotmail.com> wrote:
>>
>> For me, when users type a command line under Linux shell, they always
>> assume all related executions will know about their commands, they need
>> not set the environments again (at least, in one process, they assume so).
>>
>> execve() will not change the pid, so the users will 'feel': they are using only
>> one process.
> 
> But execve won't do the right thing if it's another target binary,
> unless you've set up binfmt_misc. And if you're setting up
> binfmt_misc then (a) you should just do it right and (b) you
> wouldn't have been directly running QEMU with command line
> arguments in the first place.
> 

Yes, we have to use binfmt_misc to let execve() run correctly. After
let execve() run correctly, I am analyzing another issue when let qemu
run wine (it is a pending issue, I guess, it is related with mmu).

At present, I often change the input parameters (e.g. -strace, -d ...),
if we let a qemu process itself always know about its input parameters,
it will be really useful.

For qemu, I still feel that we need notice about the mismatch between
env variables and input parameters.

 - If we are sure the input parameters are only for one normal process,
   we need not care about the mismatch between env variables and input
   parameters (I guess, most of programs need not care about it).

 - But if we have to process the un-normal process (e.g. our qemu), we
   have to notice about the mismatch between evn variables and input
   parameters. Or command line users may meet various strange things.

 - Since we provide the command line options, we have to always let them
   be correct within one normal or un-normal process.


Thanks
-- 
Chen Gang (陈刚)

Open, share, and attitude like air, water, and life which God blessed

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [Qemu-devel] [PATCH] linux-user/main.c: Always set QEMU_LD_PREFIX when interp_prefix is changed
  2015-09-10 15:15       ` Chen Gang
@ 2015-09-10 15:24         ` Peter Maydell
  2015-09-10 15:45           ` Chen Gang
  0 siblings, 1 reply; 9+ messages in thread
From: Peter Maydell @ 2015-09-10 15:24 UTC (permalink / raw)
  To: Chen Gang; +Cc: qemu-devel, Riku Voipio, gang.chen.5i5j, rth

On 10 September 2015 at 16:15, Chen Gang <xili_gchen_5257@hotmail.com> wrote:
> Yes, we have to use binfmt_misc to let execve() run correctly. After
> let execve() run correctly, I am analyzing another issue when let qemu
> run wine (it is a pending issue, I guess, it is related with mmu).
>
> At present, I often change the input parameters (e.g. -strace, -d ...),
> if we let a qemu process itself always know about its input parameters,
> it will be really useful.

If you want settings to apply to all child qemu processes, use the
environment variables... that is one of the things they are for.

> For qemu, I still feel that we need notice about the mismatch between
> env variables and input parameters.
>
>  - If we are sure the input parameters are only for one normal process,
>    we need not care about the mismatch between env variables and input
>    parameters (I guess, most of programs need not care about it).
>
>  - But if we have to process the un-normal process (e.g. our qemu), we
>    have to notice about the mismatch between evn variables and input
>    parameters. Or command line users may meet various strange things.
>
>  - Since we provide the command line options, we have to always let them
>    be correct within one normal or un-normal process.

I think it would be unexpected behaviour for command line arguments
provided to one QEMU program to affect the execution of a different
QEMU process.

thanks
-- PMM

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [Qemu-devel] [PATCH] linux-user/main.c: Always set QEMU_LD_PREFIX when interp_prefix is changed
  2015-09-10 15:24         ` Peter Maydell
@ 2015-09-10 15:45           ` Chen Gang
  0 siblings, 0 replies; 9+ messages in thread
From: Chen Gang @ 2015-09-10 15:45 UTC (permalink / raw)
  To: Peter Maydell; +Cc: qemu-devel, Riku Voipio, gang.chen.5i5j, rth

On 9/10/15 23:24, Peter Maydell wrote:
> On 10 September 2015 at 16:15, Chen Gang <xili_gchen_5257@hotmail.com> wrote:
>> Yes, we have to use binfmt_misc to let execve() run correctly. After
>> let execve() run correctly, I am analyzing another issue when let qemu
>> run wine (it is a pending issue, I guess, it is related with mmu).
>>
>> At present, I often change the input parameters (e.g. -strace, -d ...),
>> if we let a qemu process itself always know about its input parameters,
>> it will be really useful.
> 
> If you want settings to apply to all child qemu processes, use the
> environment variables... that is one of the things they are for.
> 

Yes it will be work well. :-)

>> For qemu, I still feel that we need notice about the mismatch between
>> env variables and input parameters.
>>
>>  - If we are sure the input parameters are only for one normal process,
>>    we need not care about the mismatch between env variables and input
>>    parameters (I guess, most of programs need not care about it).
>>
>>  - But if we have to process the un-normal process (e.g. our qemu), we
>>    have to notice about the mismatch between evn variables and input
>>    parameters. Or command line users may meet various strange things.
>>
>>  - Since we provide the command line options, we have to always let them
>>    be correct within one normal or un-normal process.
> 
> I think it would be unexpected behaviour for command line arguments
> provided to one QEMU program to affect the execution of a different
> QEMU process.
> 

For me, I guess, it should be still OK:

 - For execve(), the input parameters should always have effect with (
   since we treate it as one un-normal process).

 - For other QEMU cases (really different QEMU child processes).

   If they have their own command line options, the will override the
   env variables which may be set by original command line parameters.

   If they have no their own command line options, they need inherit the
   parent QEMU process's command line options (e.g. -strace, -d ...).


Thanks.
-- 
Chen Gang (陈刚)

Open, share, and attitude like air, water, and life which God blessed

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2015-09-10 15:43 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-09-10  5:43 [Qemu-devel] [PATCH] linux-user/main.c: Always set QEMU_LD_PREFIX when interp_prefix is changed gang.chen.5i5j
2015-09-10  5:49 ` Chen Gang
     [not found] ` <55F119DE.2030507@hotmail.com>
2015-09-10  7:50   ` Chen Gang
2015-09-10  9:02 ` Peter Maydell
2015-09-10  9:32   ` Chen Gang
2015-09-10 12:35     ` Peter Maydell
2015-09-10 15:15       ` Chen Gang
2015-09-10 15:24         ` Peter Maydell
2015-09-10 15:45           ` Chen Gang

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.