Add [vcpu] index support for hmp command "info lapic", which is
useful when debugging ipi and so on. Current behavior is not
changed when the parameter isn't specified.
Signed-off-by: Yi Wang <wang.yi59@zte.com.cn>
Signed-off-by: Yun Liu <liu.yunh@zte.com.cn>
---
hmp-commands-info.hx | 6 +++---
target/i386/monitor.c | 8 +++++++-
2 files changed, 10 insertions(+), 4 deletions(-)
diff --git a/hmp-commands-info.hx b/hmp-commands-info.hx
index d9df238..c534b03 100644
--- a/hmp-commands-info.hx
+++ b/hmp-commands-info.hx
@@ -115,9 +115,9 @@ ETEXI
#if defined(TARGET_I386)
{
.name = "lapic",
- .args_type = "",
- .params = "",
- .help = "show local apic state",
+ .args_type = "vcpu:i?",
+ .params = "[vcpu]",
+ .help = "show local apic state (vcpu: vCPU to read, default is 0)",
.cmd = hmp_info_local_apic,
},
#endif
diff --git a/target/i386/monitor.c b/target/i386/monitor.c
index 77ead60..813005e 100644
--- a/target/i386/monitor.c
+++ b/target/i386/monitor.c
@@ -632,8 +632,14 @@ const MonitorDef *target_monitor_defs(void)
void hmp_info_local_apic(Monitor *mon, const QDict *qdict)
{
- CPUState *cs = mon_get_cpu();
+ CPUState *cs;
+ if (qdict_haskey(qdict, "vcpu")) {
+ int index = qdict_get_try_int(qdict, "vcpu", 0);
+ cs = qemu_get_cpu(index);
+ } else {
+ cs = mon_get_cpu();
+ }
if (!cs) {
monitor_printf(mon, "No CPU available\n");
return;
--
1.8.3.1
On Mon, 17 Jul 2017 21:49:37 -0400 Yi Wang <wang.yi59@zte.com.cn> wrote: > Add [vcpu] index support for hmp command "info lapic", which is > useful when debugging ipi and so on. Current behavior is not > changed when the parameter isn't specified. we shouldn't expose cpu_index to users anymore, I would suggest using to use real APIC ID here but we don't have monitor command that returns APIC IDs for present cpus. "info hotpluggable-cpus" gives you a list of available CPUs it also gives you qom_path to cpu so potentially you could read apic-id property of cpu. But we have only QMP variant of qom-get so monitor needs addition of qom-get command that will be a wrapper around QMP command. It could be solved in 2 ways: * use socket-id/core-id/thread-id to specify desired cpu /possible values in 'info hotpluggable-cpus'/ * use apic-id value to specify interrupt controller - apic-id could be retrieved with new qom-get (qom-get would also be useful to read other properties) - extend 'info registers' with apic id value for example instead of current: CPU#1 EAX=00000c06 EBX=00000000 ECX=000002ff EDX=00000000 .... it would look like: CPU#1 (socket-id: a, core-id: b, thread-id: c, apic-id: d) ... > > Signed-off-by: Yi Wang <wang.yi59@zte.com.cn> > Signed-off-by: Yun Liu <liu.yunh@zte.com.cn> > --- > hmp-commands-info.hx | 6 +++--- > target/i386/monitor.c | 8 +++++++- > 2 files changed, 10 insertions(+), 4 deletions(-) > > diff --git a/hmp-commands-info.hx b/hmp-commands-info.hx > index d9df238..c534b03 100644 > --- a/hmp-commands-info.hx > +++ b/hmp-commands-info.hx > @@ -115,9 +115,9 @@ ETEXI > #if defined(TARGET_I386) > { > .name = "lapic", > - .args_type = "", > - .params = "", > - .help = "show local apic state", > + .args_type = "vcpu:i?", > + .params = "[vcpu]", > + .help = "show local apic state (vcpu: vCPU to read, default is 0)", > .cmd = hmp_info_local_apic, > }, > #endif > diff --git a/target/i386/monitor.c b/target/i386/monitor.c > index 77ead60..813005e 100644 > --- a/target/i386/monitor.c > +++ b/target/i386/monitor.c > @@ -632,8 +632,14 @@ const MonitorDef *target_monitor_defs(void) > > void hmp_info_local_apic(Monitor *mon, const QDict *qdict) > { > - CPUState *cs = mon_get_cpu(); > + CPUState *cs; > > + if (qdict_haskey(qdict, "vcpu")) { > + int index = qdict_get_try_int(qdict, "vcpu", 0); > + cs = qemu_get_cpu(index); > + } else { > + cs = mon_get_cpu(); > + } > if (!cs) { > monitor_printf(mon, "No CPU available\n"); > return;
On Tue, Jul 18, 2017 at 04:54:17PM +0200, Igor Mammedov wrote: > On Mon, 17 Jul 2017 21:49:37 -0400 > Yi Wang <wang.yi59@zte.com.cn> wrote: > > > Add [vcpu] index support for hmp command "info lapic", which is > > useful when debugging ipi and so on. Current behavior is not > > changed when the parameter isn't specified. > we shouldn't expose cpu_index to users anymore, > > I would suggest using to use real APIC ID here but we don't > have monitor command that returns APIC IDs for present cpus. > > "info hotpluggable-cpus" gives you a list of available CPUs > it also gives you qom_path to cpu so potentially you could > read apic-id property of cpu. > > But we have only QMP variant of qom-get so monitor needs > addition of qom-get command that will be a wrapper around > QMP command. > > It could be solved in 2 ways: > * use socket-id/core-id/thread-id to specify desired cpu > /possible values in 'info hotpluggable-cpus'/ > > * use apic-id value to specify interrupt controller > - apic-id could be retrieved with new qom-get > (qom-get would also be useful to read other properties) > - extend 'info registers' with apic id value > for example instead of current: > > CPU#1 > EAX=00000c06 EBX=00000000 ECX=000002ff EDX=00000000 > .... > > it would look like: > > CPU#1 (socket-id: a, core-id: b, thread-id: c, apic-id: d) > ... We already print "CPU #<n>" on "info cpus", so <n> is already a perfectly good identifier for a human interface. I think HMP should not require any identifier that isn't a simple number that is shown very prominently on "info cpus". If we don't want to use cpu_index as an identifier anymore, we can start printing arch ID instead of cpu_index on commands that print "CPU #<n>", and change mon_get_cpu() and monitor_set_cpu() accordingly. -- Eduardo
On Tue, 18 Jul 2017 20:26:50 -0300 Eduardo Habkost <ehabkost@redhat.com> wrote: > On Tue, Jul 18, 2017 at 04:54:17PM +0200, Igor Mammedov wrote: > > On Mon, 17 Jul 2017 21:49:37 -0400 > > Yi Wang <wang.yi59@zte.com.cn> wrote: > > > > > Add [vcpu] index support for hmp command "info lapic", which is > > > useful when debugging ipi and so on. Current behavior is not > > > changed when the parameter isn't specified. > > we shouldn't expose cpu_index to users anymore, > > > > I would suggest using to use real APIC ID here but we don't > > have monitor command that returns APIC IDs for present cpus. > > > > "info hotpluggable-cpus" gives you a list of available CPUs > > it also gives you qom_path to cpu so potentially you could > > read apic-id property of cpu. > > > > But we have only QMP variant of qom-get so monitor needs > > addition of qom-get command that will be a wrapper around > > QMP command. > > > > It could be solved in 2 ways: > > * use socket-id/core-id/thread-id to specify desired cpu > > /possible values in 'info hotpluggable-cpus'/ > > > > * use apic-id value to specify interrupt controller > > - apic-id could be retrieved with new qom-get > > (qom-get would also be useful to read other properties) > > - extend 'info registers' with apic id value > > for example instead of current: > > > > CPU#1 > > EAX=00000c06 EBX=00000000 ECX=000002ff EDX=00000000 > > .... > > > > it would look like: > > > > CPU#1 (socket-id: a, core-id: b, thread-id: c, apic-id: d) > > ... > > We already print "CPU #<n>" on "info cpus", so <n> is already a > perfectly good identifier for a human interface. I think HMP > should not require any identifier that isn't a simple number that > is shown very prominently on "info cpus". > > If we don't want to use cpu_index as an identifier anymore, we > can start printing arch ID instead of cpu_index on commands that > print "CPU #<n>", and change mon_get_cpu() and monitor_set_cpu() > accordingly. Looks like a good plan, but it probably should touch all commands that use cpu_index, also I'd leave cpu_index in 'info cpus' where it is till we faze it out from CLI.
On Mon, Jul 17, 2017 at 09:49:37PM -0400, Yi Wang wrote: > Add [vcpu] index support for hmp command "info lapic", which is > useful when debugging ipi and so on. Current behavior is not > changed when the parameter isn't specified. > > Signed-off-by: Yi Wang <wang.yi59@zte.com.cn> > Signed-off-by: Yun Liu <liu.yunh@zte.com.cn> We have 8 monitor commands (see below) that use the CPU set by the "cpu" command (mon_get_cpu()) as input. Why is "info lapic" special? * info cpustats * info lapic * info mem * info registers * info tlb * x * memsave * inject-nmi (QMP) -- Eduardo
© 2016 - 2024 Red Hat, Inc.