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

Bug#983087: sbuild-createchroot misses usr/libexec/qemu-binfmt/ directory



19.02.2021 18:45, Johannes Schauer Marin Rodrigues wrote:
Control: reassign -1 schroot
Control: tag -1 + patch
Control: retitle -1 cannot enter foreign arch schroot since qemu 1:5.2+dfsg-4
Control: severity -1 important

Hi Étienne & Michael,

Quoting Étienne Mollier (2021-02-19 09:42:48)
[]
It looks to me like this appears since qemu 1:5.2+dfsg-4: the
actual binfmt binary is now located below the directory
/usr/libexec/qemu-binfmt/.  I see in the change log:

  * qemu-user: attempt to preserve argv[0] when run under binfmt
    (Closes: #970460)
    This changes the enterpreter name for all linux-user registered
    binfmts, so it potentially can break stuff.  The actual binary
    being registered now is /usr/libexec/qemu-binfmt/foo-binfmt-P,
    which is a symlink to actual /usr/lib/qemu-foo[-static].

I predicted this change may reveal issues in other setups.

I am not too sure whether this is a bug in the sbuild package,
or something more relevant to plain debootstrap, a documentation
item perhaps, or just me missing a step on my end.  Please feel
free to reassign as deemed the most appropriate.

This seems to be a bug in schroot. After adding a "set -x" to
/etc/schroot/setup.d/15binfmt I get this output:

E: 15binfmt: + which update-binfmts
E: 15binfmt: + shell=/var/run/schroot/mount/sid-arm64-sbuild-bea80746-d95f-425f-b239-2a7f1e589f2b/bin/sh
E: 15binfmt: + update-binfmts --find /var/run/schroot/mount/sid-arm64-sbuild-bea80746-d95f-425f-b239-2a7f1e589f2b/bin/sh
E: 15binfmt: + dst=/var/run/schroot/mount/sid-arm64-sbuild-bea80746-d95f-425f-b239-2a7f1e589f2b/usr/libexec/qemu-binfmt/aarch64-binfmt-P
E: 15binfmt: + [ ! -e /usr/libexec/qemu-binfmt/aarch64-binfmt-P ] /var/run/schroot/mount/sid-arm64-sbuild-bea80746-d95f-425f-b239-2a7f1e589f2b/usr/libexec/qemu-binfmt/aarch64-binfmt-P ]
E: 15binfmt: + touch /var/run/schroot/mount/sid-arm64-sbuild-bea80746-d95f-425f-b239-2a7f1e589f2b/usr/libexec/qemu-binfmt/aarch64-binfmt-P
E: 15binfmt: touch: cannot touch '/var/run/schroot/mount/sid-arm64-sbuild-bea80746-d95f-425f-b239-2a7f1e589f2b/usr/libexec/qemu-binfmt/aarch64-binfmt-P': No such file or directory
E: sid-arm64-sbuild-bea80746-d95f-425f-b239-2a7f1e589f2b: Chroot setup failed: stage=setup-start

So the problem is in this part of /etc/schroot/setup.d/15binfmt:

for emulator in $(update-binfmts --find "$shell"); do
     dst="${CHROOT_PATH}$emulator"
     if [ ! -e "$emulator" ]; then
         info "Missing emulator: $emulator; not enabling binfmt support"
     else
         [ -e "$dst" ] || touch "$dst"
         mount --bind "$emulator" "$dst"
         mount -o remount,ro,bind "$dst"
     fi
done

Instead of just running "touch", the script should attempt to do "mkdir -p"
beforehand. This works:

The thing is that since quite some time ago, there's no need to mess up with
the qemu-user-static binfmt interpreter at all, it all just works without any
additional setup/preparation due to the fix-binary binfmt-misc flag (which
keeps the interpreter open in the main system, so it works fine within all
chroots without being present there).  It works since kernel 4.8 and QEMU
Debian package 2.12 (Apr-2018).

for emulator in $(update-binfmts --find "$shell"); do
     dst="${CHROOT_PATH}$emulator"
     if [ ! -e "$emulator" ]; then
         info "Missing emulator: $emulator; not enabling binfmt support"
     else
         if [ ! -e "$dst" ]; then
		mkdir -p "$(dirname "$dst")"
		touch "$dst"
	fi
         mount --bind "$emulator" "$dst"
         mount -o remount,ro,bind "$dst"
     fi
done

Thus, adding the tag "patch".

The whole thing isn't needed for qemu and all the binfmt handling can be removed
now.

Michael, your change in qemu introduced this problem. Schroot is currently
orphaned. Since you are responsible for this change in qemu, could you make an
NMU of schroot with above fix? Thanks!

Oww.. orphan.. that's pity.
Okay, I'll take a look at it.

Thank you for the analisys!

/mjt


Reply to: