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,16 +2479,18 @@ sub run_prepare {
# binary at configuration time instead of lazily at startup # binary at configuration time instead of lazily at startup
# time. If the flag is set, then the qemu-static binary is not # time. If the flag is set, then the qemu-static binary is not
# required inside the chroot. # required inside the chroot.
open my $fh, '<', if (-e "/proc/sys/fs/binfmt_misc/qemu-$options->{qemu}") {
"/proc/sys/fs/binfmt_misc/qemu-$options->{qemu}"; open my $fh, '<',
while (my $line = <$fh>) { "/proc/sys/fs/binfmt_misc/qemu-$options->{qemu}";
chomp($line); while (my $line = <$fh>) {
if ($line =~ /^flags: [A-Z]*F[A-Z]*$/) { chomp($line);
$require_qemu_static = 0; if ($line =~ /^flags: [A-Z]*F[A-Z]*$/) {
last; $require_qemu_static = 0;
last;
}
} }
close $fh;
} }
close $fh;
}; };
if ($require_qemu_static) { if ($require_qemu_static) {
# other modes require a static qemu-user binary # other modes require a static qemu-user binary
@ -4753,19 +4755,13 @@ sub main() {
} elsif ($withemu == 0 and $noemu == 1) { } elsif ($withemu == 0 and $noemu == 1) {
error "arch-test succeeded without emu but not with emu"; error "arch-test succeeded without emu but not with emu";
} elsif ($withemu == 1 and $noemu == 0) { } elsif ($withemu == 1 and $noemu == 0) {
info "$options->{nativearch} cannot be executed, falling back" info "$options->{nativearch} cannot be executed natively, but"
. " to qemu-user"; . " transparently using qemu-user binfmt emulation";
if (!exists $deb2qemu->{ $options->{nativearch} }) { if (!exists $deb2qemu->{ $options->{nativearch} }) {
error "no mapping from $options->{nativearch} to qemu-user" error "no mapping from $options->{nativearch} to qemu-user"
. " binary"; . " binary";
} }
$options->{qemu} = $deb2qemu->{ $options->{nativearch} }; $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) { } elsif ($withemu == 1 and $noemu == 1) {
info "$options->{nativearch} is different from $hostarch but" info "$options->{nativearch} is different from $hostarch but"
. " can be executed natively"; . " can be executed natively";