qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Laurent Vivier <laurent@vivier.eu>
To: Joel Holdsworth <joel.holdsworth@vcatechnology.com>,
	qemu-devel@nongnu.org
Cc: riku.voipio@iki.fi, Vasileios.Kalintiris@imgtec.com
Subject: Re: [Qemu-devel] [PATCH v2 2/4] linux-user: pass environment arguments in execve
Date: Mon, 20 Jun 2016 22:29:26 +0200	[thread overview]
Message-ID: <fbec165c-b1a8-c83b-a77c-bdd2fb6a7c3a@vivier.eu> (raw)
In-Reply-To: <57684939.3020207@vcatechnology.com>



Le 20/06/2016 à 21:51, Joel Holdsworth a écrit :
> On 15/06/16 20:59, Laurent Vivier wrote:
>>
>> Le 14/06/2016 à 21:26, Joel Holdsworth a écrit :
>>> Previously, when emulating execve(2), qemu would execute a child
>>> instance of the emulator with the environment variables provided by
>>> the parent process. This caused problems with qemu if any of the
>>> variables affected the child emulator's behaviour e.g.
>>> LD_LIBRARY_PATH.
>> The best way to avoid that is to use a statically linked qemu.
> 
> Stepping back a bit; the problem I'm trying to solve is this...
> 
> There are some processes that invoke a helper process to do some work
> for them e.g. gstreamer's gst-plugin-scanner. Previously qemu would
> attempt to execute the helper executable as if it were machine-native,
> which won't work. These patches modify qemu so that it will (optionally)
> run the child process inside a child instance of qemu.

If the context is to use qemu to have a cross build/test environment, I
like the idea, but you should use chroot/binfmt to do that.

Even without the architecture change, the build/test environment must be
isolated (chroot) from the host environment to know exactly what you
build/test.

> 
> My experience as a user was that it took a couple of hours of searching
> through strace logs to figure out what the issue was. gstreamer would
> just fail with a generic error about the helper. These patches are meant
> to make qemu do the right thing.
> 
> Saying to the user that they should make a static linked build of qemu
> isn't very practical. Having a command line argument is a much easier
> solution for the user, that doesn't force them not to used
> shared-library builds. The distros aren't going to go for that.

You can provide the RPM/DEB with the statically linked qemu.
(it will have no dependencies)

> Moreover, LD_LIBRARY_PATH is just one example. LD_PRELOAD is another.
> Timezone and locale environment variables are also an issue.

all LD_ are for the ld.so, the dynamic loader, and with a statically
linked qemu, you don't use the host ld.so (see ld.so(8)).

Why timezone and local environment variables are also an issue?

> In an ideal world, it wouldn't even be necessary to add an argument -
> qemu would just do the right thing automatically. Though I'm not sure
> how that could be done correctly, so a command line option is a good
> compromise for a starting point.
> 
> 
>>
>>> This patch solves this issue by passing the environment variables
>>> with '-E' arguments to the child qemu instance. The call to
>>> execve(2) is replaced by a call to execv(2) so that the parent
>>> emulator's environment variable state is propagated into the child.
>>>
>>> Any variables from the host environment that are not in the in the
>>> execve() call are removed with a '-U' argument.
>> Run ./scripts/checkpatch.pl on your patch...
>>
>> and add your Signed-off-by here.
> Sure ok.
> 
> 
>> The environment is already managed in linux-user/main.c:main(), I don't
>> understand why the qemu_execve() special case should differ from the
>> general case.
> Maybe I've missed something, but the problem I'm trying to solve here is
> the issue of correctly propagating the guest environment variables into
> the child process.
> 
> The parent guest process (running inside qemu-user) constructs a set of
> environment variables and passes them to execve. However, if the parent
> qemu-user decides to run a child instance of qemu-user it should run
> with the same environment variables as the parent, but with environment
> variables the parent-guest passed through the arguments for the
> child-guest.
> 
> If gstreamer decides to run gst-plugin-scanner with a certain environ,
> that is for the child qemu guest, not the child qemu instance itself.

Child qemu instance should just ignore it.

Thanks,
Laurent

  reply	other threads:[~2016-06-20 20:29 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-06-14 19:26 [Qemu-devel] linux-user: add option to intercept execve() syscalls Joel Holdsworth
2016-06-14 19:26 ` [Qemu-devel] [PATCH v2 1/4] " Joel Holdsworth
2016-06-15 19:31   ` Laurent Vivier
2016-06-20 20:04     ` Joel Holdsworth
2016-06-14 19:26 ` [Qemu-devel] [PATCH v2 2/4] linux-user: pass environment arguments in execve Joel Holdsworth
2016-06-15 19:59   ` Laurent Vivier
2016-06-20 19:51     ` Joel Holdsworth
2016-06-20 20:29       ` Laurent Vivier [this message]
2016-06-20 21:27         ` Joel Holdsworth
2016-06-20 21:40           ` Peter Maydell
2016-06-20 22:15             ` Joel Holdsworth
2016-06-20 22:54               ` Peter Maydell
2016-06-14 19:26 ` [Qemu-devel] [PATCH v2 3/4] linux-user: pass elf interpreter prefix " Joel Holdsworth
2016-06-15 20:06   ` Laurent Vivier
2016-06-20 19:57     ` Joel Holdsworth
2016-06-14 19:26 ` [Qemu-devel] [PATCH v2 4/4] linux-user: pass strace argument " Joel Holdsworth
2016-06-15 20:37   ` Laurent Vivier
2016-06-20 20:02     ` Joel Holdsworth
  -- strict thread matches above, loose matches on Subject: below --
2016-06-20 20:08 [Qemu-devel] [PATCH v2 2/4] linux-user: pass environment arguments " Riku Voipio

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=fbec165c-b1a8-c83b-a77c-bdd2fb6a7c3a@vivier.eu \
    --to=laurent@vivier.eu \
    --cc=Vasileios.Kalintiris@imgtec.com \
    --cc=joel.holdsworth@vcatechnology.com \
    --cc=qemu-devel@nongnu.org \
    --cc=riku.voipio@iki.fi \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).