Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

qemu vs qemu-kvm: some performance measurements

I conducted the following benchmark in qemu and qemu-kvm, with the following configuration:

CPU: AMD 4400 process dual core with svm enabled, 2G RAM
Host OS: OpenSUSE 11.3 with latest Patch, running with kde4
Guest OS: FreeDos
Emulated Memory: 256M
Network: Nil
Language: Turbo C 2.0
Benchmark Program: Count from 0000000 to 9999999. Display the counter on the screen
     by direct accessing the screen memory (i.e. 0xb800:xxxx)

It only takes 6 sec when running in qemu.

But it takes 89 sec when running in qemu-kvm.

I ran the benchmark one by one, not in parallel.

I scratched my head the whole night, but still not idea why this happens. Would somebody give me some hints?

like image 303
bio2com2 Avatar asked Mar 27 '11 15:03

bio2com2


People also ask

Is QEMU better than KVM?

KVM is a Linux-based full virtualization solution, so you can definitely use it without QEMU. However, if you are looking for a powerful type-1 hypervisor that provides better performance and stability, using KVM and QEMU together is your best bet.

What's the difference between QEMU and KVM?

So to conclude: QEMU is a type 2 hypervisor that runs within user space and performs virtual hardware emulation, whereas KVM is a type 1 hypervisor that runs in kernel space, that allows a user space program access to the hardware virtualization features of various processors.

How can I make QEMU run faster?

Qemu can be compiled with (fast) or without (slow) kvm support. To use kvm you need to compile for the same architecture and load the kvm module in the kernel. Qemu can be compiled with (fast) or without (slow) kvm support. To use kvm you need to compile for the same architecture and load the kvm module in the kernel.

Is QEMU slower than VirtualBox?

QEMU/KVM is better integrated in Linux, has a smaller footprint and should therefore be faster. VirtualBox is a virtualization software limited to x86 and amd64 architecture. Xen uses QEMU for the hardware assisted virtualization, but can also paravirtualize guests without hardware virtualisation.


1 Answers

KVM uses qemu as his device simulator, any device operation is simulated by user space QEMU program. When you write to 0xB8000, the graphic display is operated which involves guest's doing a CPU `vmexit' from guest mode and returning to KVM module, who in turn sends device simulation requests to user space QEMU backend.

In contrast, QEMU w/o KVM does all the jobs in unified process except for usual system calls, there's fewer CPU context switches. Meanwhile, your benchmark code is a simple loop which only requires code block translation for just one time. That cost nothing, compared to vmexit and kernel-user communication of every iteration in KVM case.

This should be the most probable cause.

like image 99
admiring_shannon Avatar answered Oct 04 '22 04:10

admiring_shannon