设为首页 收藏本站
查看: 949|回复: 0

[经验分享] kvm+qemu

[复制链接]

尚未签到

发表于 2015-10-10 10:36:10 | 显示全部楼层 |阅读模式
首先要搞清楚是 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

运维网声明 1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com

所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其承担任何法律责任,如涉及侵犯版权等问题,请您及时通知我们,我们将立即处理,联系人Email:kefu@iyunv.com,QQ:1061981298 本贴地址:https://www.yunweiku.com/thread-125001-1-1.html 上篇帖子: how to tell if you can use kvm 下篇帖子: Qemu-KVM管理
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

扫码加入运维网微信交流群X

扫码加入运维网微信交流群

扫描二维码加入运维网微信交流群,最新一手资源尽在官方微信交流群!快快加入我们吧...

扫描微信二维码查看详情

客服E-mail:kefu@iyunv.com 客服QQ:1061981298


QQ群⑦:运维网交流群⑦ QQ群⑧:运维网交流群⑧ k8s群:运维网kubernetes交流群


提醒:禁止发布任何违反国家法律、法规的言论与图片等内容;本站内容均来自个人观点与网络等信息,非本站认同之观点.


本站大部分资源是网友从网上搜集分享而来,其版权均归原作者及其网站所有,我们尊重他人的合法权益,如有内容侵犯您的合法权益,请及时与我们联系进行核实删除!



合作伙伴: 青云cloud

快速回复 返回顶部 返回列表