[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH] linux-user: add option to chroot before emulation
From: |
Matteo Croce |
Subject: |
Re: [PATCH] linux-user: add option to chroot before emulation |
Date: |
Tue, 8 Dec 2020 17:04:42 +0100 |
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