From patchwork Mon Sep 29 10:52:33 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gu Zheng X-Patchwork-Id: 394366 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id EF7951400DD for ; Mon, 29 Sep 2014 22:26:48 +1000 (EST) Received: from localhost ([::1]:36259 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XYa2R-0002Nt-3s for incoming@patchwork.ozlabs.org; Mon, 29 Sep 2014 08:26:47 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:47612) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XYZxx-0002xI-BF for qemu-devel@nongnu.org; Mon, 29 Sep 2014 08:22:15 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XYZxq-0000jN-Kj for qemu-devel@nongnu.org; Mon, 29 Sep 2014 08:22:09 -0400 Received: from fgwmail7.fujitsu.co.jp ([192.51.44.37]:55349) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XYZxq-0000i3-6T for qemu-devel@nongnu.org; Mon, 29 Sep 2014 08:22:02 -0400 Received: from fgwmail6.fujitsu.co.jp (fgwmail6.fujitsu.co.jp [192.51.44.36]) by fgwmail7.fujitsu.co.jp (Postfix) with ESMTP id 6EB1F1504AEF for ; Mon, 29 Sep 2014 21:20:07 +0900 (JST) Received: from kw-mxoi2.gw.nic.fujitsu.com (unknown [10.0.237.143]) by fgwmail6.fujitsu.co.jp (Postfix) with ESMTP id E17DF3EE0C2 for ; Mon, 29 Sep 2014 21:20:06 +0900 (JST) Received: from s4.gw.fujitsu.co.jp (s4.gw.fujitsu.co.jp [10.0.50.94]) by kw-mxoi2.gw.nic.fujitsu.com (Postfix) with ESMTP id F36F8AC054E for ; Mon, 29 Sep 2014 21:20:05 +0900 (JST) Received: from s01.gw.fujitsu.co.jp (s01.gw.nic.fujitsu.com [133.161.11.16]) by s4.gw.fujitsu.co.jp (Postfix) with ESMTP id 9BF451DB8037 for ; Mon, 29 Sep 2014 21:20:05 +0900 (JST) Received: from s01.gw.fujitsu.co.jp (yt-mxio2.gw.nic.fujitsu.com [10.134.25.142]) by s01.gw.fujitsu.co.jp (Postfix) with ESMTP id 626233F005E; Mon, 29 Sep 2014 21:20:05 +0900 (JST) Received: from guz (unknown [10.167.226.100]) by s01.gw.fujitsu.co.jp (Postfix) with ESMTP id 192608A001; Mon, 29 Sep 2014 21:20:05 +0900 (JST) Received: (from root@localhost) by guz (8.14.5/8.14.5/Submit) id s8TBBgQC032544; Mon, 29 Sep 2014 19:11:42 +0800 From: Gu Zheng To: qemu-devel@nongnu.org, imammedo@redhat.com Date: Mon, 29 Sep 2014 18:52:33 +0800 Message-Id: <1411987957-31190-5-git-send-email-guz.fnst@cn.fujitsu.com> X-Mailer: git-send-email 1.7.7 In-Reply-To: <1411987957-31190-1-git-send-email-guz.fnst@cn.fujitsu.com> References: <1411987957-31190-1-git-send-email-guz.fnst@cn.fujitsu.com> X-TM-AS-MML: disable X-TMASE-MatchedRID: uVuWzlu52RmGeJygPEVoVkvEthfZZLzvHO47qqaGvO/uc7XfuTYENvlY oV6p/cSxUVB7I/2CDSAMLq3lVTN3H1nG4aMEcT3TngIgpj8eDcAZ1CdBJOsoY8RB0bsfrpPIfiA qrjYtFiTD/GVhujeRAKXqvi4DfT1RKejBg+iSL8Z0wpEsuggghX7cGd19dSFd X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x X-Received-From: 192.51.44.37 Cc: chen.fan.fnst@cn.fujitsu.com, Gu Zheng , isimatu.yasuaki@jp.fujitsu.com, afaerber@suse.de, tangchen@cn.fujitsu.com Subject: [Qemu-devel] [PATCH V4 4/8] pc: add cpu hotplug handler to PC_MACHINE X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Add cpu hotplug handler to PC_MACHINE, which will perform the acpi cpu hotplug callback via hotplug_handler API. v3: -deal with start up cpus in a more neat way as Igor suggested. v2: -just rebase. Signed-off-by: Gu Zheng --- hw/i386/pc.c | 26 +++++++++++++++++++++++++- 1 files changed, 25 insertions(+), 1 deletions(-) diff --git a/hw/i386/pc.c b/hw/i386/pc.c index 82a7daa..dcb9332 100644 --- a/hw/i386/pc.c +++ b/hw/i386/pc.c @@ -1616,11 +1616,34 @@ out: error_propagate(errp, local_err); } +static void pc_cpu_plug(HotplugHandler *hotplug_dev, + DeviceState *dev, Error **errp) +{ + HotplugHandlerClass *hhc; + Error *local_err = NULL; + PCMachineState *pcms = PC_MACHINE(hotplug_dev); + + if (!pcms->acpi_dev) { + if (dev->hotplugged) { + error_setg(&local_err, + "cpu hotplug is not enabled: missing acpi device"); + } + goto out; + } + + hhc = HOTPLUG_HANDLER_GET_CLASS(pcms->acpi_dev); + hhc->plug(HOTPLUG_HANDLER(pcms->acpi_dev), dev, &local_err); +out: + error_propagate(errp, local_err); +} + static void pc_machine_device_plug_cb(HotplugHandler *hotplug_dev, DeviceState *dev, Error **errp) { if (object_dynamic_cast(OBJECT(dev), TYPE_PC_DIMM)) { pc_dimm_plug(hotplug_dev, dev, errp); + } else if (object_dynamic_cast(OBJECT(dev), TYPE_CPU)) { + pc_cpu_plug(hotplug_dev, dev, errp); } } @@ -1629,7 +1652,8 @@ static HotplugHandler *pc_get_hotpug_handler(MachineState *machine, { PCMachineClass *pcmc = PC_MACHINE_GET_CLASS(machine); - if (object_dynamic_cast(OBJECT(dev), TYPE_PC_DIMM)) { + if (object_dynamic_cast(OBJECT(dev), TYPE_PC_DIMM) || + object_dynamic_cast(OBJECT(dev), TYPE_CPU)) { return HOTPLUG_HANDLER(machine); }