kvm搭建完成了,那么问题来了,到底是什么原理

kvm中到底是怎么模拟的CPU和内存?

收到了大量的

这里有一个裸的调用kvm接口的实例,超赞:

1
2
<a href="http://www.cnblogs.com/Bozh/p/5753379.html" target="_blank">http://www.cnblogs.com/Bozh/p/5753379.html
</a>

 使用kvm的API来实现Emulator Demo,同样赞:

1
2
<a href="http://soulxu.github.io/blog/2014/08/11/use-kvm-api-write-emulator/" target="_blank" rel="noopener nofollow">http://soulxu.github.io/blog/2014/08/11/use-kvm-api-write-emulator/
</a>

 

 //-----2017.12.17  打开tracepoint,这是研究kvm的好方法:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
qemu-system-x86-10102 [001] d... 13485.390144: kvm_entry: vcpu 0
 qemu-system-x86-10102 [001] .N.. 13485.393300: kvm_exit: reason EXTERNAL_INTERRUPT rip 0x4009b2 info 0 800000ef
 qemu-system-x86-10102 [001] d... 13485.393301: kvm_fpu: unload
 qemu-system-x86-10102 [001] .... 13485.401393: kvm_ple_window: vcpu 0: ple_window 4096 (shrink 4096)
 qemu-system-x86-10102 [001] .... 13485.401398: kvm_fpu: load
 qemu-system-x86-10102 [001] .... 13485.401399: kvm_apic_accept_irq: apicid 0 vec 239 (Fixed|edge)
 qemu-system-x86-10102 [001] .... 13485.401400: kvm_inj_virq: irq 239
 qemu-system-x86-10102 [001] d... 13485.401401: kvm_entry: vcpu 0
 qemu-system-x86-10102 [001] .... 13485.401419: kvm_eoi: apicid 0 vector 239
 qemu-system-x86-10102 [001] .... 13485.401419: kvm_pv_eoi: apicid 0 vector 239
 qemu-system-x86-10102 [001] .... 13485.401420: kvm_exit: reason MSR_WRITE rip 0xffffffff81064508 info 0 0
 qemu-system-x86-10102 [001] .... 13485.401421: kvm_apic: apic_write APIC_TMICT = 0xafd2
 qemu-system-x86-10102 [001] .... 13485.401422: kvm_msr: msr_write 838 = 0xafd2
 qemu-system-x86-10102 [001] d... 13485.401422: kvm_entry: vcpu 0
 qemu-system-x86-10102 [001] .... 13485.402142: kvm_exit: reason EXTERNAL_INTERRUPT rip 0x4009b2 info 0 800000ef
 qemu-system-x86-10102 [001] .... 13485.402142: kvm_apic_accept_irq: apicid 0 vec 239 (Fixed|edge)
 qemu-system-x86-10102 [001] .... 13485.402143: kvm_inj_virq: irq 239
 qemu-system-x86-10102 [001] d... 13485.402143: kvm_entry: vcpu 0
 qemu-system-x86-10102 [001] .... 13485.402146: kvm_eoi: apicid 0 vector 239
 qemu-system-x86-10102 [001] .... 13485.402146: kvm_pv_eoi: apicid 0 vector 239
 qemu-system-x86-10102 [001] .... 13485.402146: kvm_exit: reason MSR_WRITE rip 0xffffffff81064508 info 0 0
 qemu-system-x86-10102 [001] .... 13485.402146: kvm_apic: apic_write APIC_TMICT = 0x3cee0
 qemu-system-x86-10102 [001] .... 13485.402146: kvm_msr: msr_write 838 = 0x3cee0
 qemu-system-x86-10102 [001] d... 13485.402147: kvm_entry: vcpu 0
 qemu-system-x86-10102 [001] .N.. 13485.403339: kvm_exit: reason EXTERNAL_INTERRUPT rip 0x4009b2 info 0 800000ef
 qemu-system-x86-10102 [001] d... 13485.403341: kvm_fpu: unload
 qemu-system-x86-10102 [001] .... 13485.403521: kvm_ple_window: vcpu 0: ple_window 4096 (shrink 4096)
 qemu-system-x86-10102 [001] .... 13485.403523: kvm_fpu: load
 qemu-system-x86-10102 [001] d... 13485.403523: kvm_entry: vcpu 0
 qemu-system-x86-10102 [001] .N.. 13485.404571: kvm_exit: reason EXTERNAL_INTERRUPT rip 0x4009b2 info 0 800000ef
 qemu-system-x86-10102 [001] d... 13485.404573: kvm_fpu: unload
 qemu-system-x86-10102 [001] .... 13485.406671: kvm_ple_window: vcpu 0: ple_window 4096 (shrink 4096)
 qemu-system-x86-10102 [001] .... 13485.406676: kvm_fpu: load
 qemu-system-x86-10102 [001] .... 13485.406677: kvm_apic_accept_irq: apicid 0 vec 239 (Fixed|edge)
 qemu-system-x86-10102 [001] .... 13485.406679: kvm_inj_virq: irq 239
 qemu-system-x86-10102 [001] d... 13485.406680: kvm_entry: vcpu 0
 qemu-system-x86-10102 [001] .... 13485.406702: kvm_eoi: apicid 0 vector 239
 qemu-system-x86-10102 [001] .... 13485.406703: kvm_pv_eoi: apicid 0 vector 239
 qemu-system-x86-10102 [001] .... 13485.406704: kvm_exit: reason MSR_WRITE rip 0xffffffff81064508 info 0 0
 qemu-system-x86-10102 [001] .... 13485.406706: kvm_apic: apic_write APIC_TMICT = 0x34720
 qemu-sys

 神秘的kvm,服务器端直接运行在,guest按理说也是要有中断的:

1
2
3
4
5
6
7
8
9
39839 __apic_accept_irq ([kvm])
            3aa20 kvm_apic_local_deliver ([kvm])
            3ac7d kvm_inject_apic_timer_irqs ([kvm])
            3824e kvm_inject_pending_timer_irqs ([kvm])
            1ebfe kvm_arch_vcpu_ioctl_run ([kvm])
             610d kvm_vcpu_ioctl ([kvm])
           4200ff do_vfs_ioctl ([kernel.kallsyms])
           420369 sys_ioctl ([kernel.kallsyms])
           a244f2 entry_SYSCALL_64_fastpath ([kernel.kallsyms])

  关键函数是

kvm是如何模拟时钟中断的?

kvm_create_pit   create_pit_timer

kvm_create_

有专门的一章,是讨论中断的虚拟化;

还要个超有意思的函数是:kvm_msr事件,

 

posted @   honpey  阅读(678)  评论(0编辑  收藏  举报
编辑推荐:
· SQL Server 内存占用高分析
· .NET Core GC计划阶段(plan_phase)底层原理浅谈
· .NET开发智能桌面机器人:用.NET IoT库编写驱动控制两个屏幕
· 用纯.NET开发并制作一个智能桌面机器人:从.NET IoT入门开始
· 一个超经典 WinForm,WPF 卡死问题的终极反思
阅读排行:
· 支付宝事故这事儿,凭什么又是程序员背锅?有没有可能是这样的...
· 在线客服系统 QPS 突破 240/秒,连接数突破 4000,日请求数接近1000万次,.NET 多
· C# 开发工具Visual Studio 介绍
· 在 Windows 10 上实现免密码 SSH 登录
· C#中如何使用异步编程
点击右上角即可分享
微信分享提示