aboutsummaryrefslogtreecommitdiffstats
path: root/scripts/runqemu-internal
diff options
context:
space:
mode:
authorRobert Yang <liezhi.yang@windriver.com>2015-06-25 01:56:03 -0700
committerRobert Yang <liezhi.yang@windriver.com>2015-06-25 18:26:06 -0700
commitec38a9b641108bba14f8be1c71c50cc85e6f9f86 (patch)
treebffd9d5f7437c6c88969bc758ba330a9df529ae6 /scripts/runqemu-internal
parentdd6a444cfc1ef527520a0e3490b6a243f0e7679c (diff)
downloadopenembedded-core-contrib-rbt/qemu_v2.tar.gz
runqemu: enable kvm when use tap under sudorbt/qemu_v2
Enable kvm support automatically when use tap interface under sudo, the thought is, if sudo works well, and qemu-native has been built with kvm support, and kvm can be enabled, then enable it, it can be disabled by nokvm option. The previous command: $ runqemu qemux86 kvm may not work since it checks the current user's read/write permission on /dev/kvm and /dev/vhost-net but failed without sudo, it can't use sudo to check them since sudo is not a must, sudo is only required when need create tap interface, this patch can enable it automatically. Enable kvm can improve qemu's performance a lot, when test perl-5.22's lib/warnings.t on qemux86-64, 70 times improved. Signed-off-by: Robert Yang <liezhi.yang@windriver.com>
Diffstat (limited to 'scripts/runqemu-internal')
-rwxr-xr-xscripts/runqemu-internal14
1 files changed, 14 insertions, 0 deletions
diff --git a/scripts/runqemu-internal b/scripts/runqemu-internal
index 694815fb74..25533ecef5 100755
--- a/scripts/runqemu-internal
+++ b/scripts/runqemu-internal
@@ -217,6 +217,19 @@ else
sudo $QEMUIFUP $USERID $GROUPID $OECORE_NATIVE_SYSROOT
return 1
fi
+
+ # Enale kvm when possible since sudo works well, if
+ # /usr/include/linux/kvm.h exists, qemu-native is built with kvm
+ # support.
+ if [ "$KVM_ENABLED" = "maybe" -a -n "$KVM_CAPABLE" -a \
+ -e /dev/kvm -a -e /dev/vhost-net -a -f /usr/include/linux/kvm.h ] && \
+ [ "$MACHINE" = "qemux86" -o "$MACHINE" = "qemux86-64" ]; then
+ echo "Enabling KVM automatically, can be disabled by nokvm option"
+ SCRIPT_QEMU_OPT="$SCRIPT_QEMU_OPT -enable-kvm"
+ KVM_ACTIVE="yes"
+ KVM_SUDO="sudo"
+ fi
+
LOCKFILE="$LOCKDIR/$tap"
echo "Acquiring lockfile for $tap..."
acquire_lock $LOCKFILE
@@ -685,6 +698,7 @@ if [ "x$SERIALSTDIO" = "x1" ]; then
fi
echo "Running $QEMU..."
+[ -n "$KVM_SUDO" ] && QEMUBIN="$KVM_SUDO $QEMUBIN"
# -no-reboot is a mandatory option - see bug #100
if [ "$FSTYPE" = "vmdk" ]; then
echo $QEMUBIN $VM $QEMUOPTIONS $SERIALOPTS -no-reboot $SCRIPT_QEMU_OPT $SCRIPT_QEMU_EXTRA_OPT