Skip to contentSkip to conversation

Add new user mode option -ignore-environment

PATCH In review Stefan Weil 4 participants 13 messages Jul 15, 2010 – Sep 10, 2010

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Add new user mode option -ignore-environment

An empty environment is sometimes useful in user mode. The new option provides it for linux-user and bsd-user (darwin-user still has no environment related options).

The patch also adds the documentation for other
environment related options.

---
 bsd-user/main.c   |    6 ++++++
 linux-user/main.c |    6 ++++++
 qemu-doc.texi     |   14 ++++++++++++++
 3 files changed, 26 insertions(+), 0 deletions(-)
bsd-user/main.c +6 -0
index aff9f13..6b12f8b 100644
@@ -795,6 +795,12 @@ int main(int argc, char **argv)
             r = argv[optind++];
             if (envlist_setenv(envlist, r) != 0)
                 usage();
+        } else if (!strcmp(r, "ignore-environment")) {
+            envlist_free(envlist);
+            if ((envlist = envlist_create()) == NULL) {
+                (void) fprintf(stderr, "Unable to allocate envlist\n");
+                exit(1);
+            }
         } else if (!strcmp(r, "U")) {
             r = argv[optind++];
             if (envlist_unsetenv(envlist, r) != 0)
linux-user/main.c +6 -0
index 403c8d3..bf60922 100644
@@ -2759,6 +2759,12 @@ int main(int argc, char **argv, char **envp)
             r = argv[optind++];
             if (envlist_setenv(envlist, r) != 0)
                 usage();
+        } else if (!strcmp(r, "ignore-environment")) {
+            envlist_free(envlist);
+            if ((envlist = envlist_create()) == NULL) {
+                (void) fprintf(stderr, "Unable to allocate envlist\n");
+                exit(1);
+            }
         } else if (!strcmp(r, "U")) {
             r = argv[optind++];
             if (envlist_unsetenv(envlist, r) != 0)
qemu-doc.texi +14 -0
index e67bf44..ec7820e 100644
@@ -2136,6 +2136,13 @@ Set the x86 elf interpreter prefix (default=/usr/local/qemu-i386)
 Set the x86 stack size in bytes (default=524288)
 @item -cpu model
 Select CPU model (-cpu ? for list and additional feature selection)
+@item -ignore-environment
+Start with an empty environment. Without this option,
+the inital environment is a copy of the caller's environment.
+@item -E @var{var}=@var{value}
+Set environment @var{var} to @var{value}.
+@item -U @var{var}
+Remove @var{var} from the environment.
 @item -B offset
 Offset guest address by the specified number of bytes.  This is useful when
 the address region required by guest applications is reserved on the host.
@@ -2359,6 +2366,13 @@ Print the help
 Set the library root path (default=/)
 @item -s size
 Set the stack size in bytes (default=524288)
+@item -ignore-environment
+Start with an empty environment. Without this option,
+the inital environment is a copy of the caller's environment.
+@item -E @var{var}=@var{value}
+Set environment @var{var} to @var{value}.
+@item -U @var{var}
+Remove @var{var} from the environment.
 @item -bsd type
 Set the type of the emulated BSD Operating system. Valid values are
 FreeBSD, NetBSD and OpenBSD (default).
Signature · 1 line
1.7.1
#1 lore raw
Quoted 3 lines · Stefan Weil

An empty environment is sometimes useful in user mode. The new option provides it for linux-user and bsd-user (darwin-user still has no environment related options).

Stupid question: why is /usr/bin/env insufficient?

[...]

#2 lore raw

Am 16.07.2010 09:04, schrieb Markus Armbruster:

Quoted 12 lines
Quoted 4 lines · Stefan Weil

An empty environment is sometimes useful in user mode. The new option provides it for linux-user and bsd-user (darwin-user still has no environment related options).

Stupid question: why is /usr/bin/env insufficient?

[...]

In most cases it is sufficient (but not always available - Windows...). The options -U and -E are also redundant and can be replaced by /usr/bin/env.

But -U and -E exist, so completing the set of environment related options seems to be logical. The name of the new option was inspired by /usr/bin/env!

And finally, there is a use case where /usr/bin/env is a bad choice:
just look for "getenv" and you will find one in linux-user/main.c. Removing the environment via /usr/bin/env will also remove environment variables which are read by qemu's runtime code.

#3 lore raw

Am 16.07.2010 15:09, schrieb Stefan Weil:

Quoted 15 lines

Am 16.07.2010 09:04, schrieb Markus Armbruster:

Quoted 9 lines
Quoted 3 lines · Stefan Weil

An empty environment is sometimes useful in user mode. The new option provides it for linux-user and bsd-user (darwin-user still has no environment related options).

Stupid question: why is /usr/bin/env insufficient?

[...]

In most cases it is sufficient (but not always available - Windows...). The options -U and -E are also redundant and can be replaced by /usr/bin/env.

Quoted 8 lines

But -U and -E exist, so completing the set of environment related options seems to be logical. The name of the new option was inspired by /usr/bin/env!

And finally, there is a use case where /usr/bin/env is a bad choice:
just look for "getenv" and you will find one in linux-user/main.c. Removing the environment via /usr/bin/env will also remove environment variables which are read by qemu's runtime code.

Is there any more feedback on this patch?
Or can it be commited to git master?

#4 lore raw

Am 01.08.2010 13:48, schrieb Stefan Weil:

Quoted 20 lines

Am 16.07.2010 15:09, schrieb Stefan Weil:

Quoted 19 lines

Am 16.07.2010 09:04, schrieb Markus Armbruster:

Quoted 9 lines
Quoted 3 lines · Stefan Weil

An empty environment is sometimes useful in user mode. The new option provides it for linux-user and bsd-user (darwin-user still has no environment related options).

Stupid question: why is /usr/bin/env insufficient?

[...]

In most cases it is sufficient (but not always available - Windows...). The options -U and -E are also redundant and can be replaced by /usr/bin/env.

But -U and -E exist, so completing the set of environment related options seems to be logical. The name of the new option was inspired by /usr/bin/env!

Quoted 8 lines
Quoted 4 lines

And finally, there is a use case where /usr/bin/env is a bad choice:
just look for "getenv" and you will find one in linux-user/main.c. Removing the environment via /usr/bin/env will also remove environment variables which are read by qemu's runtime code.

Is there any more feedback on this patch?
Or can it be commited to git master?

Ping? The patch is still missing.

Regards,
Stefan

#5 lore raw
In reply to Markus Armbruster

Am 16.07.2010 09:04, schrieb Markus Armbruster:

Quoted 11 lines
Quoted 4 lines · Stefan Weil

An empty environment is sometimes useful in user mode. The new option provides it for linux-user and bsd-user (darwin-user still has no environment related options).

Stupid question: why is /usr/bin/env insufficient?

[...]

Hi Markus,

was your question answered (and can Antony commit this change to QEMU master)?

Regards
Stefan

#6 lore raw
Quoted 6 lines · Stefan Weil

Am 16.07.2010 09:04, schrieb Markus Armbruster:

Quoted 5 lines
Quoted 3 lines · Stefan Weil

An empty environment is sometimes useful in user mode. The new option provides it for linux-user and bsd-user (darwin-user still has no environment related options).

Quoted 7 lines
Quoted 3 lines

Stupid question: why is /usr/bin/env insufficient?

[...]

Hi Markus,

was your question answered (and can Antony commit this change to QEMU master)?

Riku is the linux-user maintainer so it really ought to go through his tree.

Regards,

Anthony Liguori

Quoted 4 lines

Regards
Stefan

#7 lore raw

PATCH 1/1 MAINTAINERS: Add new maintainer for Linux user

According to Antony, Riku is the maintainer for Linux user, so make this visible for everyone.

(The patch also fixes a whitespace issue at end of line - required by git and by my editor).

Cc Riku Voipio <[email protected]>
Cc Antony Liguori <[email protected]>
---
 MAINTAINERS |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)
