Set RAM to something larger than qemu default.
[qemu-sanity-check.git] / qemu-sanity-check.in
index e1abafd..5066ebc 100644 (file)
@@ -24,15 +24,29 @@ initrd="@libdir@/qemu-sanity-check/initrd"
 arch="$(uname -m)"
 canonical_arch="$(uname -m | sed 's/i[456]86/i386/')"
 
+verbose=no
 timeout=10m
 accel=kvm:tcg
+cpu=
+memory=768
+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
 
-# Default machine type depends on arch.  You can override this using
-# -m|--machine option.
+# Default machine and CPU type depends on arch.  You can override this
+# using -m|--machine and --cpu options.
 case "$canonical_arch" in
-    arm*|aarch*) machine=virt ;;
-    # On non-ARM let qemu pick the default.
-    *) machine= ;;
+    arm*)
+       machine=virt ;;
+    aarch*)
+       if [ "$cpu" = "" ]; then cpu=cortex-a57; fi
+       machine=virt ;;
 esac
 
 # Handle command line parsing.
@@ -42,24 +56,28 @@ function usage {
     echo "Options:"
     echo "  --help               Display this help"
     echo "  --accel=[kvm|tcg]    Force KVM or software emulation"
+    echo "  --cpu=cpu            Set CPU"
     echo "  -i|--initrd=initrd   Set location of initramfs"
     echo "  -k|--kernel=vmlinuz  Set location of kernel"
     echo "  -m|--machine=machine Set machine type"
     echo "  -q|--qemu=qemu       Set location of qemu/KVM binary"
     echo "  -t|--timeout=timeout Set the timeout"
+    echo "  -v|--verbose         Verbose output"
     echo "  -V|--version         Display version and exit"
     exit 0
 }
 
 TEMP=$(getopt \
-    -o i:k:m:q:t:V \
+    -o i:k:m:q:t:vV \
     --long help \
     --long accel: \
+    --long cpu: \
     --long initrd: \
     --long kernel: \
     --long machine: \
     --long qemu: \
     --long timeout: \
+    --long verbose \
     --long version \
     -n 'qemu-sanity-check' -- "$@")
 if [ $? != 0 ]; then exit 2; fi
@@ -74,6 +92,10 @@ while true; do
             accel="$2"
             shift 2
             ;;
+       --cpu)
+           cpu="$2"
+           shift 2
+           ;;
         -i|--initrd)
             initrd="$2"
             shift 2
@@ -94,6 +116,10 @@ while true; do
             timeout="$2"
             shift 2
             ;;
+        -v|--verbose)
+            verbose=yes
+            shift
+            ;;
         -V|--version)
             echo "@PACKAGE_NAME@ @PACKAGE_VERSION@"
             exit 0
@@ -160,6 +186,12 @@ argv[$((i++))]="-no-user-config"
 argv[$((i++))]="-nodefaults"
 argv[$((i++))]="-machine"
 argv[$((i++))]="$machine${machine:+,}accel=$accel"
+if [ "$cpu" != "" ]; then
+    argv[$((i++))]="-cpu"
+    argv[$((i++))]="$cpu"
+fi
+argv[$((i++))]="-m"
+argv[$((i++))]="$memory"
 argv[$((i++))]="-no-reboot"
 argv[$((i++))]="-serial"
 argv[$((i++))]="file:$test_output"
@@ -170,7 +202,9 @@ argv[$((i++))]="$initrd"
 argv[$((i++))]="-append"
 argv[$((i++))]="console=ttyS0 oops=panic panic=-1"
 
-#echo "${argv[@]}"
+if [ "$verbose" = "yes" ]; then
+    echo "${argv[@]}"
+fi
 
 # Run the command.
 timeout "$timeout" "${argv[@]}"