From: Daniel Henrique Barboza <danielhb@linux.vnet.ibm.com>
To: qemu-devel@nongnu.org
Cc: dgilbert@redhat.com, armbru@redhat.com,
Daniel Henrique Barboza <danielhb@linux.vnet.ibm.com>
Subject: [Qemu-devel] [PATCH v1 2/2] cpus.c: change qmp_query_cpus 'value->current' logic
Date: Wed, 13 Dec 2017 16:15:40 -0200 [thread overview]
Message-ID: <20171213181540.7949-3-danielhb@linux.vnet.ibm.com> (raw)
In-Reply-To: <20171213181540.7949-1-danielhb@linux.vnet.ibm.com>
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 == 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 <danielhb@linux.vnet.ibm.com>
---
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 = g_malloc0(sizeof(*info));
info->value = g_malloc0(sizeof(*info->value));
info->value->CPU = cpu->cpu_index;
- info->value->current = (cpu == first_cpu);
+ info->value->current = (cpu->cpu_index == monitor_get_cpu_index());
info->value->halted = cpu->halted;
info->value->qom_path = object_get_canonical_path(OBJECT(cpu));
info->value->thread_id = 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 = qmp_query_cpus(NULL);
for (cpu = cpu_list; cpu; cpu = cpu->next) {
- int active = ' ';
-
- if (cpu->value->CPU == monitor_get_cpu_index()) {
- active = '*';
- }
+ int active = cpu->value->current ? '*' : ' ';
monitor_printf(mon, "%c CPU #%" PRId64 ":", active, cpu->value->CPU);
--
2.13.6
next prev parent reply other threads:[~2017-12-13 18:16 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-12-13 18:15 [Qemu-devel] [PATCH v1 0/2] QMP: implementing qmp_cpu Daniel Henrique Barboza
2017-12-13 18:15 ` [Qemu-devel] [PATCH v1 1/2] qmp.c: (re)implement qmp_cpu Daniel Henrique Barboza
2017-12-14 2:18 ` Eric Blake
2017-12-14 15:21 ` Markus Armbruster
2017-12-14 19:46 ` Daniel Henrique Barboza
2017-12-15 13:56 ` Markus Armbruster
2017-12-15 18:11 ` Paolo Bonzini
2017-12-18 9:20 ` Markus Armbruster
2017-12-15 18:59 ` Dr. David Alan Gilbert
2017-12-18 9:12 ` Markus Armbruster
2017-12-13 18:15 ` Daniel Henrique Barboza [this message]
2017-12-14 19:50 ` [Qemu-devel] [PATCH v1 2/2] cpus.c: change qmp_query_cpus 'value->current' logic Daniel Henrique Barboza
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20171213181540.7949-3-danielhb@linux.vnet.ibm.com \
--to=danielhb@linux.vnet.ibm.com \
--cc=armbru@redhat.com \
--cc=dgilbert@redhat.com \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).