From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:43112) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YQa3d-0006ST-7i for qemu-devel@nongnu.org; Wed, 25 Feb 2015 06:23:14 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YQa3Z-0004YR-1v for qemu-devel@nongnu.org; Wed, 25 Feb 2015 06:23:13 -0500 Received: from [59.151.112.132] (port=59342 helo=heian.cn.fujitsu.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YQa3Y-0004Xe-Ju for qemu-devel@nongnu.org; Wed, 25 Feb 2015 06:23:08 -0500 Message-ID: <54EDB047.9050003@cn.fujitsu.com> Date: Wed, 25 Feb 2015 19:21:43 +0800 From: Zhu Guihua MIME-Version: 1.0 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> In-Reply-To: <20150129143453.02176657@nial.brq.redhat.com> Content-Type: text/plain; charset="windows-1252"; format=flowed 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: Igor Mammedov , Tang Chen Cc: 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 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 ? 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, > . >