qemu-devel
[Top][All Lists]
Advanced

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

Re: [Qemu-devel] [PATCH] linux-user: Add binfmt wrapper


From: Joakim Tjernlund
Subject: Re: [Qemu-devel] [PATCH] linux-user: Add binfmt wrapper
Date: Wed, 16 Jul 2014 09:22:49 +0200

Riku Voipio <address@hidden> wrote on 2014/07/16 08:54:45:
> 
> On Tue, Jul 15, 2014 at 05:11:48PM +0200, Joakim Tjernlund wrote:
> > Riku Voipio <address@hidden> wrote on 2014/07/15 16:12:26:
> > > On Mon, Jul 14, 2014 at 05:38:49PM +0200, Joakim Tjernlund wrote:
> > > > Alexander Graf <address@hidden> wrote on 2014/07/14 17:21:33:
> > > > > 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 
<address@hidden>
> > > > > 
> > > > > 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
> > > 
> > > I do - but CC gets directly to my inbox while qemu-devel goes to an
> > > folder.
> > > 
> > > I take from this discussion, that this patch has been superceded by 
the
> > > Patch at: http://patchwork.ozlabs.org/patch/369770/ ?
> > 
> > BTW, any chance qemu binfmt could fixup the ps output from within a 
> > container:
> >  jocke-ppc2 ~ # ps uaxww
> > USER       PID %CPU %MEM    VSZ   RSS TTY      STAT START   TIME 
COMMAND
> > root         1  0.1  0.0 4138016 7600 ?        Ss   17:02   0:00 
> > /usr/bin/qemu-ppc /sbin/init /sbin/init
> > root        79  0.0  0.0 4138016 5792 ?        Ss   17:02   0:00 
> > /usr/bin/qemu-ppc /usr/sbin/sshd /usr/sbin/sshd
> > root       293  0.0  0.0 4137952 4072 ?        Ss   17:02   0:00 
> > /usr/bin/qemu-ppc /bin/busybox /bin/busybox udhcpc -x 
hostname:jocke-ppc2 
> > --interface=eth0 --now --script=/lib/netifrc/sh/udhcpc-hook.sh 
> > --pidfile=/var/run/udhcpc-eth0.pid
> > root       334  0.3  0.0 4138016 5964 tty1     Ss+  17:02   0:00 
> > /usr/bin/qemu-ppc /sbin/agetty /sbin/agetty 38400 tty1 linux
> > root       335  3.1  0.0 4138048 7064 console  Ss   17:02   0:00 
> > /usr/bin/qemu-ppc /bin/login /bin/login -- root
> > root       336  3.3  0.0 4138016 9764 console  S    17:02   0:00 
> > /usr/bin/qemu-ppc /bin/bash -bash
> > root       340  0.0  0.0 4138016 6336 ?        R+   Jul10   0:00 
/bin/ps 
> > ps uaxww
> > 
> > As you can see, qemu-ppc is visible. 
> 
> This isn't something binfmt could do. ps uses /proc/$pid/exe to map the

Why not? I think it is the perfekt place to do it in Linux binfmt code. 
All
the other interp(ELF ld.so and normal bash scripts) do it. Fixing this 
with
no support from Linux amounts to hacks like:
    /*
     * Munge our argv so it will look like it would
     * if started without linux-user
     */
    if (execfd > 0) {
        unsigned long len;
        char *p = argv[0];

        for (i = 0; i < target_argc; i++, p += len) {
            len = strlen(target_argv[i]) + 1;
            memcpy(p, target_argv[i], len);
        }
        len = *envp - p;
        memset(p, 0, len);
    }
and it is still not perfekt, apps like ps and top still does
not work.
Linux binfmt code should at least pass a correct argv to us

BTW,
    You forgot:
[PATCH 4/4] ppc: remove excessive logging





reply via email to

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