fix(test/run-qemu): shellcheck for test/run-qemu

master
Harald Hoyer 2021-03-30 10:40:13 +02:00 committed by Harald Hoyer
parent 51b6784217
commit e010f45524
1 changed files with 12 additions and 12 deletions

View File

@ -3,13 +3,13 @@
# We prefer kvm, kqemu, userspace in that order.
export PATH=/sbin:/bin:/usr/sbin:/usr/bin

[[ -x /usr/bin/qemu ]] && BIN=/usr/bin/qemu && ARGS="-cpu max"
$(lsmod | grep -q '^kqemu ') && BIN=/usr/bin/qemu && ARGS="-kernel-kqemu -cpu host"
[[ -c /dev/kvm && -x /usr/bin/kvm ]] && BIN=/usr/bin/kvm && ARGS="-cpu host"
[[ -c /dev/kvm && -x /usr/bin/qemu-kvm ]] && BIN=/usr/bin/qemu-kvm && ARGS="-cpu host"
[[ -c /dev/kvm && -x /usr/libexec/qemu-kvm ]] && BIN=/usr/libexec/qemu-kvm && ARGS="-cpu host"
[[ -x /usr/bin/qemu-system-$(uname -i) ]] && BIN=/usr/bin/qemu-system-$(uname -i) && ARGS="-cpu max"
[[ -c /dev/kvm && -x /usr/bin/qemu-system-$(uname -i) ]] && BIN=/usr/bin/qemu-system-$(uname -i) && ARGS="-enable-kvm -cpu host"
[[ -x /usr/bin/qemu ]] && BIN=/usr/bin/qemu && ARGS=(-cpu max)
(lsmod | grep -q '^kqemu ') && BIN=/usr/bin/qemu && ARGS=(-kernel-kqemu -cpu host)
[[ -c /dev/kvm && -x /usr/bin/kvm ]] && BIN=/usr/bin/kvm && ARGS=(-cpu host)
[[ -c /dev/kvm && -x /usr/bin/qemu-kvm ]] && BIN=/usr/bin/qemu-kvm && ARGS=(-cpu host)
[[ -c /dev/kvm && -x /usr/libexec/qemu-kvm ]] && BIN=/usr/libexec/qemu-kvm && ARGS=(-cpu host)
[[ -x /usr/bin/qemu-system-$(uname -i) ]] && BIN=/usr/bin/qemu-system-$(uname -i) && ARGS=(-cpu max)
[[ -c /dev/kvm && -x /usr/bin/qemu-system-$(uname -i) ]] && BIN=/usr/bin/qemu-system-$(uname -i) && ARGS=(-enable-kvm -cpu host)

[[ $BIN ]] || {
echo "Could not find a working KVM or QEMU to test with!" >&2
@ -18,10 +18,10 @@ $(lsmod | grep -q '^kqemu ') && BIN=/usr/bin/qemu && ARGS="-kernel-kqemu -cpu ho
}

# Provide rng device sourcing the hosts /dev/urandom and other standard parameters
ARGS="$ARGS -smp 2 -m 512 -nodefaults -vga none -display none -no-reboot -device virtio-rng-pci"
ARGS+=(-smp 2 -m 512 -nodefaults -vga none -display none -no-reboot -device virtio-rng-pci)

if ! [[ $* == *-daemonize* ]] && ! [[ $* == *-daemonize* ]]; then
ARGS="$ARGS -serial stdio"
ARGS+=(-serial stdio)
fi

KVERSION=${KVERSION-$(uname -r)}
@ -29,13 +29,13 @@ KVERSION=${KVERSION-$(uname -r)}
VMLINUZ="/lib/modules/${KVERSION}/vmlinuz"

if ! [ -f "$VMLINUZ" ]; then
[[ -f /etc/machine-id ]] && read MACHINE_ID < /etc/machine-id
[[ -f /etc/machine-id ]] && read -r MACHINE_ID < /etc/machine-id

if [[ $MACHINE_ID ]] && ([[ -d /boot/${MACHINE_ID} ]] || [[ -L /boot/${MACHINE_ID} ]]); then
if [[ $MACHINE_ID ]] && { [[ -d /boot/${MACHINE_ID} ]] || [[ -L /boot/${MACHINE_ID} ]]; }; then
VMLINUZ="/boot/${MACHINE_ID}/$KVERSION/linux"
else
VMLINUZ="/boot/vmlinuz-${KVERSION}"
fi
fi

exec $BIN $ARGS -kernel $VMLINUZ "$@"
exec "$BIN" "${ARGS[@]}" -kernel "$VMLINUZ" "$@"