博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
内存热添加
阅读量:5755 次
发布时间:2019-06-18

本文共 7372 字,大约阅读时间需要 24 分钟。

static void pc_dimm_class_init(ObjectClass oc, void data)

{
DeviceClass dc = DEVICE_CLASS(oc);
PCDIMMDeviceClass
ddc = PC_DIMM_CLASS(oc);

dc->realize = pc_dimm_realize;dc->unrealize = pc_dimm_unrealize;dc->props = pc_dimm_properties;dc->desc = "DIMM memory module";ddc->get_memory_region = pc_dimm_get_memory_region;ddc->get_vmstate_memory_region = pc_dimm_get_vmstate_memory_region;

}

static void piix4_pm_class_init(ObjectClass klass, void data)

{
DeviceClass dc = DEVICE_CLASS(klass);
PCIDeviceClass
k = PCI_DEVICE_CLASS(klass);
HotplugHandlerClass hc = HOTPLUG_HANDLER_CLASS(klass);
AcpiDeviceIfClass
adevc = ACPI_DEVICE_IF_CLASS(klass);

k->realize = piix4_pm_realize;k->config_write = pm_write_config;k->vendor_id = PCI_VENDOR_ID_INTEL;k->device_id = PCI_DEVICE_ID_INTEL_82371AB_3;k->revision = 0x03;k->class_id = PCI_CLASS_BRIDGE_OTHER;dc->desc = "PM";dc->vmsd = &vmstate_acpi;dc->props = piix4_pm_properties;/* * Reason: part of PIIX4 southbridge, needs to be wired up, * e.g. by mips_malta_init() */dc->user_creatable = false;dc->hotpluggable = false;hc->plug = piix4_device_plug_cb;hc->unplug_request = piix4_device_unplug_request_cb;hc->unplug = piix4_device_unplug_cb;adevc->ospm_status = piix4_ospm_status;adevc->send_event = piix4_send_gpe;adevc->madt_cpu = pc_madt_cpu_entry;

}

pc_init1

{
设置中断回调函数
if (kvm_ioapic_in_kernel()) {
kvm_pc_setup_irq_routing(pcmc->pci_enabled);
pcms->gsi = qemu_allocate_irqs(kvm_pc_gsi_handler, gsi_state,
GSI_NUM_PINS);
} else {
pcms->gsi = qemu_allocate_irqs(gsi_handler, gsi_state, GSI_NUM_PINS);
}

初始化中断     if (kvm_pic_in_kernel()) {    i8259 = kvm_i8259_init(isa_bus);} else if (xen_enabled()) {    i8259 = xen_interrupt_controller_init();} else {    i8259 = i8259_init(isa_bus, pc_allocate_cpu_irq());}

}

qemu_irq kvm_i8259_init(ISABus bus)

{
i8259_init_chip(TYPE_KVM_I8259, bus, true); 初始化主中断
i8259_init_chip(TYPE_KVM_I8259, bus, false); 初始化从中断

return qemu_allocate_irqs(kvm_pic_set_irq, NULL, ISA_NUM_IRQS);

}

#2 0x00007f117a950f34 in qemuMonitorSend (mon=0x7f1160035880, msg=0x7f117605b6f0) at ../../../src/qemu/qemu_monitor.c:1087

