From patchwork Thu Mar 20 15:01:14 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Igor Mammedov X-Patchwork-Id: 332247 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id E357A2C00BE for ; Fri, 21 Mar 2014 02:31:26 +1100 (EST) Received: from localhost ([::1]:47491 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WQeWu-0002EF-3h for incoming@patchwork.ozlabs.org; Thu, 20 Mar 2014 11:05:12 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:50566) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WQeUX-0007Pp-Fc for qemu-devel@nongnu.org; Thu, 20 Mar 2014 11:02:51 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WQeUR-0001Wf-7w for qemu-devel@nongnu.org; Thu, 20 Mar 2014 11:02:45 -0400 Received: from mx1.redhat.com ([209.132.183.28]:53357) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WQeUR-0001WW-3Q for qemu-devel@nongnu.org; Thu, 20 Mar 2014 11:02:39 -0400 Received: from int-mx02.intmail.prod.int.phx2.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id s2KF2ZS5016460 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Thu, 20 Mar 2014 11:02:36 -0400 Received: from dell-pet610-01.lab.eng.brq.redhat.com (dell-pet610-01.lab.eng.brq.redhat.com [10.34.42.20]) by int-mx02.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id s2KF2Mji022015; Thu, 20 Mar 2014 11:02:33 -0400 From: Igor Mammedov To: qemu-devel@nongnu.org Date: Thu, 20 Mar 2014 16:01:14 +0100 Message-Id: <1395327676-29753-7-git-send-email-imammedo@redhat.com> In-Reply-To: <1395327676-29753-1-git-send-email-imammedo@redhat.com> References: <1395327676-29753-1-git-send-email-imammedo@redhat.com> X-Scanned-By: MIMEDefang 2.67 on 10.5.11.12 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 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 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Signed-off-by: Igor Mammedov --- 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; + + /* */ + DimmDevice *memory_slots[PC_MAX_DIMM_SLOTS]; }; typedef struct PCMachineState PCMachineState;