Support different virtualization technologies for run-qemu. This patch 
should be applied on top of the patchset from Victor Lowther.

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.

diffstat dracut-run-qemu-enhancements.patch 
 run-qemu |   24 ++++++++++++++++--------
 1 file changed, 16 insertions(+), 8 deletions(-)

diff -up dracut/test/run-qemu.orig dracut/test/run-qemu
--- dracut/test/run-qemu.orig   2009-05-21 12:16:14.622759670 +0200
+++ dracut/test/run-qemu        2009-05-21 12:16:22.858798678 +0200
@@ -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 "$@"
--
To unsubscribe from this list: send the line "unsubscribe initramfs" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to