selftest: replace qemu-kvm with one based on dracut's run-qemu
Dracut's run-qemu could find which virtualization technology to the user in the order of kvm, kqemu, userspace. Using run-qemu could allow running tests where qemu-kvm doesn't exist. Signed-off-by: Coiby Xu <coxu@redhat.com> Acked-by: Kairui Song <kasong@redhat.com>
This commit is contained in:
parent
bbc064f958
commit
8619f58538
23
tests/scripts/run-qemu
Executable file
23
tests/scripts/run-qemu
Executable file
@ -0,0 +1,23 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
# Check which virtualization technology to use
|
||||||
|
# We prefer kvm, kqemu, userspace in that order.
|
||||||
|
|
||||||
|
# This script is based on https://github.com/dracutdevs/dracut/blob/master/test/run-qemu
|
||||||
|
|
||||||
|
export PATH=/sbin:/bin:/usr/sbin:/usr/bin
|
||||||
|
|
||||||
|
[[ -x /usr/bin/qemu ]] && BIN=/usr/bin/qemu && ARGS="-cpu max"
|
||||||
|
$(lsmod | grep -q '^kqemu ') && BIN=/usr/bin/qemu && ARGS="-kernel-kqemu -cpu host"
|
||||||
|
[[ -c /dev/kvm && -x /usr/bin/kvm ]] && BIN=/usr/bin/kvm && ARGS="-cpu host"
|
||||||
|
[[ -c /dev/kvm && -x /usr/bin/qemu-kvm ]] && BIN=/usr/bin/qemu-kvm && ARGS="-cpu host"
|
||||||
|
[[ -c /dev/kvm && -x /usr/libexec/qemu-kvm ]] && BIN=/usr/libexec/qemu-kvm && ARGS="-cpu host"
|
||||||
|
[[ -x /usr/bin/qemu-system-$(uname -i) ]] && BIN=/usr/bin/qemu-system-$(uname -i) && ARGS="-cpu max"
|
||||||
|
[[ -c /dev/kvm && -x /usr/bin/qemu-system-$(uname -i) ]] && BIN=/usr/bin/qemu-system-$(uname -i) && ARGS="-enable-kvm -cpu host"
|
||||||
|
|
||||||
|
[[ $BIN ]] || {
|
||||||
|
echo "Could not find a working KVM or QEMU to test with!" >&2
|
||||||
|
echo "Please install kvm or qemu." >&2
|
||||||
|
exit 1
|
||||||
|
}
|
||||||
|
|
||||||
|
exec $BIN $ARGS "$@"
|
@ -89,7 +89,7 @@ run_test_sync() {
|
|||||||
local qemu_cmd=$(get_test_qemu_cmd $1)
|
local qemu_cmd=$(get_test_qemu_cmd $1)
|
||||||
|
|
||||||
if [ -n "$qemu_cmd" ]; then
|
if [ -n "$qemu_cmd" ]; then
|
||||||
timeout --foreground 10m qemu-kvm $(get_test_qemu_cmd $1)
|
timeout --foreground 10m $BASEDIR/run-qemu $(get_test_qemu_cmd $1)
|
||||||
else
|
else
|
||||||
echo "error: test qemu command line is not configured" > /dev/stderr
|
echo "error: test qemu command line is not configured" > /dev/stderr
|
||||||
return 1
|
return 1
|
||||||
|
Loading…
Reference in New Issue
Block a user