hw/intc: Introduce x-query-interrupt-controllers QMP command
cover hw/intc: Introduce x-query-interrupt-controllers QMP command
Continuing previous work from Daniel:
https://lore.kernel.org/qemu-devel/[email protected]/
- Prefer HumanReadableText over Monitor in hw/intc/
- Introduce x-query-interrupt-controllers QMP command
See commits f2de406f29 ("docs/devel: document expectations for QAPI data modelling for QMP") and 3d312f417d ("docs/devel: document expectations for HMP commands in the future") for rationale.
Based-on: <[email protected]>
Philippe Mathieu-Daudé (2):
hw/intc: Avoid using Monitor in INTERRUPT_STATS_PROVIDER::print_info() hw/intc: Introduce x-query-interrupt-controllers QMP command
qapi/machine.json | 17 ++++++++++++ include/hw/intc/intc.h | 2 +- hw/core/machine-qmp-cmds.c | 29 +++++++++++++++++++ hw/intc/goldfish_pic.c | 8 +++--- hw/intc/i8259_common.c | 14 +++++----- hw/intc/ioapic_common.c | 57 +++++++++++++++++++------------------- hw/intc/m68k_irqc.c | 5 ++-- hw/intc/slavio_intctl.c | 11 ++++---- hw/ppc/pnv.c | 10 +------ hw/ppc/spapr.c | 10 +------ monitor/hmp-cmds.c | 27 ------------------ hmp-commands-info.hx | 2 +- 12 files changed, 97 insertions(+), 95 deletions(-)
Signature · 1 line
2.41.0
PATCH 1/2 hw/intc: Avoid using Monitor in INTERRUPT_STATS_PROVIDER::print_info()
Replace Monitor API by HumanReadableText one (see commit f2de406f29 "docs/devel: document expectations for QAPI data modelling for QMP" for rationale).
--- include/hw/intc/intc.h | 2 +- hw/intc/goldfish_pic.c | 8 +++--- hw/intc/i8259_common.c | 14 +++++----- hw/intc/ioapic_common.c | 57 +++++++++++++++++++++-------------------- hw/intc/m68k_irqc.c | 5 ++-- hw/intc/slavio_intctl.c | 11 ++++---- hw/ppc/pnv.c | 10 +------- hw/ppc/spapr.c | 10 +------- monitor/hmp-cmds.c | 8 +++++- 9 files changed, 57 insertions(+), 68 deletions(-)
include/hw/intc/intc.h +1 -1
@@ -22,7 +22,7 @@ struct InterruptStatsProviderClass {*/ bool (*get_statistics)(InterruptStatsProvider *obj,uint64_t **irq_counts,unsigned int *nb_irqs); - void (*print_info)(InterruptStatsProvider *obj, Monitor *mon); + void (*print_info)(InterruptStatsProvider *obj, GString *buf); };#endif
hw/intc/goldfish_pic.c +4 -4
@@ -12,7 +12,6 @@#include "hw/qdev-properties.h" #include "hw/sysbus.h" #include "migration/vmstate.h" -#include "monitor/monitor.h" #include "qemu/log.h" #include "trace.h" #include "hw/intc/intc.h"
@@ -39,11 +38,12 @@ static bool goldfish_pic_get_statistics(InterruptStatsProvider *obj,return true; } -static void goldfish_pic_print_info (InterruptStatsProvider *obj,Monitor *mon) +static void goldfish_pic_print_info (InterruptStatsProvider *obj,GString *buf) {GoldfishPICState *s =GOLDFISH_PIC (obj); -monitor_printf (mon,"goldfish-pic.%d: pending=0x%08x enabled=0x%08x\n" , - s->idx, s->pending, s->enabled); +g_string_append_printf (buf, +"goldfish-pic.%d: pending=0x%08x enabled=0x%08x\n" , + s->idx, s->pending, s->enabled); }static void goldfish_pic_update (GoldfishPICState *s)
hw/intc/i8259_common.c +7 -7
@@ -28,7 +28,6 @@#include "hw/isa/i8259_internal.h" #include "hw/qdev-properties.h" #include "migration/vmstate.h" -#include "monitor/monitor.h" #include "qapi/error.h" static int irq_level[16 ];
@@ -132,16 +131,17 @@ static bool pic_get_statistics(InterruptStatsProvider *obj,return true; } -static void pic_print_info (InterruptStatsProvider *obj,Monitor *mon) +static void pic_print_info (InterruptStatsProvider *obj,GString *buf) {PICCommonState *s =PIC_COMMON (obj);pic_dispatch_pre_save (s); -monitor_printf (mon,"pic%d: irr=%02x imr=%02x isr=%02x hprio=%d " -"irq_base=%02x rr_sel=%d elcr=%02x fnm=%d\n" , - s->master ?0 :1 , s->irr, s->imr, s->isr, s->priority_add, - s->irq_base, s->read_reg_select, s->elcr, - s->special_fully_nested_mode); +g_string_append_printf (buf,"pic%d: irr=%02x imr=%02x isr=%02x hprio=%d " +"irq_base=%02x rr_sel=%d elcr=%02x fnm=%d\n" , + s->master ?0 :1 , s->irr, s->imr, s->isr, + s->priority_add, + s->irq_base, s->read_reg_select, s->elcr, + s->special_fully_nested_mode); }static bool ltim_state_needed (void *opaque)
hw/intc/ioapic_common.c +29 -28
108 lines not on this page · raw message
hw/intc/m68k_irqc.c +2 -3
@@ -10,7 +10,6 @@#include "qemu/osdep.h" #include "cpu.h" #include "migration/vmstate.h" -#include "monitor/monitor.h" #include "hw/qdev-properties.h" #include "hw/nmi.h" #include "hw/intc/intc.h"
@@ -27,10 +26,10 @@ static bool m68k_irqc_get_statistics(InterruptStatsProvider *obj,return true; } -static void m68k_irqc_print_info (InterruptStatsProvider *obj,Monitor *mon) +static void m68k_irqc_print_info (InterruptStatsProvider *obj,GString *buf) {M68KIRQCState *s =M68K_IRQC (obj); -monitor_printf (mon,"m68k-irqc: ipr=0x%x\n" , s->ipr); +g_string_append_printf (buf,"m68k-irqc: ipr=0x%x\n" , s->ipr); }static void m68k_set_irq (void *opaque,int irq,int level)
hw/intc/slavio_intctl.c +5 -6
@@ -24,7 +24,6 @@#include "qemu/osdep.h" #include "migration/vmstate.h" -#include "monitor/monitor.h" #include "qemu/module.h" #include "hw/sysbus.h" #include "hw/intc/intc.h"
@@ -401,17 +400,17 @@ static bool slavio_intctl_get_statistics(InterruptStatsProvider *obj, }#endif -static void slavio_intctl_print_info (InterruptStatsProvider *obj,Monitor *mon) +static void slavio_intctl_print_info (InterruptStatsProvider *obj,GString *buf) {SLAVIO_INTCTLState *s =SLAVIO_INTCTL (obj);int i;for (i =0 ; i <MAX_CPUS ; i++) { -monitor_printf (mon,"per-cpu %d: pending 0x%08x\n" , i, - s->slaves[i].intreg_pending); +g_string_append_printf (buf,"per-cpu %d: pending 0x%08x\n" , i, + s->slaves[i].intreg_pending); } -monitor_printf (mon,"master: pending 0x%08x, disabled 0x%08x\n" , - s->intregm_pending, s->intregm_disabled); +g_string_append_printf (buf,"master: pending 0x%08x, disabled 0x%08x\n" , + s->intregm_pending, s->intregm_disabled); }static void slavio_intctl_init (Object *obj)
hw/ppc/pnv.c +1 -9
@@ -38,8 +38,6 @@#include "hw/loader.h" #include "hw/nmi.h" #include "qapi/visitor.h" -#include "qapi/type-helpers.h" -#include "monitor/monitor.h" #include "hw/intc/intc.h" #include "hw/ipmi/ipmi.h" #include "target/ppc/mmu-hash64.h"
@@ -2331,14 +2329,11 @@ static ICPState *pnv_icp_get(XICSFabric *xi, int pir)return cpu ?ICP (pnv_cpu_state (cpu)->intc) :NULL ; } -static void pnv_pic_print_info (InterruptStatsProvider *obj, -Monitor *mon) +static void pnv_pic_print_info (InterruptStatsProvider *obj,GString *buf) {PnvMachineState *pnv =PNV_MACHINE (obj);int i;CPUState *cs; -g_autoptr (GString) buf =g_string_new ("" ); -g_autoptr (HumanReadableText) info =NULL ;CPU_FOREACH (cs) {PowerPCCPU *cpu =POWERPC_CPU (cs);
@@ -2351,9 +2346,6 @@ static void pnv_pic_print_info(InterruptStatsProvider *obj,for (i =0 ; i < pnv->num_chips; i++) {PNV_CHIP_GET_CLASS (pnv->chips[i])->pic_print_info (pnv->chips[i], buf); } - - info =human_readable_text_from_str (buf); -monitor_puts (mon, info->human_readable_text); } static int pnv_match_nvt(XiveFabric *xfb, uint8_t format,
hw/ppc/spapr.c +1 -9
@@ -31,7 +31,6 @@#include "qapi/error.h" #include "qapi/qapi-events-machine.h" #include "qapi/qapi-events-qdev.h" -#include "qapi/type-helpers.h" #include "qapi/visitor.h" #include "sysemu/sysemu.h" #include "sysemu/hostmem.h"
@@ -90,8 +89,6 @@#include "hw/ppc/spapr_nvdimm.h" #include "hw/ppc/spapr_numa.h" -#include "monitor/monitor.h" -#include <libfdt.h> /* SLOF memory layout:
@@ -4527,18 +4524,13 @@ static ICPState *spapr_icp_get(XICSFabric *xi, int vcpu_id)return cpu ?spapr_cpu_state (cpu)->icp :NULL ; } -static void spapr_pic_print_info (InterruptStatsProvider *obj, -Monitor *mon) +static void spapr_pic_print_info (InterruptStatsProvider *obj,GString *buf) {SpaprMachineState *spapr =SPAPR_MACHINE (obj); -g_autoptr (GString) buf =g_string_new ("" ); -g_autoptr (HumanReadableText) info =NULL ;spapr_irq_print_info (spapr, buf);g_string_append_printf (buf,"irqchip: %s\n" ,kvm_irqchip_in_kernel () ?"in-kernel" :"emulated" ); - info =human_readable_text_from_str (buf); -monitor_puts (mon, info->human_readable_text); }/*
monitor/hmp-cmds.c +7 -1
@@ -25,6 +25,7 @@#include "qapi/qapi-commands-machine.h" #include "qapi/qapi-commands-misc.h" #include "qapi/qmp/qdict.h" +#include "qapi/type-helpers.h" #include "qemu/cutils.h" #include "hw/intc/intc.h" #include "qemu/log.h"
@@ -92,7 +93,12 @@ static int hmp_info_pic_foreach(Object *obj, void *opaque) intc =INTERRUPT_STATS_PROVIDER (obj); k =INTERRUPT_STATS_PROVIDER_GET_CLASS (obj);if (k->print_info) { - k->print_info (intc, mon); +g_autoptr (GString) buf =g_string_new ("" ); +g_autoptr (HumanReadableText) info =NULL ; + + k->print_info (intc, buf); + info =human_readable_text_from_str (buf); +monitor_puts (mon, info->human_readable_text); }else {monitor_printf (mon,"Interrupt controller information not available for %s.\n" ,object_get_typename (obj));
Signature · 1 line
2.41.0
Re: [PATCH 1/2] hw/intc: Avoid using Monitor in INTERRUPT_STATS_PROVIDER::print_info()
Quoted 5 lines · Philippe Mathieu-Daudé
Replace Monitor API by HumanReadableText one (see commit
f2de406f29"docs/devel: document expectations for QAPI data modelling for QMP" for rationale).Signed-off-by Philippe Mathieu-Daudé <[email protected]>
Quoted 11 lines
--- include/hw/intc/intc.h | 2 +- hw/intc/goldfish_pic.c | 8 +++--- hw/intc/i8259_common.c | 14 +++++----- hw/intc/ioapic_common.c | 57 +++++++++++++++++++++-------------------- hw/intc/m68k_irqc.c | 5 ++-- hw/intc/slavio_intctl.c | 11 ++++---- hw/ppc/pnv.c | 10 +------- hw/ppc/spapr.c | 10 +------- monitor/hmp-cmds.c | 8 +++++- 9 files changed, 57 insertions(+), 68 deletions(-)
With regards,
Daniel
Signature · 3 lines
|: https://berrange.com -o- https://www.flickr.com/photos/dberrange :| |: https://libvirt.org -o- https://fstop138.berrange.com :| |: https://entangle-photo.org -o- https://www.instagram.com/dberrange :|
PATCH 2/2 hw/intc: Introduce x-query-interrupt-controllers QMP command
In reply to Philippe Mathieu-DaudéThis is a counterpart to the HMP "info pic" command. It is being added with an "x-" prefix because this QMP command is intended as an adhoc debugging tool and will thus not be modelled in QAPI as fully structured data, nor will it have long term guaranteed stability. The existing HMP command is rewritten to call the QMP command.
--- qapi/machine.json | 17 +++++++++++++++++ hw/core/machine-qmp-cmds.c | 29 +++++++++++++++++++++++++++++ monitor/hmp-cmds.c | 33 --------------------------------- hmp-commands-info.hx | 2 +- 4 files changed, 47 insertions(+), 34 deletions(-)
qapi/machine.json +17 -0
@@ -1864,3 +1864,20 @@ { 'command': 'dumpdtb', 'data': { 'filename': 'str' }, 'if': 'CONFIG_FDT' } + +## +# @x-query-interrupt-controllers: +# +# Query information on interrupt controller devices +# +# Features: +# +# @unstable: This command is meant for debugging. +# +# Returns: Interrupt controller device information +# +# Since: 9.1 +## +{ 'command': 'x-query-interrupt-controllers', + 'returns': 'HumanReadableText', + 'features': [ 'unstable' ]}
hw/core/machine-qmp-cmds.c +29 -0
@@ -361,6 +361,35 @@ HumanReadableText *qmp_x_query_irq(Error **errp)return human_readable_text_from_str (buf); } +static int qmp_x_query_intc_foreach (Object *obj,void *opaque) +{ +InterruptStatsProvider *intc; +InterruptStatsProviderClass *k; +GString *buf = opaque; + +if (object_dynamic_cast (obj,TYPE_INTERRUPT_STATS_PROVIDER )) { + intc =INTERRUPT_STATS_PROVIDER (obj); + k =INTERRUPT_STATS_PROVIDER_GET_CLASS (obj); +if (k->print_info) { + k->print_info (intc, buf); + }else { +g_string_append_printf (buf, +"Interrupt controller information not available for %s.\n" , +object_get_typename (obj)); + } + } + +return 0 ; +} + +HumanReadableText *qmp_x_query_interrupt_controllers (Error **errp) +{ +g_autoptr (GString) buf =g_string_new ("" ); +object_child_foreach_recursive (object_get_root (), + qmp_x_query_intc_foreach, buf); +return human_readable_text_from_str (buf); +} +GuidInfo *qmp_query_vm_generation_id (Error **errp) {GuidInfo *info;
monitor/hmp-cmds.c +0 -33
@@ -25,9 +25,7 @@#include "qapi/qapi-commands-machine.h" #include "qapi/qapi-commands-misc.h" #include "qapi/qmp/qdict.h" -#include "qapi/type-helpers.h" #include "qemu/cutils.h" -#include "hw/intc/intc.h" #include "qemu/log.h" #include "sysemu/sysemu.h"
@@ -83,37 +81,6 @@ void hmp_info_version(Monitor *mon, const QDict *qdict)qapi_free_VersionInfo (info); } -static int hmp_info_pic_foreach (Object *obj,void *opaque) -{ -InterruptStatsProvider *intc; -InterruptStatsProviderClass *k; -Monitor *mon = opaque; - -if (object_dynamic_cast (obj,TYPE_INTERRUPT_STATS_PROVIDER )) { - intc =INTERRUPT_STATS_PROVIDER (obj); - k =INTERRUPT_STATS_PROVIDER_GET_CLASS (obj); -if (k->print_info) { -g_autoptr (GString) buf =g_string_new ("" ); -g_autoptr (HumanReadableText) info =NULL ; - - k->print_info (intc, buf); - info =human_readable_text_from_str (buf); -monitor_puts (mon, info->human_readable_text); - }else { -monitor_printf (mon,"Interrupt controller information not available for %s.\n" , -object_get_typename (obj)); - } - } - -return 0 ; -} - -void hmp_info_pic (Monitor *mon,const QDict *qdict) -{ -object_child_foreach_recursive (object_get_root (), - hmp_info_pic_foreach, mon); -} -void hmp_quit (Monitor *mon,const QDict *qdict) {monitor_suspend (mon);
hmp-commands-info.hx +1 -1
@@ -174,7 +174,7 @@ ERST .args_type = "", .params = "", .help = "show PIC state", - .cmd = hmp_info_pic, + .cmd_info_hrt = qmp_x_query_interrupt_controllers, }, SRST
Signature · 1 line
2.41.0
Quoted 6 lines · Philippe Mathieu-Daudé
This is a counterpart to the HMP "info pic" command. It is being added with an "x-" prefix because this QMP command is intended as an adhoc debugging tool and will thus not be modelled in QAPI as fully structured data, nor will it have long term guaranteed stability. The existing HMP command is rewritten to call the QMP command.
Quoted 7 lines
Signed-off-by Philippe Mathieu-Daudé <[email protected]>--- qapi/machine.json | 17 +++++++++++++++++ hw/core/machine-qmp-cmds.c | 29 +++++++++++++++++++++++++++++ monitor/hmp-cmds.c | 33 --------------------------------- hmp-commands-info.hx | 2 +- 4 files changed, 47 insertions(+), 34 deletions(-)
With regards,
Daniel
Signature · 3 lines
|: https://berrange.com -o- https://www.flickr.com/photos/dberrange :| |: https://libvirt.org -o- https://fstop138.berrange.com :| |: https://entangle-photo.org -o- https://www.instagram.com/dberrange :|
Quoted 3 lines · Philippe Mathieu-Daudé
Philippe Mathieu-Daudé (2):
hw/intc: Avoid using Monitor inINTERRUPT_STATS_PROVIDER::print_info()hw/intc: Introduce x-query-interrupt-controllers QMP command
Series queued.