All of lore.kernel.org
 help / color / mirror / Atom feed
From: Matteo Croce <mcroce@linux.microsoft.com>
To: Laurent Vivier <laurent@vivier.eu>
Cc: qemu-devel@nongnu.org
Subject: Re: [PATCH] linux-user: add option to chroot before emulation
Date: Tue, 8 Dec 2020 17:04:42 +0100	[thread overview]
Message-ID: <CAFnufp1QkXMxMwVksczL8jSHET2zwLSgv4Lm34MgqWd5jyYTNA@mail.gmail.com> (raw)
In-Reply-To: <f37589e0-90d9-a5f0-a5a9-423c583c675d@vivier.eu>

On Tue, Dec 8, 2020 at 9:21 AM Laurent Vivier <laurent@vivier.eu> wrote:
>
> Le 08/12/2020 à 01:17, Matteo Croce a écrit :
> > From: Matteo Croce <mcroce@microsoft.com>
> >
> > Add a '-c' option which does a chroot() just before starting the
> > emulation. This is useful when the static QEMU user binary can't
> > be copied into the target root filesystem, e.g. if it's readonly.
>
> Did you try to use the binfmt_misc 'F' flag (fix binary)?
>
> https://www.kernel.org/doc/Documentation/admin-guide/binfmt-misc.rst
>
> ``F`` - fix binary
>
> The usual behaviour of binfmt_misc is to spawn the
> binary lazily when the misc format file is invoked.  However,
> this doesn``t work very well in the face of mount namespaces and
> changeroots, so the ``F`` mode opens the binary as soon as the
> emulation is installed and uses the opened image to spawn the
> emulator, meaning it is always available once installed,
> regardless of how the environment changes.
>
> This can be configured with scripts/qemu-binfmt-conf.sh and
> "--persistent yes"" option
>

Yes, this works too.
Basically it's the same trick, open the binary early and then emulate.
The only difference is that with binfmt emulation the procfs open
still fails:

# strace -feopenat chroot debian /bin/true 2>&1 |grep /proc/sys
[pid  9359] openat(AT_FDCWD, "/proc/sys/vm/mmap_min_addr", O_RDONLY) =
-1 ENOENT (No such file or directory)

vs

# strace -feopenat qemu-aarch64 -c debian /bin/true 2>&1 |grep /proc/sys
[pid  9348] openat(AT_FDCWD, "/proc/sys/vm/mmap_min_addr", O_RDONLY) = 3

-- 
per aspera ad upstream


  reply	other threads:[~2020-12-08 16:06 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-12-08  0:17 [PATCH] linux-user: add option to chroot before emulation Matteo Croce
2020-12-08  2:09 ` no-reply
2020-12-08  8:21 ` Laurent Vivier
2020-12-08 16:04   ` Matteo Croce [this message]
2020-12-08 18:25     ` 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=CAFnufp1QkXMxMwVksczL8jSHET2zwLSgv4Lm34MgqWd5jyYTNA@mail.gmail.com \
    --to=mcroce@linux.microsoft.com \
    --cc=laurent@vivier.eu \
    --cc=qemu-devel@nongnu.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.