Received: from eggs.gnu.org ([2001:4830:134:3::10]:36281) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YQbTC-0003Tp-Ie for qemu-devel@nongnu.org; Wed, 25 Feb 2015 07:53:47 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YQbT7-0006tc-5i for qemu-devel@nongnu.org; Wed, 25 Feb 2015 07:53:42 -0500 Received: from mx1.redhat.com ([209.132.183.28]:59012) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YQbT6-0006tT-VZ for qemu-devel@nongnu.org; Wed, 25 Feb 2015 07:53:37 -0500 Date: Wed, 25 Feb 2015 13:53:24 +0100 From: Igor Mammedov Message-ID: <20150225135324.685a5313@nial.brq.redhat.com> In-Reply-To: <54EDB047.9050003@cn.fujitsu.com> References: <1420679180-14883-1-git-send-email-tangchen@cn.fujitsu.com> <1420679180-14883-12-git-send-email-tangchen@cn.fujitsu.com> <20150129143453.02176657@nial.brq.redhat.com> <54EDB047.9050003@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: Zhu Guihua Cc: mst@redhat.com, hutao@cn.fujitsu.com, qemu-devel@nongnu.org, Tang Chen , isimatu.yasuaki@jp.fujitsu.com, guz.fnst@cn.fujitsu.com, pbonzini@redhat.com On Wed, 25 Feb 2015 19:21:43 +0800 Zhu Guihua wrote: > > On 01/29/2015 09:34 PM, Igor Mammedov wrote: > > 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. > > your meaning is to put the above behind hhc->unplug ? yes > > Regards, > Zhu > > >> + > >> + 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, > > . > > >