qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Igor Mammedov <imammedo@redhat.com>
To: qemu-devel@nongnu.org
Cc: marcel.a@redhat.com, mst@redhat.com,
	vasilis.liaskovitis@profitbricks.com, aliguori@amazon.com,
	pbonzini@redhat.com, afaerber@suse.de
Subject: [Qemu-devel] [RFC 6/8] pc: preallocate hotplug links for DIMMDevices
Date: Thu, 20 Mar 2014 16:01:14 +0100	[thread overview]
Message-ID: <1395327676-29753-7-git-send-email-imammedo@redhat.com> (raw)
In-Reply-To: <1395327676-29753-1-git-send-email-imammedo@redhat.com>

Signed-off-by: Igor Mammedov <imammedo@redhat.com>
---
 hw/i386/pc.c         |   33 +++++++++++++++++++++++++++++++++
 include/hw/i386/pc.h |    6 ++++++
 2 files changed, 39 insertions(+), 0 deletions(-)

diff --git a/hw/i386/pc.c b/hw/i386/pc.c
index e0bc3a2..7bfd2c9 100644
--- a/hw/i386/pc.c
+++ b/hw/i386/pc.c
@@ -1155,6 +1155,9 @@ FWCfgState *pc_memory_init(MemoryRegion *system_memory,
     MemoryRegion *ram, *option_rom_mr;
     MemoryRegion *ram_below_4g, *ram_above_4g;
     FWCfgState *fw_cfg;
+    uint64_t ram_slot;
+    MachineState *machine = MACHINE(qdev_get_machine());
+    PCMachineState *pcms = PC_MACHINE(machine);
 
     linux_boot = (kernel_filename != NULL);
 
@@ -1181,6 +1184,20 @@ FWCfgState *pc_memory_init(MemoryRegion *system_memory,
         e820_add_entry(0x100000000ULL, above_4g_mem_size, E820_RAM);
     }
 
+    for (ram_slot = 0; ram_slot < machine->init_args.ram_slots; ram_slot++) {
+        char *dimm_name;
+
+        if (ram_slot >= PC_MAX_DIMM_SLOTS) {
+            error_report("supported memory slots limit: PC_MAX_DIMM_SLOTS");
+            exit(EXIT_FAILURE);
+        }
+
+        dimm_name = g_strdup_printf("dimm[%lu]", ram_slot);
+        object_property_add_link(OBJECT(pcms), dimm_name, TYPE_DIMM,
+                             (Object **)&pcms->memory_slots[ram_slot],
+                             &error_abort);
+        g_free(dimm_name);
+    }
 
     /* Initialize PC system firmware */
     pc_system_firmware_init(rom_memory, guest_info->isapc_ram_fw);
@@ -1426,11 +1443,27 @@ void qemu_register_pc_machine(QEMUMachine *m)
     type_register(&ti);
 }
 
+static char *pc_dimm_hotplug_path(DeviceState *dev)
+{
+    DimmDevice *dimm = DIMM(dev);
+
+    return g_strdup_printf("/machine/dimm[%d]", dimm->slot);
+}
+
+static void pc_machine_class_init(ObjectClass *oc, void *data)
+{
+    DeviceClass *dimm_dc = DEVICE_CLASS(object_class_by_name(TYPE_DIMM));
+
+    /* set board specific link path provider for DIMM device */
+    dimm_dc->hotplug_path = pc_dimm_hotplug_path;
+}
+
 static const TypeInfo pc_machine_info = {
     .name = TYPE_PC_MACHINE,
     .parent = TYPE_MACHINE,
     .abstract = true,
     .instance_size = sizeof(PCMachineState),
+    .class_init = pc_machine_class_init,
 };
 
 static void pc_machine_register_types(void)
diff --git a/include/hw/i386/pc.h b/include/hw/i386/pc.h
index a01a220..277bbb9 100644
--- a/include/hw/i386/pc.h
+++ b/include/hw/i386/pc.h
@@ -13,12 +13,18 @@
 #include "sysemu/sysemu.h"
 #include "hw/pci/pci.h"
 #include "hw/boards.h"
+#include "hw/mem/dimm.h"
 
 #define HPET_INTCAP "hpet-intcap"
 
+#define PC_MAX_DIMM_SLOTS 256
+
 struct PCMachineState {
     /*< private >*/
     MachineState parent_obj;
+
+    /* <public> */
+    DimmDevice *memory_slots[PC_MAX_DIMM_SLOTS];
 };
 
 typedef struct PCMachineState PCMachineState;
-- 
1.7.1

  parent reply	other threads:[~2014-03-20 15:02 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-03-20 15:01 [Qemu-devel] [RFC 0/8] bus-less device hotplug Igor Mammedov
2014-03-20 15:01 ` [Qemu-devel] [RFC 1/8] vl.c: extend -m option to support options for memory hotplug Igor Mammedov
2014-03-20 15:01 ` [Qemu-devel] [RFC 2/8] make machine_class_init() accessible outside of vl.c Igor Mammedov
2014-03-23 15:27   ` Marcel Apfelbaum
2014-03-23 16:22     ` Marcel Apfelbaum
2014-03-20 15:01 ` [Qemu-devel] [RFC 3/8] pc: prepare PC for custom machine state Igor Mammedov
2014-03-23 15:13   ` Marcel Apfelbaum
2014-03-24 10:34     ` Igor Mammedov
2014-03-24 12:28       ` Marcel Apfelbaum
2014-03-24 10:52     ` Andreas Färber
2014-03-24 11:20       ` Michael S. Tsirkin
2014-03-24 11:57         ` Andreas Färber
2014-03-24 12:13       ` Marcel Apfelbaum
2014-03-20 15:01 ` [Qemu-devel] [RFC 4/8] qdev: link based hotplug Igor Mammedov
2014-03-20 16:12   ` Paolo Bonzini
2014-03-20 16:20     ` Igor Mammedov
2014-03-20 18:03       ` Paolo Bonzini
2014-03-21 10:35         ` Igor Mammedov
2014-03-21 11:45           ` Paolo Bonzini
2014-03-24  9:10             ` Igor Mammedov
2014-03-24 12:20           ` Andreas Färber
2014-03-24 13:12             ` Michael S. Tsirkin
2014-03-20 15:01 ` [Qemu-devel] [RFC 5/8] dimm: implement dimm device abstraction Igor Mammedov
2014-03-20 15:01 ` Igor Mammedov [this message]
2014-03-20 15:01 ` [Qemu-devel] [RFC 7/8] pc: initialize memory hotplug address space Igor Mammedov
2014-03-20 15:01 ` [Qemu-devel] [RFC 8/8] pc: make PC_MACHINE memory hotplug controller Igor Mammedov

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1395327676-29753-7-git-send-email-imammedo@redhat.com \
    --to=imammedo@redhat.com \
    --cc=afaerber@suse.de \
    --cc=aliguori@amazon.com \
    --cc=marcel.a@redhat.com \
    --cc=mst@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=vasilis.liaskovitis@profitbricks.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).