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)
> My existing and newly created chroots with sbuild-createchroot
> are missing target/usr/libexec/qemu-binfmt/.  This lead me to
> see the following symptoms when attempting to schroot in my
> arm64 chroot overlay environment on top of amd64 machine:
> 
>         $ sudo sbuild-createchroot --arch=arm64 sid target/
>         [...]
> 
>         $ schroot -d / -c sid-arm64-sbuild
>         E: 15binfmt: touch: cannot touch 
> '/var/run/schroot/mount/sid-arm64-sbuild-542dde2d-092f-4135-a59e-9db33d518450/usr/libexec/qemu-binfmt/aarch64-binfmt-P':
>  No such file or directory
>         E: 15binfmt: touch: cannot touch 
> '/var/run/schroot/mount/sid-arm64-sbuild-542dde2d-092f-4135-a59e-9db33d518450/usr/libexec/qemu-binfmt/aarch64-binfmt-P':
>  No such file or directory
>         E: sid-arm64-sbuild-542dde2d-092f-4135-a59e-9db33d518450: Chroot 
> setup failed: stage=setup-start
> 
> The chroot setup fails and I cannot use my build environment.
> I could fix that issue by manually adding the missing directory:
> 
>         $ sudo mkdir -p target/usr/libexec/qemu-binfmt
> 
>         $ schroot -d / -c sid-arm64-sbuild
> 
>         (sid-arm64-sbuild)$ echo ok
>         ok
> 
> 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 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:

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".

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!

> Have a nice day,  :)

All the same! :)

cheers, josch

Attachment: signature.asc
Description: signature

Reply via email to