KVM和QEMU的关系
2014-04-15 15:02
585 查看
下面文件很好解析KVM和QEMU的关系
http://www.innervoice.in/blogs/2014/03/10/kvm-and-qemu/
If you were to ask someone “what is the most popular open source hypervisor” chances are that the answer will be KVM. Indeed KVM (or Kernel-based Virtual Machine) has played a key role in the open source Linux based virtualization environment. However is
it really a hypervisor? Moreover, can KVM by itself run virtual machines? We will delve more into such questions in this blog. We will also understand the relationship between KVM and QEMU (Quick EMUlator).
did a grep of the process ID to see if there was any difference.
Note: I used Ubuntu 13.10 for my experiments.
When I started the VM with KVM as the Virt Type the process ID details showed an interesting attribute “accel=kvm” as highlighted below.
When I started the same Virtual Machine with QEMU as the Virt Type, the process ID showed “accel=tcg”.
Note that in both the cases the same binary is executed to start the VM, namely,
qemu-system-x86_64. The main difference is the acceleration type.
However, the key difference is that the Virtual CPU is actually emulated (or virtualized) by the hypervisor. Therefore, the hypervisor software has to
translate the instructions meant for the Virtual CPU and convert it into instructions for the physical CPU. This translation has a big performance overhead.
To minimize this performance overhead, modern processors support virtualization extensions. Intel support a technology called VT-x and the AMD equivalent is AMD-V. Using these technologies, a slice of physical CPU can be directly mapped
to the Virtual CPU. Hence the instructions meant for the Virtual CPU can be directly executed the physical CPU slice.
KVM is the Linux kernel module that enables this mapping of physical CPU to Virtual CPU. This mapping provides the hardware acceleration for Virtual Machine and boosts its performance. Moreover, QEMU uses this acceleration when Virt Type
is chosen as KVM.
Then what is TCG? If your server CPU does not support virtualization extension, then it is the job of the emulator (or hypervisor) to execute the Virtual CPU instruction using translation. QEMU uses TCG or Tiny Code Generator to optimally translate and
execute the Virtual CPU instructions on the physical CPU.
KVM and
QEMU clearly show that KVM needs QEMU to provide full hypervisor functionality. By itself, KVM is more of a virtualization infrastructure provider.
QEMU by itself is a Type-2 hypervisor. It intercepts the instructions meant for Virtual CPU and uses the host operating system to get those instructions executed on the physical CPU. When QEMU uses KVM for hardware acceleration, the combination becomes
a Type-1 hypervisor. This difference is quite clear from the description on the QEMU website.
also uses the same architecture (x86).
If a VM needs to run Power PC CPU but the hypervisor server has an Intel CPU, then KVM will not work. You must use QEMU as the Virt Type and live with the performance overhead.
For all practical applications, QEMU needs KVM’s performance boost. However, it is clear that
KVM by itself cannot provide the complete virtualization solution. It needs QEMU.
http://www.innervoice.in/blogs/2014/03/10/kvm-and-qemu/
If you were to ask someone “what is the most popular open source hypervisor” chances are that the answer will be KVM. Indeed KVM (or Kernel-based Virtual Machine) has played a key role in the open source Linux based virtualization environment. However is
it really a hypervisor? Moreover, can KVM by itself run virtual machines? We will delve more into such questions in this blog. We will also understand the relationship between KVM and QEMU (Quick EMUlator).
KVM and QEMU – the process ID check
You can use libvirt and the associated Virtual Machine Manager GUI to start a virtual machine. In the GUI, you can choose the ‘Virt Type’ as either KVM or QEMU. I started a VM, once with QEMU as the Virt Type and once with KVM. In both cases, Idid a grep of the process ID to see if there was any difference.
Note: I used Ubuntu 13.10 for my experiments.
When I started the VM with KVM as the Virt Type the process ID details showed an interesting attribute “accel=kvm” as highlighted below.
When I started the same Virtual Machine with QEMU as the Virt Type, the process ID showed “accel=tcg”.
Note that in both the cases the same binary is executed to start the VM, namely,
qemu-system-x86_64. The main difference is the acceleration type.
KVM and QEMU – understanding hardware acceleration
To understand hardware acceleration, we must understand how Virtual Machine CPU works. In real hardware, the Operating System (OS) translates programs into instructions that are executed by the physical CPU. In a virtual machine, the same thing happens.However, the key difference is that the Virtual CPU is actually emulated (or virtualized) by the hypervisor. Therefore, the hypervisor software has to
translate the instructions meant for the Virtual CPU and convert it into instructions for the physical CPU. This translation has a big performance overhead.
To minimize this performance overhead, modern processors support virtualization extensions. Intel support a technology called VT-x and the AMD equivalent is AMD-V. Using these technologies, a slice of physical CPU can be directly mapped
to the Virtual CPU. Hence the instructions meant for the Virtual CPU can be directly executed the physical CPU slice.
KVM is the Linux kernel module that enables this mapping of physical CPU to Virtual CPU. This mapping provides the hardware acceleration for Virtual Machine and boosts its performance. Moreover, QEMU uses this acceleration when Virt Type
is chosen as KVM.
Then what is TCG? If your server CPU does not support virtualization extension, then it is the job of the emulator (or hypervisor) to execute the Virtual CPU instruction using translation. QEMU uses TCG or Tiny Code Generator to optimally translate and
execute the Virtual CPU instructions on the physical CPU.
KVM and QEMU – Type 1 or Type 2 hypervisor
The web pages ofKVM and
QEMU clearly show that KVM needs QEMU to provide full hypervisor functionality. By itself, KVM is more of a virtualization infrastructure provider.
QEMU by itself is a Type-2 hypervisor. It intercepts the instructions meant for Virtual CPU and uses the host operating system to get those instructions executed on the physical CPU. When QEMU uses KVM for hardware acceleration, the combination becomes
a Type-1 hypervisor. This difference is quite clear from the description on the QEMU website.
KVM and QEMU – the x86 dependency
Since KVM is really a driver for the physical CPU capabilities, it is very tightly associated with the CPU architecture (the x86 architecture). This means that the benefits of hardware acceleration will be available only if the Virtual Machine CPUalso uses the same architecture (x86).
If a VM needs to run Power PC CPU but the hypervisor server has an Intel CPU, then KVM will not work. You must use QEMU as the Virt Type and live with the performance overhead.
KVM and QEMU – the conclusion
Based on the discussion above, it is quite clear that QEMU plays a very critical role in Linux based Open Source virtualization solutions.For all practical applications, QEMU needs KVM’s performance boost. However, it is clear that
KVM by itself cannot provide the complete virtualization solution. It needs QEMU.
相关文章推荐
- ruby on rails 手动添加测试文件
- Eclipse上GIT插件EGIT使用手册之三_新建GIT仓库
- SD相关的表
- faad解码aac
- 20140415收盘小结
- 求m*n矩阵中最大的子矩阵(元素和最大)
- HTTP协议漫谈
- JAVA设计模式(05):创建型-原型模式(Prototype)
- gridview中数据的导出
- pjsip学习资料总汇
- ios之使程序在后台能继续运行
- Annotation(二):反射与Annotation、系统内建的 注释Annotation的注释
- SAP流水号
- faac编码aac
- 平板级的电池续航 三星Galaxy S5续航出炉
- 使用QuickXDev不能跳转
- 数字图像加密算法
- linux常用命令学习
- js常用知识真理
- centos ssh服务开启