全虚拟化和半虚拟化(转)

CPU通过Ring级别进行访问控制的。Ring0是最高级别,Ring1、Ring2、Ring依次降低。

以Linux X86为例,操作系统(内核)的代码运行在Ring0上,可以使用特权指令,控制中断、修改页表、访问控制等。

应用程序的代码运行在最低级别Ring3上,不能做受控操作。如果需要访问磁盘、写文件,需要通过执行系统调用(函数),执行系统调用时,CPU的运行级别从Ring3到Ring0依次切换,并跳转到系统调用对应的内核代码位置执行,由内核完成设备访问,之后再从Ring0返回Ring3,实现用户态和内核态的切换。

基于二进制的全虚拟化:

 

因为宿主操作系统工作在Ring0,客户操作系统不能运行在Ring0,当客户操作系统执行特权指令时,就会发生错误。

虚拟机管理程序(VMM)就是负责客户操作系统和内核交互的驱动程序,运行在Ring0上,以驱动程序的形式体现(驱动程序工作在Ring0,否则不能驱动设备)。

当客户操作系统执行特权指令时,会触发异常(CPU机制,没权限的指令,触发异常),VMM捕获这个异常,在异常处做翻译、模拟,返回处理结构到客户操作系统内。客户操作系统认为自己的特权指令工作正常,继续运行。

通过复杂的异常处理过程,性能损耗比较大。

 

半虚拟化(准虚拟化):

通过修改客户操作系统代码,将原来在物理机上执行的一些特权指令,修改成可以和VMM直接交互的方式,实现操作系统的定制化。

半虚拟化技术XEN,就是通过为客户操作系统定制一个专门的内核版本,和X86、MIPS、ARM这些内核版本等价。

这样,就不会有捕获异常、翻译和模拟的过程,性能损耗比较少。

这也是XEN这种半虚拟化架构的优势,也是为什么XEN只支持Linux的虚拟化,不能虚拟化Windows的原因(微软不开源)。

 

基于硬件辅助的全虚拟化:

随着CPU厂商开始支持虚拟化,以X86 CPU为例,推出了支持Intel-VT的CPU,有VMX root operation和VMX non-root operation两种模式,两种模式都支持CPU运行的四个级别。

这样,VMM可以运行在root operation模式下,客户操作系统运行在non-root operation模式下。

通过硬件层做出区分,这样,在全虚拟化技术下,有些依靠“捕获异常-翻译-模拟”的实现就不需要了。

而且CPU厂商支持虚拟化的力度在不断加大,靠硬件辅助的虚拟化技术性能逐渐逼近半虚拟化,再加上全虚拟化不需要修改客户操作系统的优势,全虚拟化技术应该是未来的发展趋势。

 

全虚拟化技术:KVM、VMWare等。

半虚拟化技术:XEN等。

XEN是最典型的半虚拟化技术,不过随着全虚拟化的不断壮大,现在XEN也支持硬件辅助全虚拟化。

 

From:http://www.cnblogs.com/xusongwei/archive/2012/07/30/2615592.html

From:http://www.cnblogs.com/hsqdboke/p/4103415.html

转载于:https://www.cnblogs.com/xiaoerlang/p/7459504.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
In 1998, VMware figured out how to virtualize the x86 platform, once thought to be impossible, and created the market for x86 virtualization. The solution was a combination of binary translation and direct execution on the processor that allowed multiple guest OSes to run in full isolation on the same computer with readily affordable virtualization overhead. The savings that tens of thousands of companies have generated from the deployment of this technology is further driving the rapid adoption of virtualized computing from the desktop to the data center. As new vendors enter the space and attempt to differentiate their products, many are creating confusion with their marketing claims and terminology. For example, while hardware assist is a valuable technique that will mature and expand the envelope of workloads that can be virtualized, paravirtualization is not an entirely new technology that offers an “order of magnitude” greater performance. While this is a complex and rapidly evolving space, the technologies employed can be readily explained to help companies understand their options and choose a path forward. This white paper attempts to clarify the various techniques used to virtualize x86 hardware, the strengths and weaknesses of each, and VMware’s community approach to develop and employ the most effective of the emerging virtualization techniques. Figure 1 provides a summary timeline of x86 virtualization technologies from VMware’s binary translation to the recent application of kernel paravirtualization and hardware-assisted virtualization.
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值