From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:46447) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XMqqc-0003Ok-9M for qemu-devel@nongnu.org; Wed, 27 Aug 2014 23:58:12 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XMqqW-0003vY-Hu for qemu-devel@nongnu.org; Wed, 27 Aug 2014 23:58:06 -0400 Received: from fgwmail6.fujitsu.co.jp ([192.51.44.36]:34479) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XMqqW-0003vS-8j for qemu-devel@nongnu.org; Wed, 27 Aug 2014 23:58:00 -0400 Received: from kw-mxoi1.gw.nic.fujitsu.com (unknown [10.0.237.133]) by fgwmail6.fujitsu.co.jp (Postfix) with ESMTP id 73B5D3EE0C7 for ; Thu, 28 Aug 2014 12:57:59 +0900 (JST) Received: from s3.gw.fujitsu.co.jp (s3.gw.fujitsu.co.jp [10.0.50.93]) by kw-mxoi1.gw.nic.fujitsu.com (Postfix) with ESMTP id 7A97CAC0845 for ; Thu, 28 Aug 2014 12:57:58 +0900 (JST) Received: from s00.gw.fujitsu.co.jp (s00.gw.nic.fujitsu.com [133.161.11.15]) by s3.gw.fujitsu.co.jp (Postfix) with ESMTP id 2A3B91DB8038 for ; Thu, 28 Aug 2014 12:57:58 +0900 (JST) From: Gu Zheng Date: Thu, 28 Aug 2014 11:36:37 +0800 Message-Id: <1409197002-9498-6-git-send-email-guz.fnst@cn.fujitsu.com> In-Reply-To: <1409197002-9498-1-git-send-email-guz.fnst@cn.fujitsu.com> References: <1409197002-9498-1-git-send-email-guz.fnst@cn.fujitsu.com> Subject: [Qemu-devel] [RFC V2 05/10] i386: add cpu device_del support List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org, imammedo@redhat.com, afaerber@suse.de Cc: chen.fan.fnst@cn.fujitsu.com, anshul.makkar@profitbricks.com, isimatu.yasuaki@jp.fujitsu.com, Gu Zheng , tangchen@cn.fujitsu.com In order to add cpu(i386) device_del support, introduce the cpu hot unplug hanlde(x86_cpu_unplug) which will trigger the unrealize routine, and just register it to the cpu class unplug handle. Signed-off-by: Chen Fan Signed-off-by: Gu Zheng --- target-i386/cpu.c | 22 ++++++++++++++++++++++ 1 files changed, 22 insertions(+), 0 deletions(-) diff --git a/target-i386/cpu.c b/target-i386/cpu.c index 72a94a6..dc5153e 100644 --- a/target-i386/cpu.c +++ b/target-i386/cpu.c @@ -2993,6 +2993,27 @@ static Property x86_cpu_properties[] = { DEFINE_PROP_END_OF_LIST() }; +static int x86_cpu_unplug(DeviceState *dev) +{ + CPUState *cpu = CPU(dev); + X86CPUClass *xcc; + Error *err = NULL; + + if (cpu == first_cpu) { + error_report("Can not remove the first cpu!\n"); + return -1; + } + + xcc = X86_CPU_GET_CLASS(DEVICE(cpu)); + xcc->parent_unrealize(DEVICE(cpu), &err); + if (err != NULL) { + error_report("%s", error_get_pretty(err)); + error_free(err); + return -1; + } + return 0; +} + static void x86_cpu_common_class_init(ObjectClass *oc, void *data) { X86CPUClass *xcc = X86_CPU_CLASS(oc); @@ -3005,6 +3026,7 @@ static void x86_cpu_common_class_init(ObjectClass *oc, void *data) dc->unrealize = x86_cpu_unrealizefn; dc->bus_type = TYPE_ICC_BUS; dc->props = x86_cpu_properties; + dc->unplug = x86_cpu_unplug; xcc->parent_reset = cc->reset; cc->reset = x86_cpu_reset; -- 1.7.7