MAINTAINERS +2 -2
index e5165fb..63deb87 100644
@@ -68,7 +68,7 @@ S390
   s390-*.c                Alexander Graf
 
 Generic Subsystems:
--------------------  
+-------------------
 
 Dynamic translator        Fabrice Bellard
 Main loop                 Fabrice Bellard (new maintainer needed)
@@ -83,6 +83,6 @@ Audio device layer        Vassili Karpov (malc)
 Character device layer    ?
 Network device layer      ?
 GDB stub                  ?
-Linux user                ?
+Linux user                Riku Voipio
 Darwin user               ?
 SLIRP                     ?
Signature · 1 line
1.7.1
Acked-by on v1 1/1
#8 lore raw

Re: [Qemu-devel] [PATCH] MAINTAINERS: Add new maintainer for Linux user

Am 09.09.2010 um 21:32 schrieb Stefan Weil:

Quoted 2 lines

According to Antony, Riku is the maintainer for Linux user, so make this visible for everyone.

You beat me! :)

Andreas

Quoted 6 lines

(The patch also fixes a whitespace issue at end of line - required by git and by my editor).

Cc Riku Voipio <[email protected]>
Cc Antony Liguori <[email protected]>

P.S. It's Anthony.

#9 lore raw

Re: [Qemu-devel] [PATCH] MAINTAINERS: Add new maintainer for Linux user

