-# the launcher, depending on local/target archs
-archs="$(uname -i)+$TARGET_ARCH"
-case $archs in
- i386+i386) QEMU=qemu;;
- i386+x86_64) QEMU=qemu-system-x86_64;;
- x86_64+i386) QEMU=qemu;;
- x86_64+x86_64) QEMU=qemu-system-x86_64;;
-esac
-
-#Creating new HDA if needed only
-#using qcow2 disk image format which is essential to support VM snapshots
-if [ -f $HDA ] ; then
- echo "Using $HDA"
+# NOTE: check if the machine supports 64bits. We'll add -no-kqemu only
+# if it does. On 32bits host, qemu-system-x86_64 doesn't accept this
+# parameter (although it's there in the man page)
+function is_64bits () {
+ return $(cat /proc/cpuinfo | grep "^flags" | grep " lm " > /dev/null)
+}
+
+
+# the launcher, depending on target arch
+# make sure to check qemu-kill-node for consistency
+
+# use kvm if available
+has_kvm=$(type -p qemu-kvm)
+if [ -n "$has_kvm" ] ; then
+ QEMU="qemu-kvm" ; ARGS=""
+else
+ case $TARGET_ARCH in
+ i386) QEMU=qemu ; ARGS="" ;;
+ x86_64) QEMU=qemu-system-x86_64 ; if is_64bits; then ARGS="-no-kqemu"; else ARGS=""; fi ;;
+ *) echo "Cannot handle TARGET_ARCH=$TARGET_ARCH"; exit 1 ;;
+ esac
+fi
+
+echo "Running $COMMAND in $(pwd)"
+echo "Starting at $(date)"
+
+#Creating new DISK_IMAGE if needed only
+if [ -f $DISK_IMAGE ] ; then
+ echo "Using existing $DISK_IMAGE"