Qemu内存管理主要结构体分析2:MemoryRegion/AddressSpace/FlatView

版权声明:本文为博主原创文章,遵循 CC 4.0 by-sa 版权协议,转载请附上原文出处链接和本声明。
本文链接:https://blog.csdn.net/Shirleylinyuer/article/details/83592614

文章主要分析qemu在guest内存管理中用到的主要结构体MemoryRegion、AddressSpace、FlatView、MemoryListener

一、简介

1. Multiple types of MemoryRegion (MemoryRegion直接操作内存,每一棵MR树的树根对应一个RAMBlock,其host即为通过mmap()分配的HVA)
  - RAM: a range of host memory that can be made available to the guest. e.g.    
     “pc.ram”, “pc.bios”, “pc.rom”, ram/rom for devices like “vga.ram”, “vga.rom”, etc.
  - IOMMU region: translate addresses esp. for each PCI device for DMA usage
  - container: includes other memory regions, each at a different offset. Use
                            memory_region_init() to initialize.
  - alias: a subsection of another region. Initialize with memory_region_init_alias().
2. AddressSpace (代表某种用途的内存,比如"memory", "I/O", "cpu-memory"等,将其他几个内存相关的结构体联系到一起)
  - Links all important structures together: MemoryRegion, MemoryRegionListener,
     FlatView, AddressSpaceDispatch, MemoryRegionIoevented, and so on.
  - Initialize with address_space_init().
3. FlatView (将树状的MemoryRegion展成平坦型的FlatView,用于内存映射)
  - Spread the MR-tree to Flat FlatView, which is filled with several FlatRange.
4. MemoryListener (用于监听内存以及内存更新)
  - Callbacks structure for updates to the physical memory map
  - Allows a component to adjust to changes in the guest-visible memory map.
    Use with memory_listener_register() and memory_listener_unregister().

二、关系图 (FlatView处的图源自网络,其他均原创)

三、结构体代码及其初始化代码解析

 

展开阅读全文

没有更多推荐了,返回首页