#3 0x00007f117a96749e in qemuMonitorJSONCommandWithFd (mon=0x7f1160035880, cmd=0x7f113c01ac40, scm_fd=-1, reply=0x7f117605b798) at ../../../src/qemu/qemu_monitor_json.c:303
#4 0x00007f117a9675d7 in qemuMonitorJSONCommand (mon=0x7f1160035880, cmd=0x7f113c01ac40, reply=0x7f117605b798) at ../../../src/qemu/qemu_monitor_json.c:333
#5 0x00007f117a9709c5 in qemuMonitorJSONAddDeviceArgs (mon=0x7f1160035880, args=0x0) at ../../../src/qemu/qemu_monitor_json.c:3808
#6 0x00007f117a970a78 in qemuMonitorJSONAddDevice (mon=0x7f1160035880, devicestr=0x7f113c001af0 "pc-dimm,node=0,memdev=ram0,id=dimm0,slot=0") at ../../../src/qemu/qemu_monitor_json.c:3832
#7 0x00007f117a9597cc in qemuMonitorAddDeviceWithFd (mon=0x7f1160035880, devicestr=0x7f113c001af0 "pc-dimm,node=0,memdev=ram0,id=dimm0,slot=0", fd=-1, fdname=0x0) at ../../../src/qemu/qemu_monitor.c:3195
#8 0x00007f117a959877 in qemuMonitorAddDevice (mon=0x7f1160035880, devicestr=0x7f113c001af0 "pc-dimm,node=0,memdev=ram0,id=dimm0,slot=0") at ../../../src/qemu/qemu_monitor.c:3212
#9 0x00007f117a9163b5 in qemuDomainAttachMemory (driver=0x7f1170002b10, vm=0x7f11700dd610, mem=0x7f113c002370) at ../../../src/qemu/qemu_hotplug.c:2210
#10 0x00007f117a98f8a0 in qemuDomainAttachDeviceLive (vm=0x7f11700dd610, dev=0x7f113c000a90, conn=0x7f116c0164d0, driver=0x7f1170002b10) at ../../../src/qemu/qemu_driver.c:7734
#11 0x00007f117a992994 in qemuDomainAttachDeviceLiveAndConfig (conn=0x7f116c0164d0, vm=0x7f11700dd610, driver=0x7f1170002b10,
xml=0x7f113c001590 "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?><memory model=\"dimm\"><target><size unit=\"KiB\">2097152</size><node>0</node></target></memory>", flags=3)
at ../../../src/qemu/qemu_driver.c:8796
#12 0x00007f117a992cc1 in qemuDomainAttachDeviceFlags (dom=0x7f113c001360,
xml=0x7f113c001590 "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?><memory model=\"dimm\"><target><size unit=\"KiB\">2097152</size><node>0</node></target></memory>", flags=3)
at ../../../src/qemu/qemu_driver.c:8880
#13 0x00007f118a0cdd80 in virDomainAttachDeviceFlags (domain=0x7f113c001360,
xml=0x7f113c001590 "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?><memory model=\"dimm\"><target><size unit=\"KiB\">2097152</size><node>0</node></target></memory>", flags=3)
at ../../../src/libvirt-domain.c:8156

pc_dimm_plug--> piix4_device_plug_cb -->acpi_memory_plug_cb -->acpi_send_event-->piix4_send_gpe -->acpi_send_gpe_event -->acpi_update_sci -->qemu_set_irq

-->kvm_pc_gsi_handler -->qemu_set_irq -->kvm_pic_set_irq -->kvm_set_irq

#0 pc_dimm_memory_plug (dev=dev@entry=0x5564b9dcaf60, hpms=hpms@entry=0x5564b8f03af0, mr=0x5564b9d57ce0, align=2097152, errp=errp@entry=0x7ffcd7286750)

at /vms/disk2/v-e0522/v-e0522/daemon/qemu/qemu-2.12/hw/mem/pc-dimm.c:40
#1 0x00005564b75a17db in pc_dimm_plug (errp=0x7ffcd72867b0, dev=0x5564b9dcaf60, hotplug_dev=<optimized out>) qemu-2.12/hw/i386/pc.c:1714
#2 pc_machine_device_plug_cb (hotplug_dev=<optimized out>, dev=0x5564b9dcaf60, errp=0x7ffcd72867b0) qemu-2.12/hw/i386/pc.c:2024
#3 0x00005564b76a5f6e in device_set_realized (obj=<optimized out>, value=<optimized out>, errp=0x7ffcd72868d8) qemu-2.12/hw/core/qdev.c:862
#4 0x00005564b7809227 in property_set_bool (obj=0x5564b9dcaf60, v=<optimized out>, name=<optimized out>, opaque=0x5564ba43ee50, errp=0x7ffcd72868d8) v-e0522/daemon/qemu/qemu-2.12/qom/object.c:1923
#5 0x00005564b780d46f in object_property_set_qobject (obj=obj@entry=0x5564b9dcaf60, value=value@entry=0x5564b9ab1570, name=name@entry=0x5564b79ca95f "realized", errp=errp@entry=0x7ffcd72868d8)
at /vms/disk2/v-e0522/v-e0522/daemon/qemu/qemu-2.12/qom/qom-qobject.c:27
#6 0x00005564b780b090 in object_property_set_bool (obj=0x5564b9dcaf60, value=<optimized out>, name=0x5564b79ca95f "realized", errp=0x7ffcd72868d8) at /vms/disk2/v-e0522/v-e0522/daemon/qemu/qemu-2.12/qom/object.c:1188
#7 0x00005564b762b68a in qdev_device_add (opts=opts@entry=0x5564b9dcbc80, errp=errp@entry=0x7ffcd72869b0) qemu-2.12/qdev-monitor.c:627
#8 0x00005564b762bcb3 in qmp_device_add (qdict=<optimized out>, ret_data=<optimized out>, errp=0x7ffcd72869e8) qemu-2.12/qdev-monitor.c:807

