qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [PATCH 2/2] linux-user: manage binfmt-misc preserve-arg


From: Laurent Vivier
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
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.7.2

Le 14/07/2019 à 18:19, John Paul Adrian Glaubitz a écrit :
> Hi!
> 
>> On Jul 14, 2019, at 3:40 PM, Laurent Vivier <address@hidden> 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 via email to

[Prev in Thread] Current Thread [Next in Thread]