improve qemu-user

- rephrase info message to be less misleading
 - do not require qemu-$arch-static binary
 - check if /proc/sys/fs/binfmt_misc/qemu-$arch exists before reading it
This commit is contained in:
Johannes Schauer Marin Rodrigues 2022-05-24 14:18:51 +02:00
parent b99f1d53d5
commit 0f9c6543c4
Signed by: josch
GPG key ID: F2CBA5C78FBD83E1

View file

@ -2479,6 +2479,7 @@ sub run_prepare {
# binary at configuration time instead of lazily at startup
# time. If the flag is set, then the qemu-static binary is not
# required inside the chroot.
if (-e "/proc/sys/fs/binfmt_misc/qemu-$options->{qemu}") {
open my $fh, '<',
"/proc/sys/fs/binfmt_misc/qemu-$options->{qemu}";
while (my $line = <$fh>) {
@ -2489,6 +2490,7 @@ sub run_prepare {
}
}
close $fh;
}
};
if ($require_qemu_static) {
# other modes require a static qemu-user binary
@ -4753,19 +4755,13 @@ sub main() {
} elsif ($withemu == 0 and $noemu == 1) {
error "arch-test succeeded without emu but not with emu";
} elsif ($withemu == 1 and $noemu == 0) {
info "$options->{nativearch} cannot be executed, falling back"
. " to qemu-user";
info "$options->{nativearch} cannot be executed natively, but"
. " transparently using qemu-user binfmt emulation";
if (!exists $deb2qemu->{ $options->{nativearch} }) {
error "no mapping from $options->{nativearch} to qemu-user"
. " binary";
}
$options->{qemu} = $deb2qemu->{ $options->{nativearch} };
if (any { $_ eq $options->{mode} } ('root', 'unshare')) {
my $qemubin = "/usr/bin/qemu-$options->{qemu}-static";
if (!-e $qemubin) {
error "cannot find $qemubin";
}
}
} elsif ($withemu == 1 and $noemu == 1) {
info "$options->{nativearch} is different from $hostarch but"
. " can be executed natively";