kvm+qemu

首先要搞清楚是 qemu,kqemu,kvm三者之间的关系。实际上,qemu 是一套完整的虚拟系统,kqemu 是qemu加速器,相当于其增强插件。kvm是另一套虚拟系统,包括内核虚拟构架和处理器相关模块,但其借用了 quem 其它一些组件。

qemu 在没有 kqemu 增强下,的确是很慢得让人受不了,因为要编译 kqemu 模块,但因为 debian 源里的 source 中 makefile 中缺少某些 rules ,导致编译不成功,再加上 kvm 已经很快了,所以就没有试 kqeum。

kvm 采用 qemu 一样的参数,网上有很多相关的帖子。

以前一直用 virtualbox,它的性能也很不错,cpu 占用也很少,和 qemu 一样,图形性能较差,但也比 qemu 好那么一点。然而,vbox 中 cpu 占用就高了一点。相比较 kvm 存在的一些缺点如下:
1,不能使用 direct3d,
2,不能和主机一起使用声音系统,可能是设置没有弄好而已,
3,鼠标有点慢,最大化后还原就好了,
4,缺少一些 vbox 中的小功能,如“自动调整显示尺寸”,“无缝模式”,”鼠标自动移出“等

参数:

kvm -daemonize -hda winxp.img -m 512 -smp 2 -std-vga -net nic,model=virtio -net user -soundhw all -localtime

注:用 std vga 可以用更多的显示分辨率(要装驱动),用 virtio 可以用 1gb 网卡。

参考:
kvm全教程
http://forum.ubuntu.org.cn/viewtopic.php?f=65&t=130210 

kvm windows显卡驱动安装
http://forum.ubuntu.org.cn/viewtopic.php?f=65&t=156644&start=0

kvm官方
http://www.linux-kvm.org/page/Main_Page [+❤]

qemu官方

http://www.nongnu.org/qemu/about.html [+]q






What user space tools does KVM use?

KVM uses a slightly modified QEMU program to instantiate the virtual machine. Once running, a virtual machine is just a regular process. You can use `top(1), kill(1), taskset(1)` and similar tools to manage virtual machines.




http://qemu.weilnetz.de/qemu-tech.html

2.1 QEMU compared to other emulators

Like bochs [3], QEMU emulates an x86 CPU. But QEMU is much faster than bochs as it uses dynamic compilation. Bochs is closely tied to x86 PC emulation while QEMU can emulate several processors.

Like Valgrind [2], QEMU does user space emulation and dynamic translation. Valgrind is mainly a memory debugger while QEMU has no support for it (QEMU could be used to detect out of bound memory accesses as Valgrind, but it has no support to track uninitialised data as Valgrind does). The Valgrind dynamic translator generates better code than QEMU (in particular it does register allocation) but it is closely tied to an x86 host and target and has no support for precise exceptions and system emulation.

EM86 [4] is the closest project to user space QEMU (and QEMU still uses some of its code, in particular the ELF file loader). EM86 was limited to an alpha host and used a proprietary and slow interpreter (the interpreter part of the FX!32 Digital Win32 code translator [5]).

TWIN [6] is a Windows API emulator like Wine. It is less accurate than Wine but includes a protected mode x86 interpreter to launch x86 Windows executables. Such an approach has greater potential because most of the Windows API is executed natively but it is far more difficult to develop because all the data structures and function parameters exchanged between the API and the x86 code must be converted.

User mode Linux [7] was the only solution before QEMU to launch a Linux kernel as a process while not needing any host kernel patches. However, user mode Linux requires heavy kernel patches while QEMU accepts unpatched Linux kernels. The price to pay is that QEMU is slower.

The Plex86 [8] PC virtualizer is done in the same spirit as the now obsolete qemu-fast system emulator. It requires a patched Linux kernel to work (you cannot launch the same kernel on your PC), but the patches are really small. As it is a PC virtualizer (no emulation is done except for some privileged instructions), it has the potential of being faster than QEMU. The downside is that a complicated (and potentially unsafe) host kernel patch is needed.

The commercial PC Virtualizers (VMWare [9], VirtualPC [10], TwoOStwo [11]) are faster than QEMU, but they all need specific, proprietary and potentially unsafe host drivers. Moreover, they are unable to provide cycle exact simulation as an emulator can.

VirtualBox [12], Xen [13] and KVM [14] are based on QEMU. QEMU-SystemC [15] uses QEMU to simulate a system where some hardware devices are developed in SystemC.



kvm  http://www.linux-kvm.org/page/Choose_the_right_kvm_%26_kernel_version
Three Components

To make it work, you need to get the right version for three components:

  • Linux Module
  • User Space Application
  • Guest Virtio Driver

Linux Module

KVM requires a linux kernel module to support full virtualization. The linux module consists of three files: kvm.ko, kvm_intel.ko (for Intel processors), kvm_amd.ko (for AMD processors). You can install these modules just like you install drivers for your video card. The good news is, you may not need to install anything - the 2.6.20 kernel version (and higher) includes these kernel modules as part of the mainline kernel. It will depend on your distribution configuration whether these modules are actually in the distribution kernel as a built-in or provided as modules (or possibly absent). Here is a table listing the relation of KVM module versions to mainline kernel releases:

  • 2.6.20 kvm-12
  • 2.6.21 kvm-17
  • 2.6.22 kvm-22

If you are not sure your linux distribution contain it or not, use this command:

modprobe -l | grep kvm

The linux module can be built from source code. This is also the recommended way to get the right version of linux module. Compiling from the source code, and than make install should make the linux module inserted into your /lib/modules/linux-`uname -r`. Simply make it in use by:

modprobe kvm
modprobe kvm_intel

or

modprobe kvm
modprobe kvm_amd

User space application

Compile from source code, you can get it. Otherwise, refer to the previous section.

Guest virtio driver

There was no special requirement for guest operating system if you are not using para-visualized disk ornetwork adapter. If you are using them, make sure you get virtio_pci.ko, virtio_rng.ko, virtio_blk.ko, virtio_net.ko. They are in 2.6.25 or later kernel. There is also a option to backport them.

Refer to Virtio for more information




你可能感兴趣的:(kvm+qemu)