From: Alexander Graf <agraf@suse.de>
To: Joakim Tjernlund <joakim.tjernlund@transmode.se>
Cc: riku.voipio@iki.fi, qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] [PATCH] linux-user: Add binfmt wrapper
Date: Mon, 14 Jul 2014 18:00:35 +0200 [thread overview]
Message-ID: <53C3FEA3.2060605@suse.de> (raw)
In-Reply-To: <OFD27D796B.35488E12-ONC1257D15.00572B70-C1257D15.0057D441@transmode.se>
On 14.07.14 17:59, Joakim Tjernlund wrote:
> Alexander Graf <agraf@suse.de> wrote on 2014/07/14 17:46:18:
>>
>> On 14.07.14 17:38, Joakim Tjernlund wrote:
>>> Alexander Graf <agraf@suse.de> wrote on 2014/07/14 17:21:33:
>>>
>>>> From: Alexander Graf <agraf@suse.de>
>>>> To: Joakim Tjernlund <Joakim.Tjernlund@transmode.se>,
>>>> Cc: qemu-devel@nongnu.org
>>>> Date: 2014/07/14 17:21
>>>> Subject: Re: [PATCH] linux-user: Add binfmt wrapper
>>>>
>>>>
>>>> On 14.07.14 16:38, Joakim Tjernlund wrote:
>>>>> The popular binfmt-wrapper patch adds an additional
>>>>> executable which mangle argv suitable for binfmt flag P.
>>>>> In a chroot you need the both (statically linked) qemu-$arch
>>>>> and qemu-$arch-binfmt-wrapper. This is sub optimal and a
>>>>> better approach is to recognize the -binfmt-wrapper extension
>>>>> within linux-user(qemu-$arch) and mangle argv there.
>>>>> This just produces on executable which can be either copied to
>>>>> the chroot or bind mounted with the appropriate -binfmt-wrapper
>>>>> suffix.
>>>>>
>>>>> Signed-off-by: Joakim Tjernlund <Joakim.Tjernlund@transmode.se>
>>>> Please make sure to CC Riku on patches like this - he is the
> linux-user
>>>> maintainer.
>>> Doesn't he read the devel list? Anyhow CC:ed
>> He may or may not. Qemu-devel can be pretty high volume :).
>>
>>>>> ---
>>>>> linux-user/main.c | 13 +++++++++++++
>>>>> 1 file changed, 13 insertions(+)
>>>>>
>>>>> diff --git a/linux-user/main.c b/linux-user/main.c
>>>>> index 71a33c7..212067a 100644
>>>>> --- a/linux-user/main.c
>>>>> +++ b/linux-user/main.c
>>>>> @@ -3828,6 +3828,19 @@ int main(int argc, char **argv, char **envp)
>>>>> int i;
>>>>> int ret;
>>>>> int execfd;
>>>>> + char *binfmt;
>>>>> +
>>>>> + i = strlen( argv[0] ) - strlen ( "-binfmt-wrapper" );
>>>> The spaces are odd. Did this patch pass checkpatch.pl? Same comment
> goes
>>>> for almost all function invocations.
>>> ehh, didn't run it through checkpatch.pl. Easy to fix next time.
>>>
>>>>> + binfmt = argv[0] + i;
>>>>> + if (i > 0 && strcmp ( binfmt, "-binfmt-wrapper" ) == 0) {
>>>> This magic needs to be documented somewhere. In fact, I find it
> pretty
>>>> hard to use in real world scenarios. Imagine a distribution - should
> it
>>>> package every target binary twice? Should it create hardlinks all
> over?
>>> How does dists. handle your original binfmt-wrapper? This is not much
>>> different I think. Here you got a choice to create a hardlink or a
> copy.
>>> Any chroot will only have to bind mount binfmt-wrapper into the chroot
> or
>>> lxc container.
>> Yeah, and there are reasons my original approach isn't upstream :).
> What are those then? Hardly just packaging problem/choise.
>
>>>> I think we should try and find better magic :). Looking at the
>>>> binfmt_misc loading code, I think we can cheat a bit. If we pass the
> 'O'
>>>> flag (open target binary for handler), binfmt_misc will tell us the
>>>> binary fd in AT_EXECFD:
>>>>
>>>> NEW_AUX_ENT(AT_EXECFD, bprm->interp_data);
>>>>
>>>> We could then use this as a hint that we were spawned by binfmt_misc
>>>> rather than directly and interpret the first argv as target_argv[0].
>>>>
>>>> Then we can also add the P and O flags to scripts/qemu-binfmt-conf.sh
>>>> and have a solution that works well for everyone.
>>> What to do with P only then? Seems like most dists uses only P
>> If a distro uses the P flag it's not using upstream code, so they have
>> to deal with their own breakage :). Fortunately the binfmt install
>> scripts are usually part of a package too, so they can be updated
> easily.
>
> scripts/qemu-binfmt-conf.sh does not use any flag currently, I don't think
> that works either with current linux-user and choot/lxc
>
> You think everyone feel OK with new defaults like OP ?
Yes.
Alex
next prev parent reply other threads:[~2014-07-14 16:00 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-07-14 14:38 [Qemu-devel] [PATCH] linux-user: Add binfmt wrapper Joakim Tjernlund
2014-07-14 15:21 ` Alexander Graf
2014-07-14 15:38 ` Joakim Tjernlund
2014-07-14 15:46 ` Alexander Graf
2014-07-14 15:59 ` Joakim Tjernlund
2014-07-14 16:00 ` Alexander Graf [this message]
2014-07-14 16:32 ` Joakim Tjernlund
2014-07-14 16:34 ` Alexander Graf
2014-07-14 16:45 ` Joakim Tjernlund
2014-07-14 16:51 ` Joakim Tjernlund
2014-07-14 16:54 ` Alexander Graf
2014-07-14 17:01 ` Joakim Tjernlund
2014-07-14 17:08 ` Joakim Tjernlund
2014-07-14 17:14 ` Alexander Graf
2014-07-14 16:00 ` Peter Maydell
2014-07-14 16:08 ` Joakim Tjernlund
2014-07-15 14:12 ` Riku Voipio
2014-07-15 14:39 ` Joakim Tjernlund
2014-07-15 15:11 ` Joakim Tjernlund
2014-07-16 6:54 ` Riku Voipio
2014-07-16 7:22 ` Joakim Tjernlund
2014-07-16 11:38 ` Joakim Tjernlund
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=53C3FEA3.2060605@suse.de \
--to=agraf@suse.de \
--cc=joakim.tjernlund@transmode.se \
--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).