BKM: improve qemu performance: Difference between revisions

From Yocto Project
Jump to navigationJump to search
No edit summary
No edit summary
Line 32: Line 32:
== Enable virtio block and network device ==
== Enable virtio block and network device ==
Virtio (block/network) device is a para-virtualized device for kvm guest. It is different from normal emulated hard drive, because it is simply faster.  
Virtio (block/network) device is a para-virtualized device for kvm guest. It is different from normal emulated hard drive, because it is simply faster.  
# enable yocto kernel configuration
* enable yocto kernel configuration
  +CONFIG_VIRTIO=y
  +CONFIG_VIRTIO=y
  +CONFIG_VIRTIO_PCI=y
  +CONFIG_VIRTIO_PCI=y
Line 39: Line 39:
  +CONFIG_VIRTIO_NET=y
  +CONFIG_VIRTIO_NET=y
  +CONFIG_VIRTIO_BLK=y
  +CONFIG_VIRTIO_BLK=y
# change qemu block device parameter from "-hda <your_disk_image" to '''-drive file=<your_disk_image>,if=virtio'''
* change qemu block device parameter from "-hda <your_disk_image" to '''-drive file=<your_disk_image>,if=virtio'''

Revision as of 13:26, 6 December 2011

Link title= improve qemu performance = Qemu in yocto is emulator, and is slow when running huge task inside. E.g. running yocto build inside qemu. This article illustrate possible performance improvement to accelerate it

Enable KVM

If you have processor with VTx support, you can enable KVM so that virtualization rather than emulation is used for performance. Pls. refer following:

Add big memory

Sometimes, workload inside qemu requires huge memory. Fail to do this lead performance drop. So pls. add enough memory to qemu via -m 2048 (2G).

Enable SMP

If workload inside qemu is CPU-intensive, you can enable smp:

  • enable smp configuration in yocto kernel
  • enable smp option for qemu, like -smp 4 to give 4 vcpu to guest.

Add extra disk space

If workload inside qemu is disk-intensive, it may requires huge disk space. You can set up NFS server or add extra disk image, which is preferred as NFS server introduce extra network workload. Following steps to create a new disk image(10G) with ext3 file system:

$ sudo dd if=/dev/zero of=b.img bs=1G count=10
$ sudo losetup /dev/loop0 b.img
$ sudo fdisk /dev/loop0
 Then create one new single partition
$ sudo mkfs.ext3 /dev/loop0
 to create ext3 file system
$ sudo losetup -d /dev/loop0

append this disk image to qemu via -hdb(need further changes if need virtio block device)

Create network environment

Default qemu in yocto talk with host via simple 192.168.7.X, you can use bridge to make the guest act as one true machine, E.g download source code from outside. Pls. see http://www.linux-kvm.org/page/Networking#public_bridge for details

Enable virtio block and network device

Virtio (block/network) device is a para-virtualized device for kvm guest. It is different from normal emulated hard drive, because it is simply faster.

  • enable yocto kernel configuration
+CONFIG_VIRTIO=y
+CONFIG_VIRTIO_PCI=y
+CONFIG_VIRTIO_BALLOON=y
+CONFIG_VIRTIO_RING=y
+CONFIG_VIRTIO_NET=y
+CONFIG_VIRTIO_BLK=y
  • change qemu block device parameter from "-hda <your_disk_image" to -drive file=<your_disk_image>,if=virtio