Choose -cpu max by default
[qemu-sanity-check.git] / src / qemu-sanity-check.in
index 719261a..d8962d4 100644 (file)
@@ -28,18 +28,16 @@ canonical_arch="$(uname -m | sed 's/i[456]86/i386/')"
 verbose=no
 timeout=10m
 accel=kvm:tcg
 verbose=no
 timeout=10m
 accel=kvm:tcg
-cpu=
 memory=768
 console=ttyS0
 machine=
 
 memory=768
 console=ttyS0
 machine=
 
-# Both libguestfs and virt-manager choose cpu=host when we think that
-# KVM is available, and default otherwise.  Although testing for KVM
-# is hairy, I found that on aarch64 it can fail unless we choose
-# cpu=host for KVM.
-if test -r /dev/kvm; then
-    cpu=host
-fi
+# Choosing a good CPU default is a minefield.  Ideally '-cpu max' is
+# supposed to choose the best CPU type, but it notably fails on RISC-V
+# (not supported) and x86_64+TCG (enables LA57 which TCG does not
+# emulate).  Default minimum CPU will not work on RHEL 10, since that
+# requires at least x86_64-v3.
+cpu=max
 
 # Default machine and CPU type depends on arch.  You can override this
 # using -m|--machine and --cpu options.
 
 # Default machine and CPU type depends on arch.  You can override this
 # using -m|--machine and --cpu options.
@@ -49,7 +47,6 @@ case "$canonical_arch" in
        machine=virt ;;
     aarch*)
        console=ttyAMA0
        machine=virt ;;
     aarch*)
        console=ttyAMA0
-       if [ "$cpu" = "" ]; then cpu=cortex-a57; fi
        machine=virt ;;
     s390*)
        console=ttysclp0 ;;
        machine=virt ;;
     s390*)
        console=ttysclp0 ;;
@@ -152,16 +149,18 @@ fi
 
 # Locate kernel if not specified.
 if [ -z "$kernel" ]; then
 
 # Locate kernel if not specified.
 if [ -z "$kernel" ]; then
+    shopt -s nullglob
     if [ "$verbose" = "yes" ]; then
         echo "all kernels:"
     if [ "$verbose" = "yes" ]; then
         echo "all kernels:"
-        ls -1dvr /boot/vmlinuz-*.$arch*
+        ls -1dvr /lib/modules/*/vmlinuz /boot/vmlinuz-*.$arch*
     fi
     fi
-    kernel="$(ls -1dvr /boot/vmlinuz-*.$arch* 2>/dev/null | grep -v xen | head -1)"
+    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
     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"
 fi
 if [ ! -r "$kernel" ]; then
     echo "$0: kernel $kernel is not readable"