runqemu: Enable support for kvm without vhost in x86 and x86_64

KVM can be used without vhost so add a new option to runqemu for
use kvm with vhost.

Example,
	runqemu qemux86 core-image-minimal kvm # kvm without vhost
	runqemu qemux86 core-image-minimal kvm-vhost # kvm with vhost

[YOCTO #7443]

(From OE-Core rev: 7f5f8f87a4180a2b05188047c6a05da5571f94e2)

Signed-off-by: Aníbal Limón <anibal.limon@linux.intel.com>
Signed-off-by: Ross Burton <ross.burton@intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
This commit is contained in:
Aníbal Limón 2015-10-22 10:18:37 -05:00 committed by Richard Purdie
parent 135d09454c
commit eebcbe19b7
2 changed files with 27 additions and 12 deletions

View File

@ -33,6 +33,7 @@ usage() {
echo " nographic - disables video console"
echo " serial - enables a serial console on /dev/ttyS0"
echo " kvm - enables KVM when running qemux86/qemux86-64 (VT-capable CPU required)"
echo " kvm-vhost - enables KVM with vhost support when running qemux86/qemux86-64 (VT-capable CPU required)"
echo " publicvnc - enable a VNC server open to all hosts"
echo " qemuparams=\"xyz\" - specify custom parameters to QEMU"
echo " bootparams=\"xyz\" - specify custom kernel parameters during boot"
@ -71,6 +72,8 @@ SERIALSTDIO=""
TCPSERIAL_PORTNUM=""
KVM_ENABLED="no"
KVM_ACTIVE="no"
VHOST_ENABLED="no"
VHOST_ACTIVE="no"
# Determine whether the file is a kernel or QEMU image, and set the
# appropriate variables
@ -170,6 +173,11 @@ while true; do
KVM_ENABLED="yes"
KVM_CAPABLE=`grep -q 'vmx\|svm' /proc/cpuinfo && echo 1`
;;
"kvm-vhost")
KVM_ENABLED="yes"
KVM_CAPABLE=`grep -q 'vmx\|svm' /proc/cpuinfo && echo 1`
VHOST_ENABLED="yes"
;;
"slirp")
SLIRP_ENABLED="yes"
;;
@ -270,12 +278,6 @@ if [ "x$KVM_ENABLED" = "xyes" ]; then
echo "$YOCTO_KVM_WIKI";
exit 1;
fi
if [ ! -e /dev/vhost-net ]; then
echo "Missing virtio net device. Have you inserted vhost-net module?"
echo "For further help see:"
echo "$YOCTO_PARAVIRT_KVM_WIKI";
exit 1;
fi
if [ -w /dev/kvm -a -r /dev/kvm ]; then
SCRIPT_QEMU_OPT="$SCRIPT_QEMU_OPT -enable-kvm"
KVM_ACTIVE="yes"
@ -285,13 +287,22 @@ if [ "x$KVM_ENABLED" = "xyes" ]; then
echo "$YOCTO_KVM_WIKI";
exit 1;
fi
if [ ! -w /dev/vhost-net -o ! -r /dev/vhost-net ]; then
if [ "$SLIRP_ENABLED" != "yes" ] ; then
echo "You have no rights on /dev/vhost-net."
echo "Please change the ownership of this file as described at:"
if [ "x$VHOST_ENABLED" = "xyes" ]; then
if [ ! -e /dev/vhost-net ]; then
echo "Missing virtio net device. Have you inserted vhost-net module?"
echo "For further help see:"
echo "$YOCTO_PARAVIRT_KVM_WIKI";
exit 1;
fi
fi
if [ -w /dev/vhost-net -a -r /dev/vhost-net ]; then
VHOST_ACTIVE="yes"
else
echo "You have no rights on /dev/vhost-net."
echo "Please change the ownership of this file as described at:"
echo "$YOCTO_KVM_WIKI";
exit 1;
fi
fi
fi

View File

@ -267,7 +267,11 @@ else
KERNEL_NETWORK_CMD="ip=192.168.7.$n2::192.168.7.$n1:255.255.255.0"
QEMU_TAP_CMD="-net tap,vlan=0,ifname=$TAP,script=no,downscript=no"
if [ "$KVM_ACTIVE" = "yes" ]; then
QEMU_NETWORK_CMD="-net nic,model=virtio $QEMU_TAP_CMD,vhost=on"
if [ "$VHOST_ACTIVE" = "yes" ]; then
QEMU_NETWORK_CMD="-net nic,model=virtio $QEMU_TAP_CMD,vhost=on"
else
QEMU_NETWORK_CMD="-net nic,model=virtio $QEMU_TAP_CMD"
fi
DROOT="/dev/vda"
ROOTFS_OPTIONS="-drive file=$ROOTFS,if=virtio,format=raw"
else