The original logic is to first assign a value to qemu and then check. This will cause qemu to be equal to a wrong value rather than "".
[log] [INFO] 2021-03-03 15:05:09 qemu.sh: less /srv/cci/serial/logs/vm-2p16g.taishan200-2280-2s64p-256g--a10-0 /c/compass-ci/providers/qemu/kvm.sh: line 209: qemu-kvm: command not found
Signed-off-by: Lin Jiaxin ljx.joe@qq.com --- providers/qemu/kvm.sh | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-)
diff --git a/providers/qemu/kvm.sh b/providers/qemu/kvm.sh index fdaf254..dcab81a 100755 --- a/providers/qemu/kvm.sh +++ b/providers/qemu/kvm.sh @@ -71,7 +71,9 @@ check_kernel() check_qemu() { # debian has both qemu-system-x86_64 and qemu-system-riscv64 command - [[ $kernel =~ 'riscv64' ]] && qemu=qemu-system-riscv64 + [[ $kernel =~ 'riscv64' ]] && { + command -v qemu-system-riscv64 > /dev/null && qemu=qemu-system-riscv64 + } }
check_initrds() @@ -139,9 +141,12 @@ set_qemu() qemu-kvm )
- for qemu in "${qemus[@]}" + for qemu_candidate in "${qemus[@]}" do - command -v "$qemu" > /dev/null && break + command -v "$qemu_candidate" > /dev/null && { + qemu="$qemu_candidate" + break + } done
check_qemu