Message ID | 20210908103711.683940-6-berrange@redhat.com |
---|---|
State | New |
Headers | show |
Series | Stop adding HMP-only commands, allow QMP for all | expand |
On 9/8/21 12:37 PM, Daniel P. Berrangé wrote: > Now that we have a QMP command 'x-query-registers', the HMP counterpart > 'info registers' can be refactored to call the former. > > Signed-off-by: Daniel P. Berrangé <berrange@redhat.com> > --- > monitor/misc.c | 25 ++++++++++++++++--------- > 1 file changed, 16 insertions(+), 9 deletions(-) > > diff --git a/monitor/misc.c b/monitor/misc.c > index ffe7966870..f0b94c3084 100644 > --- a/monitor/misc.c > +++ b/monitor/misc.c > @@ -67,6 +67,7 @@ > #include "block/block-hmp-cmds.h" > #include "qapi/qapi-commands-char.h" > #include "qapi/qapi-commands-control.h" > +#include "qapi/qapi-commands-machine.h" > #include "qapi/qapi-commands-migration.h" > #include "qapi/qapi-commands-misc.h" > #include "qapi/qapi-commands-qom.h" > @@ -301,23 +302,29 @@ int monitor_get_cpu_index(Monitor *mon) > static void hmp_info_registers(Monitor *mon, const QDict *qdict) > { > bool all_cpus = qdict_get_try_bool(qdict, "cpustate_all", false); > - CPUState *cs; > + bool has_cpu = !all_cpus; > + int64_t cpu = 0; > + Error *local_err = NULL; > + g_autoptr(RegisterInfo) info = NULL; > > - if (all_cpus) { > - CPU_FOREACH(cs) { > - monitor_printf(mon, "\nCPU#%d\n", cs->cpu_index); > - cpu_dump_state(cs, NULL, CPU_DUMP_FPU); And once all targets are converted we can remove cpu_dump_state().
On Wed, Sep 08, 2021 at 01:01:21PM +0200, Philippe Mathieu-Daudé wrote: > On 9/8/21 12:37 PM, Daniel P. Berrangé wrote: > > Now that we have a QMP command 'x-query-registers', the HMP counterpart > > 'info registers' can be refactored to call the former. > > > > Signed-off-by: Daniel P. Berrangé <berrange@redhat.com> > > --- > > monitor/misc.c | 25 ++++++++++++++++--------- > > 1 file changed, 16 insertions(+), 9 deletions(-) > > > > diff --git a/monitor/misc.c b/monitor/misc.c > > index ffe7966870..f0b94c3084 100644 > > --- a/monitor/misc.c > > +++ b/monitor/misc.c > > @@ -67,6 +67,7 @@ > > #include "block/block-hmp-cmds.h" > > #include "qapi/qapi-commands-char.h" > > #include "qapi/qapi-commands-control.h" > > +#include "qapi/qapi-commands-machine.h" > > #include "qapi/qapi-commands-migration.h" > > #include "qapi/qapi-commands-misc.h" > > #include "qapi/qapi-commands-qom.h" > > @@ -301,23 +302,29 @@ int monitor_get_cpu_index(Monitor *mon) > > static void hmp_info_registers(Monitor *mon, const QDict *qdict) > > { > > bool all_cpus = qdict_get_try_bool(qdict, "cpustate_all", false); > > - CPUState *cs; > > + bool has_cpu = !all_cpus; > > + int64_t cpu = 0; > > + Error *local_err = NULL; > > + g_autoptr(RegisterInfo) info = NULL; > > > > - if (all_cpus) { > > - CPU_FOREACH(cs) { > > - monitor_printf(mon, "\nCPU#%d\n", cs->cpu_index); > > - cpu_dump_state(cs, NULL, CPU_DUMP_FPU); > > And once all targets are converted we can remove cpu_dump_state(). Yes, if we take approach in this series, then there would be another 20-ish patches inserted before this one, to convert all the other targets, and eliminate the cpu_dump_state method / callback. Regards, Daniel
diff --git a/monitor/misc.c b/monitor/misc.c index ffe7966870..f0b94c3084 100644 --- a/monitor/misc.c +++ b/monitor/misc.c @@ -67,6 +67,7 @@ #include "block/block-hmp-cmds.h" #include "qapi/qapi-commands-char.h" #include "qapi/qapi-commands-control.h" +#include "qapi/qapi-commands-machine.h" #include "qapi/qapi-commands-migration.h" #include "qapi/qapi-commands-misc.h" #include "qapi/qapi-commands-qom.h" @@ -301,23 +302,29 @@ int monitor_get_cpu_index(Monitor *mon) static void hmp_info_registers(Monitor *mon, const QDict *qdict) { bool all_cpus = qdict_get_try_bool(qdict, "cpustate_all", false); - CPUState *cs; + bool has_cpu = !all_cpus; + int64_t cpu = 0; + Error *local_err = NULL; + g_autoptr(RegisterInfo) info = NULL; - if (all_cpus) { - CPU_FOREACH(cs) { - monitor_printf(mon, "\nCPU#%d\n", cs->cpu_index); - cpu_dump_state(cs, NULL, CPU_DUMP_FPU); - } - } else { - cs = mon_get_cpu(mon); + if (has_cpu) { + CPUState *cs = mon_get_cpu(mon); if (!cs) { monitor_printf(mon, "No CPU available\n"); return; } - cpu_dump_state(cs, NULL, CPU_DUMP_FPU); + cpu = cs->cpu_index; + } + + info = qmp_x_query_registers(has_cpu, cpu, &local_err); + if (!info) { + error_report_err(local_err); + return; } + + monitor_printf(mon, "%s", info->state); } static void hmp_info_sync_profile(Monitor *mon, const QDict *qdict)
Now that we have a QMP command 'x-query-registers', the HMP counterpart 'info registers' can be refactored to call the former. Signed-off-by: Daniel P. Berrangé <berrange@redhat.com> --- monitor/misc.c | 25 ++++++++++++++++--------- 1 file changed, 16 insertions(+), 9 deletions(-)