qemu-sanity-check is a short shell script that test-boots a Linux kernel under qemu, making sure it boots up to userspace. The idea is to test the Linux kernel and/or qemu to make sure they are working.
You can use the command on its own:
In this case, the script will look for a suitable qemu binary on the
$PATH and the latest Linux kernel in
/boot and try to boot that kernel on that qemu.
You can also specify a qemu binary or a Linux kernel (either or both options can be omitted):
qemu-sanity-check --qemu=/path/to/qemu --kernel=/path/to/vmlinuz
qemu-kvm) can be used in place of qemu.
No kernel modules or special drivers are required except as noted below. The test uses an initramfs containing a static binary, so the kernel is not required to locate block devices, use virtio, mount filesystems, etc.
The kernel must support only the following, compiled in (not as modules):
- A serial port (usually:
- Initrd/initramfs (
Display short help message and exit.
This sets the
-machine accel=...parameter which is passed to qemu.
If not set, then
kvm:tcgis the default, which means to try to use KVM (hardware-assisted virtualization), and fall back to software emulation if KVM is not possible.
Other typical values of this parameter are:
tcg, which means to force software emulation.
kvm, which means to force KVM and fail if KVM is unavailable.
Set the qemu --cpu option. If not set then a suitable default is picked depending on the architecture and whether KVM is available. You can also use --cpu= to let qemu pick the default.
- -i INITRD
Use the initramfs image named
INITRDinstead of the default.
- -k VMLINUZ
Use the kernel image
VMLINUZinstead of searching for the latest kernel installed in
- -m MACHINE
Set the qemu -m (machine type) option. If not set then a suitable default is picked depending on the architecture. You can also use --machine= to let qemu pick the default.
- -q QEMU
Use the qemu (or KVM) binary
QEMUinstead of searching
$PATHfor a suitable binary.
- -t TIMEOUT
Specify a timeout instead of the default which is
The syntax for the
TIMEOUTis described in full in the man page for timeout(1).
Print extra debugging information.
Display version and exit.
The exit status is 0 if the Linux kernel booted as far as userspace under qemu; or if the --help or --version options were used.
The exit status is 1 if the kernel boot failed under qemu.
The exit status is 2 if the script itself failed (eg. incorrect command line options were used, a suitable kernel could not be found).
The default location for the small initramfs image that is used to test that userspace has been reached.
Richard W.M. Jones <email@example.com>
(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 the Free Software Foundation; either version 2 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.