From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:44602) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YGpFV-00057r-O0 for qemu-devel@nongnu.org; Thu, 29 Jan 2015 08:35:10 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YGpFS-0000Yu-3y for qemu-devel@nongnu.org; Thu, 29 Jan 2015 08:35:09 -0500 Received: from mx1.redhat.com ([209.132.183.28]:33596) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YGpFR-0000Ws-SJ for qemu-devel@nongnu.org; Thu, 29 Jan 2015 08:35:06 -0500 Date: Thu, 29 Jan 2015 14:34:53 +0100 From: Igor Mammedov Message-ID: <20150129143453.02176657@nial.brq.redhat.com> In-Reply-To: <1420679180-14883-12-git-send-email-tangchen@cn.fujitsu.com> References: <1420679180-14883-1-git-send-email-tangchen@cn.fujitsu.com> <1420679180-14883-12-git-send-email-tangchen@cn.fujitsu.com> MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [RESEND PATCH v1 11/13] pc-dimm: Add memory hot unplug support for pc-dimm. List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Tang Chen Cc: zhugh.fnst@cn.fujitsu.com, mst@redhat.com, hutao@cn.fujitsu.com, qemu-devel@nongnu.org, isimatu.yasuaki@jp.fujitsu.com, guz.fnst@cn.fujitsu.com, pbonzini@redhat.com On Thu, 8 Jan 2015 09:06:18 +0800 Tang Chen wrote: > Implement unplug cb for pc-dimm. It remove the corresponding > memory region, and unregister vmstat. At last, it calls memory > unplug cb to reset memory status and do unparenting. > --- > hw/i386/pc.c | 25 +++++++++++++++++++++++-- > 1 file changed, 23 insertions(+), 2 deletions(-) > > diff --git a/hw/i386/pc.c b/hw/i386/pc.c > index f501f1f..3732f67 100644 > --- a/hw/i386/pc.c > +++ b/hw/i386/pc.c > @@ -1691,6 +1691,23 @@ out: > error_propagate(errp, local_err); > } > > +static void pc_dimm_unplug(HotplugHandler *hotplug_dev, > + DeviceState *dev, Error **errp) > +{ > + PCMachineState *pcms = PC_MACHINE(hotplug_dev); > + PCDIMMDevice *dimm = PC_DIMM(dev); > + PCDIMMDeviceClass *ddc = PC_DIMM_GET_CLASS(dimm); > + MemoryRegion *mr = ddc->get_memory_region(dimm); > + HotplugHandlerClass *hhc; > + Error *local_err = NULL; > + > + memory_region_del_subregion(&pcms->hotplug_memory, mr); > + vmstate_unregister_ram(mr, dev); I'd first cleanup external state by calling acpi unplug handler and only the do above. > + > + hhc = HOTPLUG_HANDLER_GET_CLASS(pcms->acpi_dev); > + hhc->unplug(HOTPLUG_HANDLER(pcms->acpi_dev), dev, &local_err); > +} > + > static void pc_cpu_plug(HotplugHandler *hotplug_dev, > DeviceState *dev, Error **errp) > { > @@ -1744,8 +1761,12 @@ static void pc_machine_device_unplug_request_cb(HotplugHandler *hotplug_dev, > static void pc_machine_device_unplug_cb(HotplugHandler *hotplug_dev, > DeviceState *dev, Error **errp) > { > - error_setg(errp, "acpi: device unplug for not supported device" > - " type: %s", object_get_typename(OBJECT(dev))); > + if (object_dynamic_cast(OBJECT(dev), TYPE_PC_DIMM)) { > + pc_dimm_unplug(hotplug_dev, dev, errp); > + } else { > + error_setg(errp, "acpi: device unplug for not supported device" > + " type: %s", object_get_typename(OBJECT(dev))); > + } > } > > static HotplugHandler *pc_get_hotpug_handler(MachineState *machine,