KVM、QEMU和KQemu有啥区别
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了KVM、QEMU和KQemu有啥区别相关的知识,希望对你有一定的参考价值。
参考技术AKVM、QEMU和KQemu的区别:
1、KVM包括很多部件,它是一个Linux内核模块(现在包括在主线中)用于转换处理器到一种新的用户 (guset)模式。Qemu是一个完整的可以单独运行的软件;作为一个内核模块,KQemu仅仅需要替换最底层的ring0-only指令。
2、Qemu它可以用来模拟机器,非常灵活和可移植。它主要通过一个特殊的'重编译器'将为特定处理器编写二进制代码转换为另一种。(也就是,在PPCmac上面运行MIPS代码,或者在X86 PC上运行ARM代码)
3、KQemu当源和目标代码有同样的架构的时候,同样需要解析代码去出去任
何'特权指令'并且把它们替换为上下文转换。为了尽量使这个过程有效,有个内核模块KQemu处理这个事情。
作为一个内核模块,KQemu仅仅需要替换最底层的ring0-only指令。KQemu不需要重新编译代码,它仅仅调用KQemu去扫描/打补丁/执行。所有外围的硬件仿真是在Qemu中做的。
扩展资料:
QEMU的两种主要运作模式:
1、User mode模拟模式,亦即是用户模式。QEMU能启动那些为不同中央处理器编译的Linux程序。而Wine及Dosemu是其主要目标。
2、System mode模拟模式,亦即是系统模式。QEMU能模拟整个电脑系统,包括中央处理器及其他周边设备。它使得为跨平台编写的程序进行测试及除错工作变得容易。其亦能用来在一部主机上虚拟数部不同虚拟电脑。
QEMU的主体部份是在LGPL下发布的,而其系统模式模拟则是在GPL下发布;而kqemu这个加速器则是在免费但闭源的条件下发布的。使用kqemu可使QEMU能模拟至接近实机速度,但其在虚拟的操作系统是 Microsoft Windows 98或以下的情况下是无用的。
参考资料:百度百科_QEMU
KVM 核心功能:CPU 虚拟化
1 vCPU 简介
[root@lianhua qemu-kvm]# /usr/libexec/qemu-kvm -smp 2 -m 1G lianhua.qcow -monitor stdio QEMU 2.6.0 monitor - type ‘help‘ for more information (qemu) VNC server running on ‘::1;5900‘ (qemu) info cpus * CPU #0: pc=0x000000003fefa56a thread_id=1019305 CPU #1: pc=0x00000000000fd374 (halted) thread_id=1019307 (qemu) info cpus * CPU #0: pc=0x000000003ff0d4ea (halted) thread_id=1019305 CPU #1: pc=0x00000000000fd374 (halted) thread_id=1019307 [root@lianhua home]# ps -eLf | grep qemu root 1019294 1014044 1019294 0 5 12:53 pts/0 00:00:00 /usr/libexec/qemu-kvm -smp 2 -m 1G lianhua.qcow -monitor stdio root 1019294 1014044 1019300 0 5 12:53 pts/0 00:00:00 /usr/libexec/qemu-kvm -smp 2 -m 1G lianhua.qcow -monitor stdio root 1019294 1014044 1019305 6 5 12:53 pts/0 00:00:12 /usr/libexec/qemu-kvm -smp 2 -m 1G lianhua.qcow -monitor stdio root 1019294 1014044 1019307 0 5 12:53 pts/0 00:00:00 /usr/libexec/qemu-kvm -smp 2 -m 1G lianhua.qcow -monitor stdio root 1019294 1014044 1019309 0 5 12:53 pts/0 00:00:00 /usr/libexec/qemu-kvm -smp 2 -m 1G lianhua.qcow -monitor stdio
2 vCPU 配置
[root@lianhua qemu-kvm]# /usr/libexec/qemu-kvm -smp 2 -m 1G lianhua.qcow -monitor stdio
[root@lianhua qemu-kvm]# /usr/libexec/qemu-kvm -smp 3,sockets=3,cores=1,threads=1 -m 1G lianhua.qcow -monitor stdio
<vcpu placement=‘static‘>6</vcpu> <cputune> <shares>6144</shares> <vcpupin vcpu=‘0‘ cpuset=‘9‘/> <vcpupin vcpu=‘1‘ cpuset=‘37‘/> <vcpupin vcpu=‘2‘ cpuset=‘11‘/> <vcpupin vcpu=‘3‘ cpuset=‘39‘/> <vcpupin vcpu=‘4‘ cpuset=‘34‘/> <vcpupin vcpu=‘5‘ cpuset=‘6‘/> <emulatorpin cpuset=‘6,9,11,34,37,39‘/> </cputune>
<cpu mode=‘host-model‘> <model fallback=‘allow‘/> <topology sockets=‘3‘ cores=‘1‘ threads=‘2‘/> <numa> <cell id=‘0‘ cpus=‘0-5‘ memory=‘33554432‘ unit=‘KiB‘ memAccess=‘shared‘/> </numa> </cpu>
$ cat /proc/cpuinfo processor : 0 vendor_id : GenuineIntel cpu family : 6 model : 61 model name : Intel Core Processor (Broadwell) stepping : 2 microcode : 0x1 cpu MHz : 2394.454 cache size : 4096 KB physical id : 0 siblings : 2 core id : 0 cpu cores : 1 apicid : 0 initial apicid : 0 fpu : yes fpu_exception : yes cpuid level : 13 wp : yes flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 ss ht syscall nx pdpe1gb rdtscp lm constant_tsc rep_good nopl cpuid tsc_known_freq pni pclmulqdq ssse3 fma cx16 pcid sse4_1 sse4_2 x2apic movbe popcnt tsc_deadline_timer aes xsave avx f16c rdrand hypervisor lahf_lm abm 3dnowprefetch invpcid_single pti fsgsbase tsc_adjust bmi1 hle avx2 smep bmi2 erms invpcid rtm rdseed adx smap xsaveopt arat bugs : cpu_meltdown spectre_v1 spectre_v2 spec_store_bypass l1tf mds swapgs taa itlb_multihit srbds bogomips : 4788.90 clflush size : 64 cache_alignment : 64 address sizes : 46 bits physical, 48 bits virtual power management: ... $ /bin/bash cpu.sh The physical cpu is: 3 core number in a physical cpu: 1 logical cpu number in a physical cpu: 2 The hyper threading is enabled, each core has 2 threads logical cpu number in host: 6
3 vCPU 特性
3.1 vCPU overcommit
3.2 vCPU 热插拔
[root@lianhua qemu-kvm]# /usr/libexec/qemu-kvm -smp 3,maxcpus=5,sockets=3,cores=1,threads=1 -m 1G lianhua.qcow -monitor stdio QEMU 2.6.0 monitor - type ‘help‘ for more information (qemu) VNC server running on ‘::1;5900‘ (qemu) info cpus * CPU #0: pc=0x000000003fefa56a thread_id=356200 CPU #1: pc=0x00000000000fd374 (halted) thread_id=356201 CPU #2: pc=0x00000000000fd374 (halted) thread_id=356203 (qemu) cpu-add 3 (qemu) info cpus * CPU #0: pc=0x00000000000fc373 (halted) thread_id=356200 CPU #1: pc=0x00000000000fd374 (halted) thread_id=356201 CPU #2: pc=0x00000000000fd374 (halted) thread_id=356203 CPU #3: pc=0x00000000fffffff0 thread_id=357997
3.3 vCPU 亲和性
<vcpu placement=‘static‘>6</vcpu> <cputune> <shares>6144</shares> <vcpupin vcpu=‘0‘ cpuset=‘9‘/> <vcpupin vcpu=‘1‘ cpuset=‘37‘/> <vcpupin vcpu=‘2‘ cpuset=‘11‘/> <vcpupin vcpu=‘3‘ cpuset=‘39‘/> <vcpupin vcpu=‘4‘ cpuset=‘34‘/> <vcpupin vcpu=‘5‘ cpuset=‘6‘/> <emulatorpin cpuset=‘6,9,11,34,37,39‘/> </cputune>
[root@lianhua home]# ps -eLo ruser,pid,ppid,lwp,psr,args | grep qemu | grep -v grep ... [root@lianhua home]# ps -eLo ruser,pid,ppid,lwp,psr,args | awk ‘{if($5==37) print $0}‘ root 193 2 193 37 [watchdog/37] root 194 2 194 37 [migration/37] root 195 2 195 37 [ksoftirqd/37] root 196 2 196 37 [kworker/37:0] root 197 2 197 37 [kworker/37:0H] root 145760 2 145760 37 [kworker/37:1] qemu 879955 1 880096 37 /usr/libexec/qemu-kvm -name guest=lianhua ...
[root@lianhua home]# ps -eLo ruser,pid,ppid,lwp,psr,args | awk ‘{if($5==40) print $0}‘ root 208 2 208 40 [watchdog/40] root 209 2 209 40 [migration/40] root 210 2 210 40 [ksoftirqd/40] root 212 2 212 40 [kworker/40:0H] root 390900 2 390900 40 [kworker/40:0] root 673792 2 673792 40 [kworker/40:1] root 674097 2 674097 40 [kworker/40:1H] [root@lianhua home]# ps -eLo ruser,pid,ppid,lwp,psr,args | awk ‘{if($5==41) print $0}‘ root 213 2 213 41 [watchdog/41] root 214 2 214 41 [migration/41] root 215 2 215 41 [ksoftirqd/41] root 216 2 216 41 [kworker/41:0] root 217 2 217 41 [kworker/41:0H]
以上是关于KVM、QEMU和KQemu有啥区别的主要内容,如果未能解决你的问题,请参考以下文章