[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH v1 1/2] qmp.c: (re)implement qmp_cpu
From: |
Daniel Henrique Barboza |
Subject: |
[Qemu-devel] [PATCH v1 1/2] qmp.c: (re)implement qmp_cpu |
Date: |
Wed, 13 Dec 2017 16:15:39 -0200 |
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 <address@hidden>
---
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)
--
2.13.6
- [Qemu-devel] [PATCH v1 0/2] QMP: implementing qmp_cpu, Daniel Henrique Barboza, 2017/12/13
- [Qemu-devel] [PATCH v1 1/2] qmp.c: (re)implement qmp_cpu,
Daniel Henrique Barboza <=
- Re: [Qemu-devel] [PATCH v1 1/2] qmp.c: (re)implement qmp_cpu, Eric Blake, 2017/12/13
- Re: [Qemu-devel] [PATCH v1 1/2] qmp.c: (re)implement qmp_cpu, Markus Armbruster, 2017/12/14
- Re: [Qemu-devel] [PATCH v1 1/2] qmp.c: (re)implement qmp_cpu, Daniel Henrique Barboza, 2017/12/14
- Re: [Qemu-devel] [PATCH v1 1/2] qmp.c: (re)implement qmp_cpu, Markus Armbruster, 2017/12/15
- Re: [Qemu-devel] [PATCH v1 1/2] qmp.c: (re)implement qmp_cpu, Paolo Bonzini, 2017/12/15
- Re: [Qemu-devel] [PATCH v1 1/2] qmp.c: (re)implement qmp_cpu, Markus Armbruster, 2017/12/18
- Re: [Qemu-devel] [PATCH v1 1/2] qmp.c: (re)implement qmp_cpu, Dr. David Alan Gilbert, 2017/12/15
- Re: [Qemu-devel] [PATCH v1 1/2] qmp.c: (re)implement qmp_cpu, Markus Armbruster, 2017/12/18
[Qemu-devel] [PATCH v1 2/2] cpus.c: change qmp_query_cpus 'value->current' logic, Daniel Henrique Barboza, 2017/12/13