pc_dimm_plug-->pc_dimm_memory_plug -->memory_region_add_subregion -->memory_region_add_subregion_common -->memory_region_update_container_subregions

--> memory_region_transaction_commit | -->flatviews_reset -->generate_memory_topology -->render_memory_region
| -->address_space_set_flatview -->address_space_update_topology_pass -->kvm_region_add -->kvm_set_phys_mem
将MemoryRegion映射到线性地址空间FlatView,得到若干个 MemoryRegionSection ,调用 kvm_region_add ,将 MemoryRegionSection 注册到 KVM 中

memory_region_add_subregion_common 加入subregions链表

memory_region_transaction_begin

--> qemu_flush_coalesced_mmio_buffer | --> kvm_flush_coalesced_mmio_buffer
| --> ++memory_region_transaction_depth
KVM 中对某些 MMIO 做了 batch 优化:KVM 遇到 MMIO 而 VMEXIT 时,将 MMIO 操作记录到 kvm_coalesced_mmio 结构中,然后塞到 kvm_coalesced_mmio_ring 中,不退出到 QEMU 。直到某一次退回到 QEMU ,要更新内存空间之前的那一刻,把 kvm_coalesced_mmio_ring 中的 kvm_coalesced_mmio 取出来做一遍,保证内存的一致性。这事就是 kvm_flush_coalesced_mmio_buffer 干的。

qemu_allocate_irq 分配中断号

pic_stat_update_irq 统计中断号的次数

mr = ddc->get_memory_region = pc_dimm_get_memory_region

hhc->plug = piix4_device_plug_cb
adevc->send_event = piix4_send_gpe

转载于:https://blog.51cto.com/zybcloud/2407551

你可能感兴趣的文章
配置ORACLE 11g绿色版客户端和PLSQL远程连接环境
查看>>
wordpress wp_head()函数 浏览器顶部 空白28px 解决办法
查看>>
读书笔记:改变人心的技巧
查看>>
MATLAB实现频数表——hist的使用
查看>>
iphone 线程 NSCondition NSThread
查看>>
NSURLConnection下载文件并显示进度(HEAD)
查看>>
在Firefox中使用超级Bookmarklet
查看>>
Content type and column用法示例代码来自SharePoint会议
查看>>
设计模式:外观模式(Façade Pattern)
查看>>
ASP.NET中 DataList(数据列表)的使用前台绑定
查看>>
Linux学习之CentOS(八)--Linux系统的分区概念
查看>>
C语言字节对齐
查看>>
主域控制器的安装与配置步骤与方法
查看>>
调整Flash与div的位置关系
查看>>
Objective - c 创建二维数组
查看>>
〖Android〗/system/etc/fallback_fonts.xml
查看>>
30个美丽干净的,帮助用户专注于内容的网站设计
查看>>
高级Bash脚本编程指南(27):文本处理命令(三)
查看>>
JavaScript---事件
查看>>
Android NDK入门实例 计算斐波那契数列一生成jni头文件
查看>>