From patchwork Mon May 2 12:33:51 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Igor Mammedov X-Patchwork-Id: 8992271 Return-Path: X-Original-To: patchwork-qemu-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 6BFD2BF29F for ; Mon, 2 May 2016 12:58:24 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id CC1AE20219 for ; Mon, 2 May 2016 12:58:23 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id DE9B9201FA for ; Mon, 2 May 2016 12:58:19 +0000 (UTC) Received: from localhost ([::1]:36562 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1axDQW-0001zj-4p for patchwork-qemu-devel@patchwork.kernel.org; Mon, 02 May 2016 08:58:16 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:35939) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1axD4V-0007qi-I6 for qemu-devel@nongnu.org; Mon, 02 May 2016 08:35:38 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1axD4I-0000MA-ME for qemu-devel@nongnu.org; Mon, 02 May 2016 08:35:26 -0400 Received: from mx1.redhat.com ([209.132.183.28]:41240) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1axD4I-0000G2-Gx for qemu-devel@nongnu.org; Mon, 02 May 2016 08:35:18 -0400 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 6A232489 for ; Mon, 2 May 2016 12:35:07 +0000 (UTC) Received: from dell-r430-03.lab.eng.brq.redhat.com (dell-r430-03.lab.eng.brq.redhat.com [10.34.112.60]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u42CXqcT000450; Mon, 2 May 2016 08:35:05 -0400 From: Igor Mammedov To: qemu-devel@nongnu.org Date: Mon, 2 May 2016 14:33:51 +0200 Message-Id: <1462192431-146342-43-git-send-email-imammedo@redhat.com> In-Reply-To: <1462192431-146342-1-git-send-email-imammedo@redhat.com> References: <1462192431-146342-1-git-send-email-imammedo@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.22 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [RFC 42/42] DO NOT APPLY: simulate CPU unplug when executin cpu-add on a present CPU X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: drjones@redhat.com, ehabkost@redhat.com, mst@redhat.com, armbru@redhat.com, marcel@redhat.com Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Signed-off-by: Igor Mammedov --- hw/i386/pc.c | 8 ++++++++ include/qom/cpu.h | 2 +- qom/cpu.c | 6 +++--- 3 files changed, 12 insertions(+), 4 deletions(-) diff --git a/hw/i386/pc.c b/hw/i386/pc.c index 2d29b5e..7072fb5 100644 --- a/hw/i386/pc.c +++ b/hw/i386/pc.c @@ -1063,6 +1063,9 @@ out: return cpu; } +static void pc_machine_device_unplug_request_cb(HotplugHandler *hotplug_dev, + DeviceState *dev, Error **errp); + void pc_hot_add_cpu(const int64_t id, Error **errp) { X86CPU *cpu; @@ -1076,6 +1079,11 @@ void pc_hot_add_cpu(const int64_t id, Error **errp) } if (cpu_exists(apic_id)) { + DeviceState *dev = DEVICE(cpu_exists(apic_id)); + pc_machine_device_unplug_request_cb( + qdev_get_hotplug_handler(dev), + dev, + &local_err); error_setg(errp, "Unable to add CPU: %" PRIi64 ", it already exists", id); return; diff --git a/include/qom/cpu.h b/include/qom/cpu.h index b7a10f7..da55899 100644 --- a/include/qom/cpu.h +++ b/include/qom/cpu.h @@ -629,7 +629,7 @@ CPUState *qemu_get_cpu(int index); * * Returns: %true - CPU is found, %false - CPU isn't found. */ -bool cpu_exists(int64_t id); +CPUState *cpu_exists(int64_t id); /** * cpu_throttle_set: diff --git a/qom/cpu.c b/qom/cpu.c index c9007d3..f3210a2 100644 --- a/qom/cpu.c +++ b/qom/cpu.c @@ -29,7 +29,7 @@ #include "qemu/error-report.h" #include "sysemu/sysemu.h" -bool cpu_exists(int64_t id) +CPUState *cpu_exists(int64_t id) { CPUState *cpu; @@ -37,10 +37,10 @@ bool cpu_exists(int64_t id) CPUClass *cc = CPU_GET_CLASS(cpu); if (cc->get_arch_id(cpu) == id) { - return true; + return cpu; } } - return false; + return NULL; } CPUState *cpu_generic_init(const char *typename, const char *cpu_model)