qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Qemu-devel] [PATCH 22/27] pc: add memory hotplug Q35 machine


From: Igor Mammedov
Subject: [Qemu-devel] [PATCH 22/27] pc: add memory hotplug Q35 machine
Date: Thu, 21 Nov 2013 03:38:43 +0100

Add DimmBus to q35 machine, initialize memory hotplug window and plumb
in ACPI callback (ich9_pm) for communicating hotplug event to guest.

Signed-off-by: Igor Mammedov <address@hidden>
---
 hw/i386/pc_q35.c          |    3 +++
 hw/pci-host/q35.c         |   18 +++++++++++++++++-
 include/hw/pci-host/q35.h |    1 +
 3 files changed, 21 insertions(+), 1 deletions(-)

diff --git a/hw/i386/pc_q35.c b/hw/i386/pc_q35.c
index 5525465..59887db 100644
--- a/hw/i386/pc_q35.c
+++ b/hw/i386/pc_q35.c
@@ -167,6 +167,8 @@ static void pc_q35_init(QEMUMachineInitArgs *args)
                  ICH9_LPC_NB_PIRQS);
     pci_bus_set_route_irq_fn(host_bus, ich9_route_intx_pin_to_irq);
     isa_bus = ich9_lpc->isa_bus;
+    pc_acpi_dev_memory_hotplug_init(&q35_host->mch.hotplug_mem_bus,
+                                    ich9_mem_hotplug, OBJECT(ich9_lpc));
 
     /*end early*/
     isa_bus_irqs(isa_bus, gsi);
@@ -234,6 +236,7 @@ static void pc_compat_1_7(QEMUMachineInitArgs *args)
 {
     smbios_type1_defaults = false;
     pc_pci_as_mapping_init = pc_pci_as_mapping_init_1_7;
+    pc_hotplug_memory_init = pc_hotplug_memory_init_compat_1_7;
 }
 
 static void pc_compat_1_6(QEMUMachineInitArgs *args)
diff --git a/hw/pci-host/q35.c b/hw/pci-host/q35.c
index 6e28418..ead982b 100644
--- a/hw/pci-host/q35.c
+++ b/hw/pci-host/q35.c
@@ -356,11 +356,16 @@ static int mch_init(PCIDevice *d)
 {
     int i;
     MCHPCIState *mch = MCH_PCI_DEVICE(d);
+    ram_addr_t high_memory_end = 0x100000000ULL + mch->above_4g_mem_size;
+
+    pc_hotplug_memory_init(OBJECT(mch), mch->system_memory,
+                           mch->below_4g_mem_size, mch->pci_info.w32.begin,
+                           &mch->hotplug_mem_bus, &high_memory_end);
 
     /* setup pci memory mapping */
     pc_pci_as_mapping_init(OBJECT(mch), mch->system_memory,
                            mch->pci_address_space,
-                           0x100000000ULL + mch->above_4g_mem_size);
+                           high_memory_end);
 
     /* smram */
     cpu_smm_register(&mch_set_smm, mch);
@@ -389,6 +394,16 @@ uint64_t mch_mcfg_base(void)
     return MCH_HOST_BRIDGE_PCIEXBAR_DEFAULT;
 }
 
+static void mch_initfn(Object *obj)
+{
+    MCHPCIState *mch = MCH_PCI_DEVICE(obj);
+
+    qbus_create_inplace(&mch->hotplug_mem_bus,
+                        sizeof(mch->hotplug_mem_bus),
+                        TYPE_DIMM_BUS, DEVICE(mch),
+                        "hotplug-membus");
+}
+
 static void mch_class_init(ObjectClass *klass, void *data)
 {
     PCIDeviceClass *k = PCI_DEVICE_CLASS(klass);
@@ -410,6 +425,7 @@ static const TypeInfo mch_info = {
     .name = TYPE_MCH_PCI_DEVICE,
     .parent = TYPE_PCI_DEVICE,
     .instance_size = sizeof(MCHPCIState),
+    .instance_init = mch_initfn,
     .class_init = mch_class_init,
 };
 
diff --git a/include/hw/pci-host/q35.h b/include/hw/pci-host/q35.h
index d0355b7..c9aa790 100644
--- a/include/hw/pci-host/q35.h
+++ b/include/hw/pci-host/q35.h
@@ -47,6 +47,7 @@ typedef struct MCHPCIState {
     PCIDevice parent_obj;
     /*< public >*/
 
+    DimmBus hotplug_mem_bus;
     MemoryRegion *ram_memory;
     MemoryRegion *pci_address_space;
     MemoryRegion *system_memory;
-- 
1.7.1




reply via email to

[Prev in Thread] Current Thread [Next in Thread]