* [Qemu-devel] [PATCH] add QEMU_LD_PREFIX environment variable
@ 2011-07-06 9:15 Johannes Schauer
2011-07-06 9:15 ` Johannes Schauer
0 siblings, 1 reply; 8+ messages in thread
From: Johannes Schauer @ 2011-07-06 9:15 UTC (permalink / raw)
To: qemu-devel; +Cc: Johannes Schauer
Hi,
qemu allows to specify the elf interpreter prefix with the -L option. When
using qemu user mode emulation through the binfmt mechanism, it is not
possible to pass any commandline arguments to qemu. Having qemu evaluate an
environment variable makes it possible to still supply a custom elf
interpreter prefix, even if qemu is executed by the binfmt mechanism.
My motivation is an emdebian project which creates foreign debian
bootstraps. Since foreign binaries are executed without an explicit
qemu-user call but by the binfmt mechanism, it relied on having appropriate
content in /etc/qemu-binfmt/$arch/ which is the default elf interpreter
prefix path on debian. The downside currently is, that the shared libraries
in /etc/qemu-binfmt/$arch/ have to be adapted very often for different
debian systems running on the same qemu $arch. This could be avoided by
setting the proposed environment variable QEMU_LD_PREFIX to the just
created debian rootfs. As mentioned earlier, the usage of the -L option
is not possible in this scenario because qemu-user is only implicitly
called by the binfmt mechanism.
Hopefully this change can be applied.
thanks!
cheers, josch
Johannes Schauer (1):
add QEMU_LD_PREFIX environment variable
linux-user/main.c | 5 +++++
1 files changed, 5 insertions(+), 0 deletions(-)
--
1.7.5.4
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Qemu-devel] [PATCH] add QEMU_LD_PREFIX environment variable
@ 2011-07-23 5:47 josch
2011-07-23 5:47 ` josch
2011-07-28 8:41 ` Riku Voipio
0 siblings, 2 replies; 8+ messages in thread
From: josch @ 2011-07-23 5:47 UTC (permalink / raw)
To: Riku Voipio, qemu-devel; +Cc: Johannes Schauer
From: Johannes Schauer <j.schauer@email.de>
Hi,
qemu allows to specify the elf interpreter prefix with the -L option. When
using qemu user mode emulation through the binfmt mechanism, it is not
possible to pass any commandline arguments to qemu. Having qemu evaluate an
environment variable makes it possible to still supply a custom elf
interpreter prefix, even if qemu is executed by the binfmt mechanism.
My motivation is an emdebian project which creates foreign debian
bootstraps. Since foreign binaries are executed without an explicit
qemu-user call but by the binfmt mechanism, it relied on having appropriate
content in /etc/qemu-binfmt/$arch/ which is the default elf interpreter
prefix path on debian. The downside currently is, that the shared libraries
in /etc/qemu-binfmt/$arch/ have to be adapted very often for different
debian systems running on the same qemu $arch. This could be avoided by
setting the proposed environment variable QEMU_LD_PREFIX to the just
created debian rootfs. As mentioned earlier, the usage of the -L option
is not possible in this scenario because qemu-user is only implicitly
called by the binfmt mechanism.
Hopefully this change can be applied.
thanks!
cheers, josch
Johannes Schauer (1):
add QEMU_LD_PREFIX environment variable
linux-user/main.c | 5 +++++
1 files changed, 5 insertions(+), 0 deletions(-)
--
1.7.5.4
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Qemu-devel] [PATCH] add QEMU_LD_PREFIX environment variable
2011-07-23 5:47 josch
@ 2011-07-23 5:47 ` josch
2011-07-28 8:41 ` Riku Voipio
1 sibling, 0 replies; 8+ messages in thread
From: josch @ 2011-07-23 5:47 UTC (permalink / raw)
To: Riku Voipio, qemu-devel; +Cc: Johannes Schauer
From: Johannes Schauer <j.schauer@email.de>
Signed-off-by: Johannes Schauer <j.schauer@email.de>
---
linux-user/main.c | 5 +++++
1 files changed, 5 insertions(+), 0 deletions(-)
diff --git a/linux-user/main.c b/linux-user/main.c
index 289054b..b590aa7 100644
--- a/linux-user/main.c
+++ b/linux-user/main.c
@@ -2891,6 +2891,11 @@ int main(int argc, char **argv, char **envp)
cpudef_setup(); /* parse cpu definitions in target config file (TBD) */
#endif
+ /* read interp_prefix from environment variable */
+ if (getenv("QEMU_LD_PREFIX") != NULL) {
+ interp_prefix = getenv("QEMU_LD_PREFIX");
+ }
+
optind = 1;
for(;;) {
if (optind >= argc)
--
1.7.5.4
^ permalink raw reply related [flat|nested] 8+ messages in thread
* Re: [Qemu-devel] [PATCH] add QEMU_LD_PREFIX environment variable
2011-07-23 5:47 josch
2011-07-23 5:47 ` josch
@ 2011-07-28 8:41 ` Riku Voipio
2011-07-28 11:24 ` Johannes Schauer
1 sibling, 1 reply; 8+ messages in thread
From: Riku Voipio @ 2011-07-28 8:41 UTC (permalink / raw)
To: josch; +Cc: stappers, Riku Voipio, qemu-devel, Johannes Schauer, 632192
On Sat, Jul 23, 2011 at 07:47:49AM +0200, josch wrote:
> This could be avoided by setting the proposed environment variable
> QEMU_LD_PREFIX to the just
> created debian rootfs. As mentioned earlier, the usage of the -L option
> is not possible in this scenario because qemu-user is only implicitly
> called by the binfmt mechanism.
What worries me here is that we are beginning to add a enviroment variable
for each and every command line option of qemu linux-user. I think it would
be better to have a wrapper binary to be registered as the binfmt runner.
Alternatively we should have a generic setup for mapping enviroment variables
to command line options. Now we get special per-option code every time someone
needs to setup a command line option from binfmt.
Riku
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [Qemu-devel] [PATCH] add QEMU_LD_PREFIX environment variable
2011-07-28 8:41 ` Riku Voipio
@ 2011-07-28 11:24 ` Johannes Schauer
2011-07-28 16:50 ` Geert Stappers
0 siblings, 1 reply; 8+ messages in thread
From: Johannes Schauer @ 2011-07-28 11:24 UTC (permalink / raw)
To: Riku Voipio; +Cc: stappers, 632192, qemu-devel, josch
Hi,
On Thu, Jul 28, 2011 at 11:41:09AM +0300, Riku Voipio wrote:
> On Sat, Jul 23, 2011 at 07:47:49AM +0200, josch wrote:
> > This could be avoided by setting the proposed environment variable
> > QEMU_LD_PREFIX to the just
> > created debian rootfs. As mentioned earlier, the usage of the -L option
> > is not possible in this scenario because qemu-user is only implicitly
> > called by the binfmt mechanism.
>
> What worries me here is that we are beginning to add a enviroment
> variable for each and every command line option of qemu linux-user.
Are there other environment variables? I didnt see any? (well besides
QEMU_STRACE that is)
> I think it would be better to have a wrapper binary to be registered
> as the binfmt runner.
If you need help with writing something - dont hesitate to ask for help.
I'm very interested in having this functionality working because of the
reasons I gave in my initial mail. [1]
> Alternatively we should have a generic setup for mapping enviroment
> variables to command line options. Now we get special per-option code
> every time someone needs to setup a command line option from binfmt.
What other options are there that would be interesting for binfmt?
I was also sending this patch to qemu-devel list a month ago but got no
reply. [2]
As I said - if you would like a wrapper or a generic setup for mapping
env variables to commandline parameters and dont have time to do it
yourself, dont hesitate to delegate some work to me :)
@Geert Stappers:
you are patching bsd-user/main.c and darwin-user/main.c as well. I take
it that you did test your changes on those platforms? does it work there
as well? I have no clue of darwin but is it really useful there?
cheers, josch
[1] http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=632192#5
[2] http://lists.nongnu.org/archive/html/qemu-devel/2011-07/msg00459.html
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [Qemu-devel] [PATCH] add QEMU_LD_PREFIX environment variable
2011-07-28 11:24 ` Johannes Schauer
@ 2011-07-28 16:50 ` Geert Stappers
2011-07-28 17:28 ` Alexander Graf
0 siblings, 1 reply; 8+ messages in thread
From: Geert Stappers @ 2011-07-28 16:50 UTC (permalink / raw)
To: Johannes Schauer, Riku Voipio, josch, qemu-devel, stappers,
632192
On Thu, Jul 28, 2011 at 01:24:47PM +0200, Johannes Schauer wrote:
>
> @Geert Stappers:
>
> you are patching bsd-user/main.c and darwin-user/main.c as well. I take
> it that you did test your changes on those platforms? does it work there
> as well? I have no clue of darwin but is it really useful there?
They only check I did,
was checking if BSD and Darwing have getenv(), they do.
I consider the
+ /* read interp_prefix from environment variable */
+ if (getenv("QEMU_LD_PREFIX") != NULL) {
+ interp_prefix = getenv("QEMU_LD_PREFIX");
to Darwin and BSD as harmless. In fact only reason for those additional
lines were to bring attention to those operating systems.
With the idea^Whope of better acception from upstream.
Cheers
Geert Stappers
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [Qemu-devel] [PATCH] add QEMU_LD_PREFIX environment variable
2011-07-28 16:50 ` Geert Stappers
@ 2011-07-28 17:28 ` Alexander Graf
0 siblings, 0 replies; 8+ messages in thread
From: Alexander Graf @ 2011-07-28 17:28 UTC (permalink / raw)
To: Geert Stappers; +Cc: 632192, Riku Voipio, qemu-devel, Johannes Schauer, josch
On 28.07.2011, at 18:50, Geert Stappers wrote:
> On Thu, Jul 28, 2011 at 01:24:47PM +0200, Johannes Schauer wrote:
>>
>> @Geert Stappers:
>>
>> you are patching bsd-user/main.c and darwin-user/main.c as well. I take
>> it that you did test your changes on those platforms? does it work there
>> as well? I have no clue of darwin but is it really useful there?
>
> They only check I did,
> was checking if BSD and Darwing have getenv(), they do.
>
> I consider the
> + /* read interp_prefix from environment variable */
> + if (getenv("QEMU_LD_PREFIX") != NULL) {
> + interp_prefix = getenv("QEMU_LD_PREFIX");
> to Darwin and BSD as harmless. In fact only reason for those additional
> lines were to bring attention to those operating systems.
It's called DYLD_PRELOAD on Darwin :). However, I do think that if anything this should be an alias, so you can set either of the two. If anyone cares about darwin-user at all.
Alex
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2011-07-28 17:28 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-07-06 9:15 [Qemu-devel] [PATCH] add QEMU_LD_PREFIX environment variable Johannes Schauer
2011-07-06 9:15 ` Johannes Schauer
-- strict thread matches above, loose matches on Subject: below --
2011-07-23 5:47 josch
2011-07-23 5:47 ` josch
2011-07-28 8:41 ` Riku Voipio
2011-07-28 11:24 ` Johannes Schauer
2011-07-28 16:50 ` Geert Stappers
2011-07-28 17:28 ` Alexander Graf
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).