記憶體虛拟化,qemu這塊需要了解pc_memory_init(在這裡會調用kvm_region_add ---> kvm_set_user_memory_region)和memory_listener_register(這裡隻是注冊)
先注冊memory listener,然後如果其他裝置添加了region,memory.c會回調這些listener,然後就kvm_set_phys_mem,走到kvm module中set slot了
1 2 3 4 5 6 7 8 9 10 11 12 13 14 | (gdb) bt #0 kvm_region_add (listener=0x555555c5efe0 <kvm_memory_listener>, section=0x7fffffffde60) at /home/pizhi/oschina/qemu/kvm-all .c:832 #1 0x000055555562219f in address_space_update_topology_pass ([email protected]=0x555555caae00 <address_space_memory>, [email protected]= true , new_view=<optimized out>, new_view=<optimized out>, old_view=0x555556995750, old_view=0x555556995750) at /home/pizhi/oschina/qemu/memory .c:790 #2 0x00005555556246c0 in address_space_update_topology (as=0x555555caae00 <address_space_memory>) at /home/pizhi/oschina/qemu/memory .c:805 #3 memory_region_transaction_commit () at /home/pizhi/oschina/qemu/memory.c:845 #4 0x000055555565debd in pc_cpus_init (cpu_model=0x55555587bd2d "qemu64", [email protected]=0x55555699b680) at /home/pizhi/oschina/qemu/hw/i386/pc .c:1159 #5 0x000055555565fb7d in pc_init1 (machine=0x5555569726c0, kvmclock_enabled=1, pci_enabled=1) at /home/pizhi/oschina/qemu/hw/i386/pc_piix .c:150 #6 0x00005555555e5de1 in main (argc=<optimized out>, argv=<optimized out>, envp=<optimized out>) at vl.c:4276 |