qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Laurent Vivier <laurent@vivier.eu>
To: John Paul Adrian Glaubitz <glaubitz@physik.fu-berlin.de>
Cc: Peter Maydell <peter.maydell@linaro.org>,
	Riku Voipio <riku.voipio@iki.fi>,
	qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] [PATCH 2/2] linux-user: manage binfmt-misc preserve-arg[0] flag
Date: Wed, 17 Jul 2019 12:07:09 +0200	[thread overview]
Message-ID: <13f6aa89-e3f3-61e8-fa05-cde20b55daa0@vivier.eu> (raw)
In-Reply-To: <1F76A574-2A97-4070-8EE0-0EE83A4241E9@physik.fu-berlin.de>

Le 14/07/2019 à 18:19, John Paul Adrian Glaubitz a écrit :
> Hi!
> 
>> On Jul 14, 2019, at 3:40 PM, Laurent Vivier <laurent@vivier.eu> wrote:
>>
>> Add --preserve-arg0 in qemu-binfmt-conf.sh to configure the preserve-arg0
>> flag.
>>
>> Now, if QEMU is started with -0 or QEMU_ARGV0 and an empty parameter
>> argv[0] (the full pathname provided by binfmt-misc) is removed and
>> replaced by argv[1] (the original argv[0] provided by binfmt-misc when
>> 'P'/preserve-arg[0] is set)
>>
>> For instance:
>>
>>  $ sudo QEMU_ARGV0= chroot m68k-chroot sh -c 'echo $0'
>>  sh
>>
>> without this patch:
>>
>>  $ sudo chroot m68k-chroot sh -c 'echo $0'
>>  /usr/bin/sh
> 
> As a regular user of qemu-user (we’re using qemu-user to run Debian’s buildds for m68k and sh4), I would like to add that the idea of having to pass additional environment variables to make qemu behave as expected, i.e. as the real hardware, is sub-optimal.
> 
> I would prefer that enabling the preserve flag with the qemu-binfmt.sh script would make qemu-user behave correctly.

QEMU is not able to detect if it has been started by binfmt_misc with
the preserve-arg[0] enabled or not, so it can't adapt the args analysis
to get the correct list.

> 
> If I understand correctly, the current design with the environment variable was chosen because my preferred approach would break compatibility in certain cases. However, I think that correct emulation is more important than compatibility to an old broken behavior and I would therefore be in favor to make the correct behavior default.
> 
> This will also be necessary when using qemu-user with Debian’s sbuild to “cross”-build packages with qemu-user. This particular bug was actually discovered while building Debian packages for m68k and sh4 using qemu-user.

The problem we have here is we don't know how qemu-user is used in the
wild. In my knowledge you are the most involved user, but you're not the
only one reporting problem via launchpad. Moreover, distros provide
qemu-user statically linked and binfmt configuration files, so we can
guess we have other users.

And I don't like to break existing things...

What I can propose:

1- modify this patch to add a configure option:

   by default qemu will need the QEMU_ARGV0 but we will be able to
define at configure time it always runs with preserve-arg[0] flag
enabled (something like "--enable-preserve-arg0")

[So debian will be able to provide qemu-user-static with this enabled by
default if you're not afraid to break debian users environment]

2- try (again) to push in the kernel the binfmt_misc namespace that
allows to have per chroot basis binfmt configuration

3- once 3 done, enable preserve-arg[0] by default

Thanks,
Laurent


  reply	other threads:[~2019-07-17 10:07 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-07-14 13:40 [Qemu-devel] [PATCH 1/2] linux-user: remove useless variable Laurent Vivier
2019-07-14 13:40 ` [Qemu-devel] [PATCH 2/2] linux-user: manage binfmt-misc preserve-arg[0] flag Laurent Vivier
2019-07-14 16:19   ` John Paul Adrian Glaubitz
2019-07-17 10:07     ` Laurent Vivier [this message]
2019-07-30 11:04       ` John Paul Adrian Glaubitz
2019-07-30 11:25       ` Peter Maydell
2019-07-14 16:02 ` [Qemu-devel] [PATCH 1/2] linux-user: remove useless variable Philippe Mathieu-Daudé
2019-08-23 15:31 ` Laurent Vivier

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=13f6aa89-e3f3-61e8-fa05-cde20b55daa0@vivier.eu \
    --to=laurent@vivier.eu \
    --cc=glaubitz@physik.fu-berlin.de \
    --cc=peter.maydell@linaro.org \
    --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).