understanding_qemu
  • Introduction
  • 设备模型
    • 设备类型注册
    • 设备类型初始化
    • 设备实例化
    • DeviceClass实例化细节
    • 面向对象的设备模型
    • 接口
    • 类型、对象和接口之间的转换
    • PCDIMM
      • PCDIMM类型
      • PCDIMM实例
      • 插入系统
      • 创建ACPI表
      • NVDIMM
  • 地址空间
    • 从初始化开始
    • MemoryRegion
    • AddressSpace Part1
    • FlatView
    • RAMBlock
    • AddressSpace Part2
    • 眼见为实
    • 添加MemoryRegion
  • APIC
    • 纯Qemu模拟
    • Qemu/kernel混合模拟
    • APICV
  • Live Migration
    • 从用法说起
    • 整体架构
    • VMStateDescription
    • 内存热迁移
    • postcopy
  • FW_CFG
    • 规范解读
    • Linux Guest
    • SeaBios
  • Machine
    • MachineType
    • PCMachine
  • CPU
    • TYPE_CPU
    • X86_CPU
  • MemoryBackend
    • MemoryBackend类层次结构
    • MemoryBackend初始化流程
Powered by GitBook
On this page

Was this helpful?

  1. MemoryBackend

MemoryBackend类层次结构

作为一个设备类型,MemoryBackend自然也有自己的类层次结构。

经过这么多代码的洗礼,我就不多说什么了,直接上类继承关系图。

       +------------------+                                       +----------------------+
       |                  |                                       |                      |
       |   ObjectClass    |  ------------------------------       |   Object             |
       |     class_init   |                                       |                      |
       |                  |                                       |                      |
       +------------------+                                       +----------------------+
                 |                                                            |
                 |                                                            |
                 |                                                            |
                 v                                                            v
  +--------------------------+                                       +----------------------+
  |                          |                                       |                      |
  |HostMemoryBackendClass    |  ------------------------------------ |   HostMemoryBackend  |
  |    class_init            |  host_memory_backend_class_init       |      instance_init   |  host_memory_backend_init
  |                          |                                       |                      |
  |  +-----------------------+                                       |                      |
  |  |UserCreatableClass     |                                       |                      |
  |  |    complete           |  host_memory_backend_memory_complete  |                      |
  +--+-----------------------+                                       +---+------------------+
          |                                                              |
          |                                                              |
          |                                                              |
          |                                                              |
          |     TYPE_MEMORY_BACKEND_RAM                                  |
          |     +-----------------------+                                |      +----------------------+
          |     |                       |                                |      |                      |
          +---  |HostMemoryBackendClass |                                +---   |HostMemoryBackend     |
          |     |     class_init        |  ram_backend_class_init        |      |      instance_init   |
          |     |     bc->alloc         |  ram_backend_memory_alloc      |      |                      |
          |     +-----------------------+                                |      +----------------------+
          |                                                              |     
          |     TYPE_MEMORY_BACKEND_FILE                                 |     
          |     +-----------------------+                                |      +----------------------+
          |     |                       |                                |      |                      |
          +---  |HostMemoryBackendClass |                                +---   |HostMemoryBackendFile |
          |     |     class_init        |  file_backend_class_init       |      |      instance_init   |
          |     |     bc->alloc         |  file_backend_memory_alloc     |      |                      |
          |     +-----------------------+                                |      +----------------------+
          |                                                              |
          |     TYPE_MEMORY_BACKEND_RAM                                  |
          |     +-----------------------+                                |      +----------------------+
          |     |                       |                                |      |                      |
          +---  |HostMemoryBackendClass |                                +---   |HostMemoryBackendMemfd|
                |     class_init        |  memfd_backend_class_init             |      instance_init   |   memfd_backend_instance_init
                |     bc->alloc         |  memfd_backend_memory_alloc           |                      |
                +-----------------------+                                       +----------------------+

可以看到,现在的MemoryBackend一共有三种具体的实现 ram, file, memfd。他们大同小异,主要的区别就在于bc->alloc函数的实现不同。

那这个bc->alloc究竟是如何起作用的,请看下节[初始化流程][/memory_backend/02-init_flow.md]

PreviousMemoryBackendNextMemoryBackend初始化流程

Last updated 5 years ago

Was this helpful?