qemux86: Support for KVM, paravirt and virtio added

KVM, paravirtualization and virtio drivers are now activated
in runqemu using the kvm option flag for qemux86.
Host CPU features are also exported to guest OS (Yocto Linux).
Usage example: runqemu qemux86 core-image-x11 kvm

Implements [YOCTO #2550].

(From OE-Core rev: a35d03e2eb905de4eadc9c7df5b50bff1fb7f897)

Signed-off-by: Cristian Iorga <cristian.iorga@intel.com>
Signed-off-by: Saul Wold <sgw@linux.intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
This commit is contained in:
Cristian Iorga 2012-09-19 10:06:54 +03:00 committed by Richard Purdie
parent 32fdbd879c
commit ab2b2a1f2a
3 changed files with 27 additions and 4 deletions

View File

@ -27,4 +27,5 @@ KERNEL_REVISION_CHECKING=""
KERNEL_FEATURES_append = " features/netfilter"
KERNEL_FEATURES_append_qemux86=" cfg/sound"
KERNEL_FEATURES_append_qemux86-64=" cfg/sound"
KERNEL_FEATURES_append_qemux86=" cfg/paravirt_kvm"
KERNEL_FEATURES_append = " ${@bb.utils.contains("TUNE_FEATURES", "mx32", " cfg/x32", "" ,d)}"

View File

@ -208,6 +208,7 @@ if [ -z "$MACHINE" ]; then
fi
YOCTO_KVM_WIKI="https://wiki.yoctoproject.org/wiki/How_to_enable_KVM_for_Poky_qemu"
YOCTO_PARAVIRT_KVM_WIKI="https://wiki.yoctoproject.org/wiki/Running_an_x86_Yocto_Linux_image_under_QEMU_KVM"
# Detect KVM configuration
if [ "x$KVM_ENABLED" = "xyes" ]; then
if [ -z "$KVM_CAPABLE" ]; then
@ -226,14 +227,27 @@ 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 9<>/dev/kvm ; then
SCRIPT_QEMU_OPT="$SCRIPT_QEMU_OPT -enable-kvm"
SCRIPT_QEMU_OPT="$SCRIPT_QEMU_OPT -enable-kvm -cpu host"
KVM_ACTIVE="yes"
else
echo "You have no rights on /dev/kvm."
echo "Please change the ownership of this file as described at"
echo "$YOCTO_KVM_WIKI";
exit 1;
fi
if [ ! -w /dev/vhost-net -a -r /dev/vhost-net ]; then
echo "You have no rights on /dev/vhost-net."
echo "Please change the ownership of this file as described at"
echo "$YOCTO_PARAVIRT_KVM_WIKI";
exit 1;
fi
fi
machine2=`echo $MACHINE | tr 'a-z' 'A-Z' | sed 's/-/_/'`

View File

@ -221,7 +221,15 @@ n2=$(($n1 + 1))
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"
QEMU_NETWORK_CMD="-net nic,vlan=0 $QEMU_TAP_CMD"
if [ "$KVM_ACTIVE" = "yes" ]; then
QEMU_NETWORK_CMD="-net nic,model=virtio $QEMU_TAP_CMD,vhost=on"
DROOT="/dev/vda"
ROOTFS_OPTIONS="-drive file=$ROOTFS,if=virtio"
else
QEMU_NETWORK_CMD="-net nic,vlan=0 $QEMU_TAP_CMD"
DROOT="/dev/hda"
ROOTFS_OPTIONS="-hda $ROOTFS"
fi
KERNCMDLINE="mem=$QEMU_MEMORY"
QEMU_UI_OPTIONS="-show-cursor -usb -usbdevice wacom-tablet"
@ -321,8 +329,8 @@ if [ "$MACHINE" = "qemux86" ]; then
QEMU=qemu-system-i386
QEMU_UI_OPTIONS="$QEMU_UI_OPTIONS -vga vmware"
if [ "$FSTYPE" = "ext2" -o "$FSTYPE" = "ext3" -o "$FSTYPE" = "btrfs" ]; then
KERNCMDLINE="vga=0 root=/dev/hda rw mem=$QEMU_MEMORY $KERNEL_NETWORK_CMD"
QEMUOPTIONS="$QEMU_NETWORK_CMD -hda $ROOTFS $QEMU_UI_OPTIONS"
KERNCMDLINE="vga=0 root=$DROOT rw mem=$QEMU_MEMORY $KERNEL_NETWORK_CMD"
QEMUOPTIONS="$QEMU_NETWORK_CMD $ROOTFS_OPTIONS $QEMU_UI_OPTIONS"
fi
if [ "$FSTYPE" = "nfs" ]; then
if [ "$NFS_SERVER" = "192.168.7.1" -a ! -d "$NFS_DIR" ]; then