src: Look for kernels in /lib/modules/*/vmlinuz
[qemu-sanity-check.git] / src / qemu-sanity-check.in
index 79372ed..0c96485 100644 (file)
@@ -1,7 +1,8 @@
 #!/bin/bash
 # -*- shell-script -*-
 # qemu-sanity-check
-# Copyright (C) 2013-2020 Red Hat Inc.
+# Copyright (C) 2013-2024 Red Hat Inc.
+# @configure_input@
 #
 # This program is free software; you can redistribute it and/or modify
 # it under the terms of the GNU General Public License as published by
@@ -151,12 +152,18 @@ fi
 
 # Locate kernel if not specified.
 if [ -z "$kernel" ]; then
-    kernel="$(ls -1dvr /boot/vmlinuz-*.$arch* 2>/dev/null | grep -v xen | head -1)"
+    shopt -s nullglob
+    if [ "$verbose" = "yes" ]; then
+        echo "all kernels:"
+        ls -1dvr /lib/modules/*/vmlinuz /boot/vmlinuz-*.$arch*
+    fi
+    kernel="$(ls -1dvr /lib/modules/*/vmlinuz /boot/vmlinuz-*.$arch* 2>/dev/null | grep -v xen | head -1)"
     if [ -z "$kernel" ]; then
         echo "$0: cannot find a Linux kernel in /boot"
         echo "Choose a kernel to test using --kernel=/path/to/vmlinuz"
         exit 2
     fi
+    shopt -u nullglob
 fi
 if [ ! -r "$kernel" ]; then
     echo "$0: kernel $kernel is not readable"
@@ -165,6 +172,9 @@ fi
 
 # Locate qemu if not specified.
 if [ -z "$qemu" ]; then
+    if [ "$verbose" = "yes" ]; then
+        echo "all qemus:" @QEMU_LIST@
+    fi
     for q in @QEMU_LIST@; do
         if "$q" --help >/dev/null 2>&1; then
             qemu="$q"
@@ -226,6 +236,19 @@ elif [ $r -ne 0 ]; then
     exit 1
 fi
 
+if [ "$verbose" = "yes" ]; then
+    cat "$test_output"
+fi
+
+# Check if there was a kernel panic.  Note that oops=panic is set
+# which will force a reboot for any oops condition.
+if grep -sq "Kernel panic - not syncing" "$test_output"; then
+    cat "$test_output"
+    echo "$0: error: test $kernel on $qemu: kernel panic seen"
+    rm "$test_output"
+    exit 1
+fi
+
 # Verify that userspace was reached.
 if ! grep -sq "initrd started up OK" "$test_output"; then
     cat "$test_output"