From patchwork Mon Sep 16 02:40:49 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: chenfan X-Patchwork-Id: 275093 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)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id CB2522C0119 for ; Mon, 16 Sep 2013 12:44:26 +1000 (EST) Received: from localhost ([::1]:59398 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VLOnY-0006g7-VK for incoming@patchwork.ozlabs.org; Sun, 15 Sep 2013 22:44:24 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:54342) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VLOmi-00068d-11 for qemu-devel@nongnu.org; Sun, 15 Sep 2013 22:43:36 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VLOmb-0006Ok-S2 for qemu-devel@nongnu.org; Sun, 15 Sep 2013 22:43:31 -0400 Received: from [222.73.24.84] (port=59971 helo=song.cn.fujitsu.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VLOmb-0006LH-GV for qemu-devel@nongnu.org; Sun, 15 Sep 2013 22:43:25 -0400 X-IronPort-AV: E=Sophos;i="4.90,912,1371052800"; d="scan'208";a="8533930" Received: from unknown (HELO tang.cn.fujitsu.com) ([10.167.250.3]) by song.cn.fujitsu.com with ESMTP; 16 Sep 2013 10:39:58 +0800 Received: from fnstmail02.fnst.cn.fujitsu.com (tang.cn.fujitsu.com [127.0.0.1]) by tang.cn.fujitsu.com (8.14.3/8.13.1) with ESMTP id r8G2h2db019067; Mon, 16 Sep 2013 10:43:07 +0800 Received: from G08FNSTD131468.fnst.cn.fujitsu.com ([10.167.226.78]) by fnstmail02.fnst.cn.fujitsu.com (Lotus Domino Release 8.5.3) with ESMTP id 2013091610413539-1530029 ; Mon, 16 Sep 2013 10:41:35 +0800 From: Chen Fan To: qemu-devel@nongnu.org Date: Mon, 16 Sep 2013 10:40:49 +0800 Message-Id: <01b6bd4692d75a717574c08d505b1328e7543c71.1379062188.git.chen.fan.fnst@cn.fujitsu.com> X-Mailer: git-send-email 1.8.1.4 In-Reply-To: References: X-MIMETrack: Itemize by SMTP Server on mailserver/fnst(Release 8.5.3|September 15, 2011) at 2013/09/16 10:41:35, Serialize by Router on mailserver/fnst(Release 8.5.3|September 15, 2011) at 2013/09/16 10:41:41, Serialize complete at 2013/09/16 10:41:41 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 222.73.24.84 Cc: Igor Mammedov , =?UTF-8?q?Andreas=20F=C3=A4rber?= Subject: [Qemu-devel] [RFC qom-cpu v3 05/10] qmp: add 'cpu-del' command support 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 Signed-off-by: Chen Fan --- hw/i386/pc.c | 6 ++++++ hw/i386/pc_piix.c | 1 + include/hw/boards.h | 2 ++ include/hw/i386/pc.h | 1 + qapi-schema.json | 12 ++++++++++++ qmp-commands.hx | 23 +++++++++++++++++++++++ qmp.c | 9 +++++++++ 7 files changed, 54 insertions(+) diff --git a/hw/i386/pc.c b/hw/i386/pc.c index 832c9b2..40d611e 100644 --- a/hw/i386/pc.c +++ b/hw/i386/pc.c @@ -956,6 +956,12 @@ void pc_hot_add_cpu(const int64_t id, Error **errp) pc_new_cpu(current_cpu_model, apic_id, icc_bridge, errp); } +void pc_hot_del_cpu(const int64_t id, Error **errp) +{ + /* TODO: hot remove vCPU. */ + error_setg(errp, "Hot-remove CPU is not supported."); +} + void pc_cpus_init(const char *cpu_model, DeviceState *icc_bridge) { int i; diff --git a/hw/i386/pc_piix.c b/hw/i386/pc_piix.c index 6e1e654..d779b75 100644 --- a/hw/i386/pc_piix.c +++ b/hw/i386/pc_piix.c @@ -347,6 +347,7 @@ static QEMUMachine pc_i440fx_machine_v1_6 = { .desc = "Standard PC (i440FX + PIIX, 1996)", .init = pc_init_pci_1_6, .hot_add_cpu = pc_hot_add_cpu, + .hot_del_cpu = pc_hot_del_cpu, .max_cpus = 255, .is_default = 1, DEFAULT_MACHINE_OPTIONS, diff --git a/include/hw/boards.h b/include/hw/boards.h index fb7c6f1..fea3737 100644 --- a/include/hw/boards.h +++ b/include/hw/boards.h @@ -23,6 +23,7 @@ typedef void QEMUMachineInitFunc(QEMUMachineInitArgs *args); typedef void QEMUMachineResetFunc(void); typedef void QEMUMachineHotAddCPUFunc(const int64_t id, Error **errp); +typedef void QEMUMachineHotDelCPUFunc(const int64_t id, Error **errp); typedef struct QEMUMachine { const char *name; @@ -31,6 +32,7 @@ typedef struct QEMUMachine { QEMUMachineInitFunc *init; QEMUMachineResetFunc *reset; QEMUMachineHotAddCPUFunc *hot_add_cpu; + QEMUMachineHotDelCPUFunc *hot_del_cpu; BlockInterfaceType block_default_type; int max_cpus; unsigned int no_serial:1, diff --git a/include/hw/i386/pc.h b/include/hw/i386/pc.h index f79d478..b7e66f4 100644 --- a/include/hw/i386/pc.h +++ b/include/hw/i386/pc.h @@ -96,6 +96,7 @@ void pc_acpi_smi_interrupt(void *opaque, int irq, int level); void pc_cpus_init(const char *cpu_model, DeviceState *icc_bridge); void pc_hot_add_cpu(const int64_t id, Error **errp); +void pc_hot_del_cpu(const int64_t id, Error **errp); void pc_acpi_init(const char *default_dsdt); PcGuestInfo *pc_guest_info_init(ram_addr_t below_4g_mem_size, diff --git a/qapi-schema.json b/qapi-schema.json index a51f7d2..6052aa9 100644 --- a/qapi-schema.json +++ b/qapi-schema.json @@ -1432,6 +1432,18 @@ ## { 'command': 'cpu-add', 'data': {'id': 'int'} } +# @cpu-del + +# Deletes CPU with specified ID +# +# @id: ID of CPU to be deleted, valid values [0..max_cpus) +# +# Returns: Nothing on success +# +# Since 1.7 +## +{ 'command': 'cpu-del', 'data': {'id': 'int'} } + ## # @memsave: # diff --git a/qmp-commands.hx b/qmp-commands.hx index cf47e3f..16b54fd 100644 --- a/qmp-commands.hx +++ b/qmp-commands.hx @@ -411,6 +411,29 @@ Example: EQMP { + .name = "cpu-del", + .args_type = "id:i", + .mhandler.cmd_new = qmp_marshal_input_cpu_del, + }, + +SQMP +cpu-del +------- + +Deletes virtual cpu + +Arguments: + +- "id": cpu id (json-int) + +Example: + +-> { "execute": "cpu-del", "arguments": { "id": 2 } } +<- { "return": {} } + +EQMP + + { .name = "memsave", .args_type = "val:l,size:i,filename:s,cpu:i?", .mhandler.cmd_new = qmp_marshal_input_memsave, diff --git a/qmp.c b/qmp.c index 4c149b3..84dc873 100644 --- a/qmp.c +++ b/qmp.c @@ -118,6 +118,15 @@ void qmp_cpu_add(int64_t id, Error **errp) } } +void qmp_cpu_del(int64_t id, Error **errp) +{ + if (current_machine->hot_del_cpu) { + current_machine->hot_del_cpu(id, errp); + } else { + error_setg(errp, "Not supported"); + } +} + #ifndef CONFIG_VNC /* If VNC support is enabled, the "true" query-vnc command is defined in the VNC subsystem */