From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:51001) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WYXXc-00086I-2G for qemu-devel@nongnu.org; Fri, 11 Apr 2014 05:14:38 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WYXXV-0003oJ-OG for qemu-devel@nongnu.org; Fri, 11 Apr 2014 05:14:32 -0400 Received: from mx1.redhat.com ([209.132.183.28]:21368) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WYXXV-0003oB-Ge for qemu-devel@nongnu.org; Fri, 11 Apr 2014 05:14:25 -0400 Date: Fri, 11 Apr 2014 11:14:00 +0200 From: Igor Mammedov Message-ID: <20140411111400.6af6587a@thinkpad> In-Reply-To: <20140407151451.GA17260@redhat.com> References: <1396618620-27823-1-git-send-email-imammedo@redhat.com> <1396618620-27823-29-git-send-email-imammedo@redhat.com> <20140407102354.GA14603@redhat.com> <20140407163216.5bc38ca1@nial.usersys.redhat.com> <20140407151451.GA17260@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH 28/35] pc: propagate memory hotplug event to ACPI device List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: "Michael S. Tsirkin" Cc: peter.maydell@linaro.org, aik@ozlabs.ru, hutao@cn.fujitsu.com, mjt@tls.msk.ru, qemu-devel@nongnu.org, lcapitulino@redhat.com, kraxel@redhat.com, akong@redhat.com, quintela@redhat.com, armbru@redhat.com, aliguori@amazon.com, jan.kiszka@siemens.com, lersek@redhat.com, ehabkost@redhat.com, marcel.a@redhat.com, stefanha@redhat.com, chegu_vinod@hp.com, rth@twiddle.net, kwolf@redhat.com, s.priebe@profihost.ag, mreitz@redhat.com, vasilis.liaskovitis@profitbricks.com, pbonzini@redhat.com, afaerber@suse.de On Mon, 7 Apr 2014 18:14:51 +0300 "Michael S. Tsirkin" wrote: > On Mon, Apr 07, 2014 at 04:32:16PM +0200, Igor Mammedov wrote: > > On Mon, 7 Apr 2014 13:23:54 +0300 > > "Michael S. Tsirkin" wrote: > > > > > On Fri, Apr 04, 2014 at 03:36:53PM +0200, Igor Mammedov wrote: > > > > Notify PIIX4_PM/ICH9LPC device about hotplug event, > > > > so that it would send SCI to guest notifying about > > > > newly added memory. > > > > > > > > Signed-off-by: Igor Mammedov > > > > --- > > > > hw/i386/pc.c | 13 +++++++++++++ > > > > 1 file changed, 13 insertions(+) > > > > > > > > diff --git a/hw/i386/pc.c b/hw/i386/pc.c > > > > index 734c6ee..ee5cf88 100644 > > > > --- a/hw/i386/pc.c > > > > +++ b/hw/i386/pc.c > > > > @@ -60,6 +60,8 @@ > > > > #include "acpi-build.h" > > > > #include "hw/mem/dimm.h" > > > > #include "trace.h" > > > > +#include "hw/acpi/piix4.h" > > > > +#include "hw/i386/ich9.h" > > > > > > > > /* debug PC/ISA interrupts */ > > > > //#define DEBUG_IRQ > > > > @@ -1484,6 +1486,8 @@ void qemu_register_pc_machine(QEMUMachine *m) > > > > static void pc_dimm_plug(HotplugHandler *hotplug_dev, > > > > DeviceState *dev, Error **errp) > > > > { > > > > + Object *acpi_dev; > > > > + HotplugHandlerClass *hhc; > > > > Error *local_err = NULL; > > > > PCMachineState *pcms = PC_MACHINE(hotplug_dev); > > > > DimmDevice *dimm = DIMM(dev); > > > > @@ -1517,10 +1521,19 @@ static void pc_dimm_plug(HotplugHandler *hotplug_dev, > > > > } > > > > trace_mhp_pc_dimm_assigned_slot(dimm->slot); > > > > > > > > + acpi_dev = (acpi_dev = piix4_pm_find()) ? acpi_dev : ich9_lpc_find(); > > > > + if (!acpi_dev) { > > > > + error_setg(&local_err, > > > > + "memory hotplug is not enabled: missing acpi device"); > > > > + return; > > > > + } > > > > + > > > > + hhc = HOTPLUG_HANDLER_GET_CLASS(acpi_dev); > > > > > > How about simply looking for a hotplug handler type device instead? > > > We aren't likely to have many of these, are we? > > > > How about adding link to PCMachine when it's created > > and use it instead of piix4_pm_find()/ich9_lpc_find() everywhere? > > that would allow to remove above searches in QOM tree and simplify > > code including acpi-build.c > > So each acpi implementation registers a link at a pre-defined path? > I'm fine with this, need an ack from afaerber though. It could be a just plain pointer since it points to system device which won't disappear suddenly (i.e. it's not hot-unplugable). > > > > > memory_region_add_subregion(&pcms->hotplug_memory, > > > > addr - pcms->hotplug_memory_base, > > > > mr); > > > > vmstate_register_ram(mr, dev); > > > > + hhc->plug(HOTPLUG_HANDLER(acpi_dev), dev, &local_err); > > > > > > > > out: > > > > error_propagate(errp, local_err); > > > > -- > > > > 1.9.0 > -- Regards, Igor