From: Andreas Thienemann Date: Thu, 21 May 2009 10:24:58 +0000 (+0200) Subject: Support different virtualization technologies for run-qemu. X-Git-Tag: 0.1~209 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=8a4b60d9b22f83eeecec940f8775e69fa1344981;p=thirdparty%2Fdracut.git Support different virtualization technologies for run-qemu. If the host supports kvm, use is. If this is not the case but the kqemu module is loaded, run qemu with kqemu optimization. Otherwise fall-back to pure usermode qemu. --- diff --git a/test/run-qemu b/test/run-qemu index c1068e57c..ba614c0cc 100644 --- a/test/run-qemu +++ b/test/run-qemu @@ -1,9 +1,17 @@ #!/bin/bash -for f in kvm qemu-kvm qemu; do - type $f >/dev/null 2>&1 || continue - $f "$@" - exit -done -echo "Could not find a working KVM or QEMU to test with!" -echo "Please install kvm or qemu." -exit 1 \ No newline at end of file + +# Check which virtualization technology to use +# We prefer kvm, kqemu, userspace in that order. +[[ -x /usr/bin/qemu ]] && BIN=/usr/bin/qemu && ARGS="" +$(lsmod | grep -q '^kqemu ') && BIN=/usr/bin/qemu && ARGS="-kernel-kqemu " +[[ -b /dev/kvm && -x /usr/bin/kvm ]] && BIN=/usr/bin/kvm && ARGS="" +[[ -b /dev/kvm && -x /usr/bin/qemu-kvm ]] && BIN=/usr/bin/qemu-kvm && ARGS="" + +[[ $BIN ]] || { + echo "Could not find a working KVM or QEMU to test with!" >&2 + echo "Please install kvm or qemu." >&2 + exit 1 +} + +echo "Running $BIN $ARGS" +$BIN $ARGS "$@"