From 7ec6c432c11e2c01e6269efef6402f682cbd15c7 Mon Sep 17 00:00:00 2001
From: =?utf8?q?Bar=C4=B1=C5=9F=20Metin?= <Talip-Baris.Metin@sophia.inria.fr>
Date: Mon, 26 Jul 2010 17:52:29 +0200
Subject: [PATCH] backport -no-kqemu patch

---
 system/template-qemu/qemu-start-node | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/system/template-qemu/qemu-start-node b/system/template-qemu/qemu-start-node
index cc0ea2a..0f80239 100755
--- a/system/template-qemu/qemu-start-node
+++ b/system/template-qemu/qemu-start-node
@@ -34,11 +34,18 @@ CONFIG=qemu.conf
 [ -f "$CONFIG" ] || { echo "Config file for qemu $CONFIG not found in $(pwd)" ; exit 1 ; }
 . $CONFIG
 
+# 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
 case $TARGET_ARCH in
     i386)		QEMU=qemu ; ARGS="" ;;
-    x86_64)		QEMU=qemu-system-x86_64 ; ARGS="-no-kqemu" ;;
+    x86_64)		QEMU=qemu-system-x86_64 ; if is_64bits; then ARGS="-no-kqemu"; fi ;;
     *)			echo "Cannot handle TARGET_ARCH=$TARGET_ARCH"; exit 1 ;;
 esac
 
-- 
2.47.0