Am 09.09.2010 21:43, schrieb Andreas Färber:

Quoted 11 lines

Am 09.09.2010 um 21:32 schrieb Stefan Weil:

Quoted 2 lines

According to Antony, Riku is the maintainer for Linux user, so make this visible for everyone.

You beat me! :)

Andreas

Quoted 8 lines
Quoted 6 lines

(The patch also fixes a whitespace issue at end of line - required by git and by my editor).

Cc Riku Voipio <[email protected]>
Cc Antony Liguori <[email protected]>

P.S. It's Anthony.

Sorry, Anthony. Thanks, Andreas, for the hint. I'll sent a new patch which corrects this important issue.

Stefan

#10 lore raw

PATCH 1/1 MAINTAINERS: Add new maintainer for Linux user

According to Anthony, Riku is the maintainer for Linux user, so make this visible for everyone.

(The patch also fixes a whitespace issue at end of line - required by git and by my editor).

Cc Riku Voipio <[email protected]>
Cc Anthony Liguori <[email protected]>
---
 MAINTAINERS |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)
MAINTAINERS +2 -2
index e5165fb..63deb87 100644
@@ -68,7 +68,7 @@ S390
   s390-*.c                Alexander Graf
 
 Generic Subsystems:
--------------------  
+-------------------
 
 Dynamic translator        Fabrice Bellard
 Main loop                 Fabrice Bellard (new maintainer needed)
@@ -83,6 +83,6 @@ Audio device layer        Vassili Karpov (malc)
 Character device layer    ?
 Network device layer      ?
 GDB stub                  ?
-Linux user                ?
+Linux user                Riku Voipio
 Darwin user               ?
 SLIRP                     ?
Signature · 1 line
1.7.1
#11 lore raw

Re: [Qemu-devel] [PATCH] MAINTAINERS: Add new maintainer for Linux user

Quoted 10 lines · Stefan Weil

According to Anthony, Riku is the maintainer for Linux user, so make this visible for everyone.

(The patch also fixes a whitespace issue at end of line - required by git and by my editor).

Cc Riku Voipio<[email protected]>
Cc Anthony Liguori<[email protected]>

I've got mixed feelings about it, but let me take a stab at doing a more thorough update to MAINTAINERS. Comments appreciated.

Regards,

Anthony Liguori

Quoted 26 lines
---
  MAINTAINERS |    4 ++--
  1 files changed, 2 insertions(+), 2 deletions(-)
MAINTAINERS +2 -2
index e5165fb..63deb87 100644
@@ -68,7 +68,7 @@ S390
    s390-*.c                Alexander Graf
 
  Generic Subsystems:
--------------------
+-------------------
 
  Dynamic translator        Fabrice Bellard
  Main loop                 Fabrice Bellard (new maintainer needed)
@@ -83,6 +83,6 @@ Audio device layer        Vassili Karpov (malc)
  Character device layer    ?
  Network device layer      ?
  GDB stub                  ?
-Linux user                ?
+Linux user                Riku Voipio
  Darwin user               ?
  SLIRP                     ?
#12 lore raw
In reply to Stefan Weil
Quoted 10 lines · Stefan Weil

Am 16.07.2010 09:04, schrieb Markus Armbruster:

Quoted 9 lines
Quoted 4 lines · Stefan Weil

An empty environment is sometimes useful in user mode. The new option provides it for linux-user and bsd-user (darwin-user still has no environment related options).

Stupid question: why is /usr/bin/env insufficient?

Quoted 7 lines
Quoted 2 lines

[...]

Hi Markus,

was your question answered (and can Antony commit this change to QEMU master)?

I don't mind.