Add -m/--machine option.
authorRichard W.M. Jones <rjones@redhat.com>
Thu, 10 Sep 2020 12:36:16 +0000 (13:36 +0100)
committerRichard W.M. Jones <rjones@redhat.com>
Thu, 10 Sep 2020 13:37:43 +0000 (14:37 +0100)
Pick the default machine type depending on arch.

Fixes: https://bugzilla.redhat.com/show_bug.cgi?id=1875763

qemu-sanity-check.in
qemu-sanity-check.pod.in

index 5536eda..e1abafd 100644 (file)
@@ -1,7 +1,7 @@
 #!/bin/bash
 # -*- shell-script -*-
 # qemu-sanity-check
 #!/bin/bash
 # -*- shell-script -*-
 # qemu-sanity-check
-# Copyright (C) 2013 Red Hat Inc.
+# Copyright (C) 2013-2020 Red Hat Inc.
 #
 # 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
 #
 # 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
@@ -27,6 +27,14 @@ canonical_arch="$(uname -m | sed 's/i[456]86/i386/')"
 timeout=10m
 accel=kvm:tcg
 
 timeout=10m
 accel=kvm:tcg
 
+# Default machine type depends on arch.  You can override this using
+# -m|--machine option.
+case "$canonical_arch" in
+    arm*|aarch*) machine=virt ;;
+    # On non-ARM let qemu pick the default.
+    *) machine= ;;
+esac
+
 # Handle command line parsing.
 
 function usage {
 # Handle command line parsing.
 
 function usage {
@@ -36,6 +44,7 @@ function usage {
     echo "  --accel=[kvm|tcg]    Force KVM or software emulation"
     echo "  -i|--initrd=initrd   Set location of initramfs"
     echo "  -k|--kernel=vmlinuz  Set location of kernel"
     echo "  --accel=[kvm|tcg]    Force KVM or software emulation"
     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|--version         Display version and exit"
     echo "  -q|--qemu=qemu       Set location of qemu/KVM binary"
     echo "  -t|--timeout=timeout Set the timeout"
     echo "  -V|--version         Display version and exit"
@@ -43,11 +52,12 @@ function usage {
 }
 
 TEMP=$(getopt \
 }
 
 TEMP=$(getopt \
-    -o i:k:q:t:V \
+    -o i:k:m:q:t:V \
     --long help \
     --long accel: \
     --long initrd: \
     --long kernel: \
     --long help \
     --long accel: \
     --long initrd: \
     --long kernel: \
+    --long machine: \
     --long qemu: \
     --long timeout: \
     --long version \
     --long qemu: \
     --long timeout: \
     --long version \
@@ -72,6 +82,10 @@ while true; do
             kernel="$2"
             shift 2
             ;;
             kernel="$2"
             shift 2
             ;;
+        -m|--machine)
+            machine="$2"
+            shift 2
+            ;;
         -q|--qemu)
             qemu="$2"
             shift 2
         -q|--qemu)
             qemu="$2"
             shift 2
@@ -145,7 +159,7 @@ argv[$((i++))]="none"
 argv[$((i++))]="-no-user-config"
 argv[$((i++))]="-nodefaults"
 argv[$((i++))]="-machine"
 argv[$((i++))]="-no-user-config"
 argv[$((i++))]="-nodefaults"
 argv[$((i++))]="-machine"
-argv[$((i++))]="accel=$accel"
+argv[$((i++))]="$machine${machine:+,}accel=$accel"
 argv[$((i++))]="-no-reboot"
 argv[$((i++))]="-serial"
 argv[$((i++))]="file:$test_output"
 argv[$((i++))]="-no-reboot"
 argv[$((i++))]="-serial"
 argv[$((i++))]="file:$test_output"
index 47d6d43..1559093 100644 (file)
@@ -91,6 +91,14 @@ Use the initramfs image named C<INITRD> instead of the default.
 Use the kernel image C<VMLINUZ> instead of searching for the latest
 kernel installed in C</boot>.
 
 Use the kernel image C<VMLINUZ> instead of searching for the latest
 kernel installed in C</boot>.
 
+=item B<-m> MACHINE
+
+=item B<--machine>=MACHINE
+
+Set the qemu I<-m> (machine type) option.  If not set then a suitable
+default is picked depending on the architecture.  You can also use
+I<--machine=> to let qemu pick the default.
+
 =item B<-q> QEMU
 
 =item B<--qemu>=QEMU
 =item B<-q> QEMU
 
 =item B<--qemu>=QEMU
@@ -147,7 +155,7 @@ Richard W.M. Jones <rjones@redhat.com>
 
 =head1 COPYRIGHT
 
 
 =head1 COPYRIGHT
 
-(C) Copyright 2013 Red Hat Inc.
+(C) Copyright 2013-2020 Red Hat Inc.
 
 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
 
 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