Automatically find KVM executable and set KVM variable
authorMartin Schwenke <martin@meltin.net>
Tue, 22 May 2012 05:17:43 +0000 (15:17 +1000)
committerMartin Schwenke <martin@meltin.net>
Tue, 22 May 2012 05:17:43 +0000 (15:17 +1000)
Signed-off-by: Martin Schwenke <martin@meltin.net>
config.d/00base.defconf

index 52232a866d40c7be921912b070296578871fecfd..cc1a084c12b0a514a65dec7f1cad57501f18b14f 100644 (file)
@@ -50,9 +50,7 @@ defconf DISK_FOLLOW_SYMLINKS "no" \
 defconf VIRSH "virsh -c qemu:///system" \
        "<cmd>" "how to invoke virsh"
 
-# the kvm binary to use - should be a very recent version
-# I am using a git snapshot from http://kvm.qumranet.com/kvmwiki/Code
-defconf KVM "/usr/bin/qemu-kvm" \
+defconf KVM "@uto" \
        "<file>"  "location of KVM executable"
 
 defconf KVMLOG "/var/log/kvm" \
@@ -336,6 +334,22 @@ cat <<EOF
 EOF
 }
 
+get_kvm_path ()
+{
+    local t
+
+    if t=$(which qemu-kvm 2>/dev/null) ; then
+       echo "$t"
+    elif t=$(which kvm 2>/dev/null) ; then
+       echo "$t"
+    elif [ -x "/usr/libexec/qemu-kvm" ] ; then
+       echo "/usr/libexec/qemu-kvm"
+    else
+       die "Could not find KVM executable"
+    fi
+
+}
+
 rhel_post_config_hook ()
 {
     if [ "$ISO" = "@uto" ] ; then
@@ -353,6 +367,10 @@ rhel_post_config_hook ()
     if [ "$SYSTEM_DISK_PREFIX" = "@uto" ] ; then
        SYSTEM_DISK_PREFIX=$(rhel_disk_prefix $SYSTEM_DISK_TYPE)
     fi
+
+    if [ "$KVM" = "@uto" ] ; then
+       KVM=$(get_kvm_path) || exit $?
+    fi
 }
 
 register_hook post_config_hooks rhel_post_config_hook