From patchwork Wed Dec 13 18:15:39 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Henrique Barboza X-Patchwork-Id: 848175 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=2001:4830:134:3::11; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) 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 3yxm8c0Prhz9s4q for ; Thu, 14 Dec 2017 05:54:56 +1100 (AEDT) Received: from localhost ([::1]:37049 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ePCBC-00062V-3j for incoming@patchwork.ozlabs.org; Wed, 13 Dec 2017 13:54:54 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52681) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ePBZe-0007e8-82 for qemu-devel@nongnu.org; Wed, 13 Dec 2017 13:16:07 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ePBZa-0002Nh-5B for qemu-devel@nongnu.org; Wed, 13 Dec 2017 13:16:06 -0500 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:50148 helo=mx0a-001b2d01.pphosted.com) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1ePBZZ-0002NB-W4 for qemu-devel@nongnu.org; Wed, 13 Dec 2017 13:16:02 -0500 Received: from pps.filterd (m0098413.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.0.21/8.16.0.21) with SMTP id vBDIDj8b107937 for ; Wed, 13 Dec 2017 13:15:57 -0500 Received: from e33.co.us.ibm.com (e33.co.us.ibm.com [32.97.110.151]) by mx0b-001b2d01.pphosted.com with ESMTP id 2eu6k7rgra-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Wed, 13 Dec 2017 13:15:57 -0500 Received: from localhost by e33.co.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Wed, 13 Dec 2017 11:15:56 -0700 Received: from b03cxnp08025.gho.boulder.ibm.com (9.17.130.17) by e33.co.us.ibm.com (192.168.1.133) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Wed, 13 Dec 2017 11:15:55 -0700 Received: from b03ledav004.gho.boulder.ibm.com (b03ledav004.gho.boulder.ibm.com [9.17.130.235]) by b03cxnp08025.gho.boulder.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id vBDIFt3b3211648; Wed, 13 Dec 2017 11:15:55 -0700 Received: from b03ledav004.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 0BBB978047; Wed, 13 Dec 2017 11:15:55 -0700 (MST) Received: from localhost.localdomain (unknown [9.85.206.94]) by b03ledav004.gho.boulder.ibm.com (Postfix) with ESMTP id A3F8778043; Wed, 13 Dec 2017 11:15:53 -0700 (MST) From: Daniel Henrique Barboza To: qemu-devel@nongnu.org Date: Wed, 13 Dec 2017 16:15:39 -0200 X-Mailer: git-send-email 2.13.6 In-Reply-To: <20171213181540.7949-1-danielhb@linux.vnet.ibm.com> References: <20171213181540.7949-1-danielhb@linux.vnet.ibm.com> X-TM-AS-GCONF: 00 x-cbid: 17121318-0008-0000-0000-000009070579 X-IBM-SpamModules-Scores: X-IBM-SpamModules-Versions: BY=3.00008200; HX=3.00000241; KW=3.00000007; PH=3.00000004; SC=3.00000244; SDB=6.00959718; UDB=6.00485392; IPR=6.00739739; BA=6.00005740; NDR=6.00000001; ZLA=6.00000005; ZF=6.00000009; ZB=6.00000000; ZP=6.00000000; ZH=6.00000000; ZU=6.00000002; MB=3.00018524; XFM=3.00000015; UTC=2017-12-13 18:15:56 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 17121318-0009-0000-0000-00004524FBD3 Message-Id: <20171213181540.7949-2-danielhb@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2017-12-13_09:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 malwarescore=0 suspectscore=1 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 impostorscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1709140000 definitions=main-1712130256 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] [fuzzy] X-Received-From: 148.163.158.5 Subject: [Qemu-devel] [PATCH v1 1/2] qmp.c: (re)implement qmp_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: Daniel Henrique Barboza , dgilbert@redhat.com, armbru@redhat.com Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" Commit 755f196898 ("qapi: Convert the cpu command") added the qmp_cpu function in qmp.c, leaving it blank. It the same commit, a working hmp_cpu was implemented. Since then, no further changes were made in qmp_cpu, resulting now in a working 'cpu' command that works in HMP and a 'cpu' command in QMP that does nothing. Regardless of what constraints were involved that time in not implemeting qmp_cpu, at this moment it is possible to have both. This patch brings the logic of hmp_cpu to qmp_cpu and converts the HMP function to use its QMP counterpart. Signed-off-by: Daniel Henrique Barboza --- hmp.c | 8 +++----- qapi-schema.json | 14 +++++++++++--- qmp.c | 4 +++- 3 files changed, 17 insertions(+), 9 deletions(-) diff --git a/hmp.c b/hmp.c index 35a7041824..7506f105a0 100644 --- a/hmp.c +++ b/hmp.c @@ -1070,13 +1070,11 @@ void hmp_system_powerdown(Monitor *mon, const QDict *qdict) void hmp_cpu(Monitor *mon, const QDict *qdict) { int64_t cpu_index; + Error *err = NULL; - /* XXX: drop the monitor_set_cpu() usage when all HMP commands that - use it are converted to the QAPI */ cpu_index = qdict_get_int(qdict, "index"); - if (monitor_set_cpu(cpu_index) < 0) { - monitor_printf(mon, "invalid CPU index\n"); - } + qmp_cpu(cpu_index, &err); + hmp_handle_error(mon, &err); } void hmp_memsave(Monitor *mon, const QDict *qdict) diff --git a/qapi-schema.json b/qapi-schema.json index 18457954a8..4c8f2d405e 100644 --- a/qapi-schema.json +++ b/qapi-schema.json @@ -1048,11 +1048,19 @@ ## # @cpu: # -# This command is a nop that is only provided for the purposes of compatibility. +# Set the default CPU. # -# Since: 0.14.0 +# @index: The index of the virtual CPU to be set as default +# +# Returns: Nothing on success +# +# Since: 2.12.0 +# +# Example: +# +# -> { "execute": "cpu", "arguments": { "index": 2 } } +# <- { "return": {} } # -# Notes: Do not use this command. ## { 'command': 'cpu', 'data': {'index': 'int'} } diff --git a/qmp.c b/qmp.c index e8c303116a..c482225d5c 100644 --- a/qmp.c +++ b/qmp.c @@ -115,7 +115,9 @@ void qmp_system_powerdown(Error **erp) void qmp_cpu(int64_t index, Error **errp) { - /* Just do nothing */ + if (monitor_set_cpu(index) < 0) { + error_setg(errp, "Invalid CPU index"); + } } void qmp_cpu_add(int64_t id, Error **errp)