From nobody Sun May 5 06:33:43 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 151319134811899.34416467337041; Wed, 13 Dec 2017 10:55:48 -0800 (PST) Received: from localhost ([::1]:37058 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ePCBt-0006mK-Dn for importer@patchew.org; Wed, 13 Dec 2017 13:55:37 -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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" 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 =3D NULL; =20 - /* XXX: drop the monitor_set_cpu() usage when all HMP commands that - use it are converted to the QAPI */ cpu_index =3D 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); } =20 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 compatib= ility. +# 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'} } =20 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) =20 void qmp_cpu(int64_t index, Error **errp) { - /* Just do nothing */ + if (monitor_set_cpu(index) < 0) { + error_setg(errp, "Invalid CPU index"); + } } =20 void qmp_cpu_add(int64_t id, Error **errp) --=20 2.13.6 From nobody Sun May 5 06:33:43 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 151319083494696.29889524181442; Wed, 13 Dec 2017 10:47:14 -0800 (PST) Received: from localhost ([::1]:36983 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ePC3m-000849-6j for importer@patchew.org; Wed, 13 Dec 2017 13:47:14 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52683) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ePBZe-0007e9-8t for qemu-devel@nongnu.org; Wed, 13 Dec 2017 13:16:12 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ePBZb-0002Oc-2X for qemu-devel@nongnu.org; Wed, 13 Dec 2017 13:16:06 -0500 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:49386 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 1ePBZa-0002OB-T4 for qemu-devel@nongnu.org; Wed, 13 Dec 2017 13:16:02 -0500 Received: from pps.filterd (m0098417.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.21/8.16.0.21) with SMTP id vBDIDkgR005441 for ; Wed, 13 Dec 2017 13:16:02 -0500 Received: from e31.co.us.ibm.com (e31.co.us.ibm.com [32.97.110.149]) by mx0a-001b2d01.pphosted.com with ESMTP id 2eu6mmrtan-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Wed, 13 Dec 2017 13:16:02 -0500 Received: from localhost by e31.co.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Wed, 13 Dec 2017 11:16:01 -0700 Received: from b03cxnp07028.gho.boulder.ibm.com (9.17.130.15) by e31.co.us.ibm.com (192.168.1.131) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Wed, 13 Dec 2017 11:15:58 -0700 Received: from b03ledav004.gho.boulder.ibm.com (b03ledav004.gho.boulder.ibm.com [9.17.130.235]) by b03cxnp07028.gho.boulder.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id vBDIFvP860817506; Wed, 13 Dec 2017 11:15:57 -0700 Received: from b03ledav004.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id CEEC978056; Wed, 13 Dec 2017 11:15:57 -0700 (MST) Received: from localhost.localdomain (unknown [9.85.206.94]) by b03ledav004.gho.boulder.ibm.com (Postfix) with ESMTP id 6C34678041; Wed, 13 Dec 2017 11:15:56 -0700 (MST) From: Daniel Henrique Barboza To: qemu-devel@nongnu.org Date: Wed, 13 Dec 2017 16:15:40 -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-8235-0000-0000-00000CB9FAA1 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:16:00 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 17121318-8236-0000-0000-00003ED546A3 Message-Id: <20171213181540.7949-3-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=1011 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 2/2] cpus.c: change qmp_query_cpus 'value->current' logic 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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" qmp_query_cpus always return the same information, ignoring the monitor state. This means that information such as cpu->value->current will always return the same value ((cpu =3D=3D first_cpu) at this moment). This function is used by hmp_info_cpus that does its own logic based on monitor_get_cpu_index() to print the current/active CPU information, ignoring cpu->value->current. This value is used as is in QMP query-cpus though. This wasn't a problem because QMP couldn't set its current CPU via qmp_cpu anyway, so query-cpus returning the same state all the time (regarding current CPU for the monitor) wasn't a problem. But now we can use qmp_cpu to set the current monitor CPU, making the return from query-cpus wrong. This patch makes a simple change in qmp_query_cpus to change the cpu->value->current logic to consider the current monitor state, like it was being done in hmp_info_cpus. Now, cpu->value->current will return an accurate value for both QMP and HMP calls. hmp_info_cpus can no use this value directly instead of doing its own logic. Signed-off-by: Daniel Henrique Barboza --- cpus.c | 2 +- hmp.c | 6 +----- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/cpus.c b/cpus.c index 114c29b6a0..d3b79d1c02 100644 --- a/cpus.c +++ b/cpus.c @@ -1919,7 +1919,7 @@ CpuInfoList *qmp_query_cpus(Error **errp) info =3D g_malloc0(sizeof(*info)); info->value =3D g_malloc0(sizeof(*info->value)); info->value->CPU =3D cpu->cpu_index; - info->value->current =3D (cpu =3D=3D first_cpu); + info->value->current =3D (cpu->cpu_index =3D=3D monitor_get_cpu_in= dex()); info->value->halted =3D cpu->halted; info->value->qom_path =3D object_get_canonical_path(OBJECT(cpu)); info->value->thread_id =3D cpu->thread_id; diff --git a/hmp.c b/hmp.c index 7506f105a0..1259cafc1f 100644 --- a/hmp.c +++ b/hmp.c @@ -363,11 +363,7 @@ void hmp_info_cpus(Monitor *mon, const QDict *qdict) cpu_list =3D qmp_query_cpus(NULL); =20 for (cpu =3D cpu_list; cpu; cpu =3D cpu->next) { - int active =3D ' '; - - if (cpu->value->CPU =3D=3D monitor_get_cpu_index()) { - active =3D '*'; - } + int active =3D cpu->value->current ? '*' : ' '; =20 monitor_printf(mon, "%c CPU #%" PRId64 ":", active, cpu->value->CP= U); =20 --=20 2.13.6