From patchwork Thu Jan 28 05:49:54 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bharata B Rao X-Patchwork-Id: 8146501 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 569D4BEEE5 for ; Thu, 28 Jan 2016 05:57:36 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 7D35120256 for ; Thu, 28 Jan 2016 05:57:35 +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 807F0201CD for ; Thu, 28 Jan 2016 05:57:34 +0000 (UTC) Received: from localhost ([::1]:54144 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aOfaH-0005OJ-UK for patchwork-qemu-devel@patchwork.kernel.org; Thu, 28 Jan 2016 00:57:33 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:50886) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aOfUb-0002xf-NF for qemu-devel@nongnu.org; Thu, 28 Jan 2016 00:51:44 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aOfUY-0005MQ-G7 for qemu-devel@nongnu.org; Thu, 28 Jan 2016 00:51:41 -0500 Received: from e23smtp08.au.ibm.com ([202.81.31.141]:38954) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aOfUX-0005Lx-MN for qemu-devel@nongnu.org; Thu, 28 Jan 2016 00:51:38 -0500 Received: from localhost by e23smtp08.au.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Thu, 28 Jan 2016 15:51:35 +1000 Received: from d23dlp03.au.ibm.com (202.81.31.214) by e23smtp08.au.ibm.com (202.81.31.205) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Thu, 28 Jan 2016 15:51:34 +1000 X-IBM-Helo: d23dlp03.au.ibm.com X-IBM-MailFrom: bharata@linux.vnet.ibm.com X-IBM-RcptTo: qemu-devel@nongnu.org;qemu-ppc@nongnu.org Received: from d23relay08.au.ibm.com (d23relay08.au.ibm.com [9.185.71.33]) by d23dlp03.au.ibm.com (Postfix) with ESMTP id BC9CB3578054; Thu, 28 Jan 2016 16:51:33 +1100 (EST) Received: from d23av02.au.ibm.com (d23av02.au.ibm.com [9.190.235.138]) by d23relay08.au.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id u0S5p2Ax49348652; Thu, 28 Jan 2016 16:51:10 +1100 Received: from d23av02.au.ibm.com (localhost [127.0.0.1]) by d23av02.au.ibm.com (8.14.4/8.14.4/NCO v10.0 AVout) with ESMTP id u0S5p1CI003317; Thu, 28 Jan 2016 16:51:01 +1100 Received: from bharata.in.ibm.com ([9.124.35.121]) by d23av02.au.ibm.com (8.14.4/8.14.4/NCO v10.0 AVin) with ESMTP id u0S5oG8B001110; Thu, 28 Jan 2016 16:50:58 +1100 From: Bharata B Rao To: qemu-devel@nongnu.org Date: Thu, 28 Jan 2016 11:19:54 +0530 Message-Id: <1453960195-15181-13-git-send-email-bharata@linux.vnet.ibm.com> X-Mailer: git-send-email 2.1.0 In-Reply-To: <1453960195-15181-1-git-send-email-bharata@linux.vnet.ibm.com> References: <1453960195-15181-1-git-send-email-bharata@linux.vnet.ibm.com> X-TM-AS-MML: disable X-Content-Scanned: Fidelis XPS MAILER x-cbid: 16012805-0029-0000-0000-000043F0F613 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 202.81.31.141 Cc: mjrosato@linux.vnet.ibm.com, ehabkost@redhat.com, aik@ozlabs.ru, Bharata B Rao , mdroth@linux.vnet.ibm.com, agraf@suse.de, pbonzini@redhat.com, qemu-ppc@nongnu.org, tyreld@linux.vnet.ibm.com, nfont@linux.vnet.ibm.com, imammedo@redhat.com, afaerber@suse.de, david@gibson.dropbear.id.au Subject: [Qemu-devel] [PATCH v7 12/13] qmp: Add query-ppc-cpu-cores command 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+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org 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 Show the details of PPC CPU cores via a new QMP command. TODO: update qmp-commands.hx with example Signed-off-by: Bharata B Rao --- hw/ppc/cpu-core.c | 77 +++++++++++++++++++++++++++++++++++++++++ qapi-schema.json | 31 +++++++++++++++++ qmp-commands.hx | 51 +++++++++++++++++++++++++++ stubs/Makefile.objs | 1 + stubs/qmp_query_ppc_cpu_cores.c | 10 ++++++ 5 files changed, 170 insertions(+) create mode 100644 stubs/qmp_query_ppc_cpu_cores.c diff --git a/hw/ppc/cpu-core.c b/hw/ppc/cpu-core.c index aa96e79..652a5aa 100644 --- a/hw/ppc/cpu-core.c +++ b/hw/ppc/cpu-core.c @@ -9,7 +9,84 @@ #include "hw/ppc/cpu-core.h" #include "hw/boards.h" #include +#include #include "qemu/error-report.h" +#include "qmp-commands.h" + +/* + * QMP: info ppc-cpu-cores + */ +static int qmp_ppc_cpu_list(Object *obj, void *opaque) +{ + CpuInfoList ***prev = opaque; + + if (object_dynamic_cast(obj, TYPE_POWERPC_CPU)) { + CpuInfoList *elem = g_new0(CpuInfoList, 1); + CpuInfo *s = g_new0(CpuInfo, 1); + CPUState *cs = CPU(obj); + PowerPCCPU *cpu = POWERPC_CPU(cs); + CPUPPCState *env = &cpu->env; + + cpu_synchronize_state(cs); + s->arch = CPU_INFO_ARCH_PPC; + s->current = (cs == first_cpu); + s->CPU = cs->cpu_index; + s->qom_path = object_get_canonical_path(obj); + s->halted = cs->halted; + s->thread_id = cs->thread_id; + s->u.ppc = g_new0(CpuInfoPPC, 1); + s->u.ppc->nip = env->nip; + + elem->value = s; + elem->next = NULL; + **prev = elem; + *prev = &elem->next; + } + object_child_foreach(obj, qmp_ppc_cpu_list, opaque); + return 0; +} + +static int qmp_ppc_cpu_core_list(Object *obj, void *opaque) +{ + PPCCPUCoreList ***prev = opaque; + + if (object_dynamic_cast(obj, TYPE_POWERPC_CPU_CORE)) { + DeviceClass *dc = DEVICE_GET_CLASS(obj); + DeviceState *dev = DEVICE(obj); + + if (dev->realized) { + PPCCPUCoreList *elem = g_new0(PPCCPUCoreList, 1); + PPCCPUCore *s = g_new0(PPCCPUCore, 1); + CpuInfoList *cpu_head = NULL; + CpuInfoList **cpu_prev = &cpu_head; + + if (dev->id) { + s->has_id = true; + s->id = g_strdup(dev->id); + } + s->hotplugged = dev->hotplugged; + s->hotpluggable = dc->hotpluggable; + qmp_ppc_cpu_list(obj, &cpu_prev); + s->threads = cpu_head; + elem->value = s; + elem->next = NULL; + **prev = elem; + *prev = &elem->next; + } + } + + object_child_foreach(obj, qmp_ppc_cpu_core_list, opaque); + return 0; +} + +PPCCPUCoreList *qmp_query_ppc_cpu_cores(Error **errp) +{ + PPCCPUCoreList *head = NULL; + PPCCPUCoreList **prev = &head; + + qmp_ppc_cpu_core_list(qdev_get_machine(), &prev); + return head; +} static int ppc_cpu_core_realize_child(Object *child, void *opaque) { diff --git a/qapi-schema.json b/qapi-schema.json index 8d04897..0902697 100644 --- a/qapi-schema.json +++ b/qapi-schema.json @@ -4083,3 +4083,34 @@ ## { 'enum': 'ReplayMode', 'data': [ 'none', 'record', 'play' ] } + +## +# @PPCCPUCore: +# +# Information about PPC CPU core devices +# +# @hotplugged: true if device was hotplugged +# +# @hotpluggable: true if device if could be added/removed while machine is running +# +# Since: 2.6 +## + +{ 'struct': 'PPCCPUCore', + 'data': { '*id': 'str', + 'hotplugged': 'bool', + 'hotpluggable': 'bool', + 'threads' : ['CpuInfo'] + } +} + +## +# @query-ppc-cpu-core: +# +# Returns information for all PPC CPU core devices +# +# Returns: a list of @PPCCPUCore. +# +# Since: 2.6 +## +{ 'command': 'query-ppc-cpu-cores', 'returns': ['PPCCPUCore'] } diff --git a/qmp-commands.hx b/qmp-commands.hx index db072a6..77cda3c 100644 --- a/qmp-commands.hx +++ b/qmp-commands.hx @@ -4795,3 +4795,54 @@ Example: {"type": 0, "out-pport": 0, "pport": 0, "vlan-id": 3840, "pop-vlan": 1, "id": 251658240} ]} + +EQMP + +#if defined TARGET_PPC64 + { + .name = "query-ppc-cpu-cores", + .args_type = "", + .mhandler.cmd_new = qmp_marshal_query_ppc_cpu_cores, + }, +#endif + +SQMP +@query-ppc-cpu-cores +-------------------- + +Show PowerPC CPU core devices information. + +Example: +-> { "execute": "query-ppc-cpu-cores" } +<- {"return": [{"threads": [ + {"arch": "ppc", + "current": false, + "CPU": 16, + "nip": -4611686018426944644, + "qom_path": "/machine/peripheral/core2/thread[0]", + "halted": false, + "thread_id": 32636}, + {"arch": "ppc", + "current": false", + "CPU": 17, + "nip": -4611686018426944644, + "qom_path": "/machine/peripheral/core2/thread[1]", + "halted": false, "thread_id": 32637}, + {"arch": "ppc", + "current": false, + "CPU": 18, + "nip": -4611686018426944644, + "qom_path": "/machine/peripheral/core2/thread[2]", + "halted": false, + "thread_id": 32638}, + {"arch": "ppc", + "current": false, + "CPU": 19, + "nip": -4611686018426944644, + "qom_path": "/machine/peripheral/core2/thread[3]", + "halted": false, + "thread_id": 32639}], + "hotplugged": false, + "hotpluggable": true, + "id": "core2"} + ]} diff --git a/stubs/Makefile.objs b/stubs/Makefile.objs index d7898a0..1d65999 100644 --- a/stubs/Makefile.objs +++ b/stubs/Makefile.objs @@ -38,3 +38,4 @@ stub-obj-y += qmp_pc_dimm_device_list.o stub-obj-y += target-monitor-defs.o stub-obj-y += target-get-monitor-def.o stub-obj-y += vhost.o +stub-obj-y += qmp_query_ppc_cpu_cores.o diff --git a/stubs/qmp_query_ppc_cpu_cores.c b/stubs/qmp_query_ppc_cpu_cores.c new file mode 100644 index 0000000..6a875f0 --- /dev/null +++ b/stubs/qmp_query_ppc_cpu_cores.c @@ -0,0 +1,10 @@ +#include "qom/object.h" +#include "qapi/qmp/qerror.h" +#include "qemu/typedefs.h" +#include "qmp-commands.h" + +PPCCPUCoreList *qmp_query_ppc_cpu_cores(Error **errp) +{ + error_setg(errp, QERR_UNSUPPORTED); + return 0; +}