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). Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org> Reviewed-by: Daniel P. Berrangé <berrange@redhat.com> Message-Id: <20240610063518.50680-2-philmd@linaro.org>
This commit is contained in:
parent
a58e653aa2
commit
b2580720d0
@ -12,7 +12,6 @@
|
|||||||
#include "hw/qdev-properties.h"
|
#include "hw/qdev-properties.h"
|
||||||
#include "hw/sysbus.h"
|
#include "hw/sysbus.h"
|
||||||
#include "migration/vmstate.h"
|
#include "migration/vmstate.h"
|
||||||
#include "monitor/monitor.h"
|
|
||||||
#include "qemu/log.h"
|
#include "qemu/log.h"
|
||||||
#include "trace.h"
|
#include "trace.h"
|
||||||
#include "hw/intc/intc.h"
|
#include "hw/intc/intc.h"
|
||||||
@ -39,11 +38,12 @@ static bool goldfish_pic_get_statistics(InterruptStatsProvider *obj,
|
|||||||
return true;
|
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);
|
GoldfishPICState *s = GOLDFISH_PIC(obj);
|
||||||
monitor_printf(mon, "goldfish-pic.%d: pending=0x%08x enabled=0x%08x\n",
|
g_string_append_printf(buf,
|
||||||
s->idx, s->pending, s->enabled);
|
"goldfish-pic.%d: pending=0x%08x enabled=0x%08x\n",
|
||||||
|
s->idx, s->pending, s->enabled);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void goldfish_pic_update(GoldfishPICState *s)
|
static void goldfish_pic_update(GoldfishPICState *s)
|
||||||
|
@ -28,7 +28,6 @@
|
|||||||
#include "hw/isa/i8259_internal.h"
|
#include "hw/isa/i8259_internal.h"
|
||||||
#include "hw/qdev-properties.h"
|
#include "hw/qdev-properties.h"
|
||||||
#include "migration/vmstate.h"
|
#include "migration/vmstate.h"
|
||||||
#include "monitor/monitor.h"
|
|
||||||
#include "qapi/error.h"
|
#include "qapi/error.h"
|
||||||
|
|
||||||
static int irq_level[16];
|
static int irq_level[16];
|
||||||
@ -132,16 +131,17 @@ static bool pic_get_statistics(InterruptStatsProvider *obj,
|
|||||||
return true;
|
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);
|
PICCommonState *s = PIC_COMMON(obj);
|
||||||
|
|
||||||
pic_dispatch_pre_save(s);
|
pic_dispatch_pre_save(s);
|
||||||
monitor_printf(mon, "pic%d: irr=%02x imr=%02x isr=%02x hprio=%d "
|
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",
|
"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->master ? 0 : 1, s->irr, s->imr, s->isr,
|
||||||
s->irq_base, s->read_reg_select, s->elcr,
|
s->priority_add,
|
||||||
s->special_fully_nested_mode);
|
s->irq_base, s->read_reg_select, s->elcr,
|
||||||
|
s->special_fully_nested_mode);
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool ltim_state_needed(void *opaque)
|
static bool ltim_state_needed(void *opaque)
|
||||||
|
@ -23,7 +23,6 @@
|
|||||||
#include "qapi/error.h"
|
#include "qapi/error.h"
|
||||||
#include "qemu/module.h"
|
#include "qemu/module.h"
|
||||||
#include "migration/vmstate.h"
|
#include "migration/vmstate.h"
|
||||||
#include "monitor/monitor.h"
|
|
||||||
#include "hw/intc/intc.h"
|
#include "hw/intc/intc.h"
|
||||||
#include "hw/intc/ioapic.h"
|
#include "hw/intc/ioapic.h"
|
||||||
#include "hw/intc/ioapic_internal.h"
|
#include "hw/intc/ioapic_internal.h"
|
||||||
@ -59,59 +58,62 @@ static bool ioapic_get_statistics(InterruptStatsProvider *obj,
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void ioapic_irr_dump(Monitor *mon, const char *name, uint32_t bitmap)
|
static void ioapic_irr_dump(GString *buf, const char *name, uint32_t bitmap)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
monitor_printf(mon, "%-10s ", name);
|
g_string_append_printf(buf, "%-10s ", name);
|
||||||
if (bitmap == 0) {
|
if (bitmap == 0) {
|
||||||
monitor_printf(mon, "(none)\n");
|
g_string_append_printf(buf, "(none)\n");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
for (i = 0; i < IOAPIC_NUM_PINS; i++) {
|
for (i = 0; i < IOAPIC_NUM_PINS; i++) {
|
||||||
if (bitmap & (1 << i)) {
|
if (bitmap & (1 << i)) {
|
||||||
monitor_printf(mon, "%-2u ", i);
|
g_string_append_printf(buf, "%-2u ", i);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
monitor_printf(mon, "\n");
|
g_string_append_c(buf, '\n');
|
||||||
}
|
}
|
||||||
|
|
||||||
static void ioapic_print_redtbl(Monitor *mon, IOAPICCommonState *s)
|
static void ioapic_print_redtbl(GString *buf, IOAPICCommonState *s)
|
||||||
{
|
{
|
||||||
static const char *delm_str[] = {
|
static const char *delm_str[] = {
|
||||||
"fixed", "lowest", "SMI", "...", "NMI", "INIT", "...", "extINT"};
|
"fixed", "lowest", "SMI", "...", "NMI", "INIT", "...", "extINT"};
|
||||||
uint32_t remote_irr = 0;
|
uint32_t remote_irr = 0;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
monitor_printf(mon, "ioapic0: ver=0x%x id=0x%02x sel=0x%02x",
|
g_string_append_printf(buf, "ioapic0: ver=0x%x id=0x%02x sel=0x%02x",
|
||||||
s->version, s->id, s->ioregsel);
|
s->version, s->id, s->ioregsel);
|
||||||
if (s->ioregsel) {
|
if (s->ioregsel) {
|
||||||
monitor_printf(mon, " (redir[%u])\n",
|
g_string_append_printf(buf, " (redir[%u])\n",
|
||||||
(s->ioregsel - IOAPIC_REG_REDTBL_BASE) >> 1);
|
(s->ioregsel - IOAPIC_REG_REDTBL_BASE) >> 1);
|
||||||
} else {
|
} else {
|
||||||
monitor_printf(mon, "\n");
|
g_string_append_c(buf, '\n');
|
||||||
}
|
}
|
||||||
for (i = 0; i < IOAPIC_NUM_PINS; i++) {
|
for (i = 0; i < IOAPIC_NUM_PINS; i++) {
|
||||||
uint64_t entry = s->ioredtbl[i];
|
uint64_t entry = s->ioredtbl[i];
|
||||||
uint32_t delm = (uint32_t)((entry & IOAPIC_LVT_DELIV_MODE) >>
|
uint32_t delm = (uint32_t)((entry & IOAPIC_LVT_DELIV_MODE) >>
|
||||||
IOAPIC_LVT_DELIV_MODE_SHIFT);
|
IOAPIC_LVT_DELIV_MODE_SHIFT);
|
||||||
monitor_printf(mon, " pin %-2u 0x%016"PRIx64" dest=%"PRIx64
|
g_string_append_printf(buf, " pin %-2u 0x%016"PRIx64" dest=%"PRIx64
|
||||||
" vec=%-3"PRIu64" %s %-5s %-6s %-6s %s\n",
|
" vec=%-3"PRIu64" %s %-5s %-6s %-6s %s\n",
|
||||||
i, entry,
|
i, entry,
|
||||||
(entry >> IOAPIC_LVT_DEST_SHIFT) &
|
(entry >> IOAPIC_LVT_DEST_SHIFT) &
|
||||||
(entry & IOAPIC_LVT_DEST_MODE ? 0xff : 0xf),
|
(entry & IOAPIC_LVT_DEST_MODE ? 0xff : 0xf),
|
||||||
entry & IOAPIC_VECTOR_MASK,
|
entry & IOAPIC_VECTOR_MASK,
|
||||||
entry & IOAPIC_LVT_POLARITY ? "active-lo" : "active-hi",
|
entry & IOAPIC_LVT_POLARITY
|
||||||
entry & IOAPIC_LVT_TRIGGER_MODE ? "level" : "edge",
|
? "active-lo" : "active-hi",
|
||||||
entry & IOAPIC_LVT_MASKED ? "masked" : "",
|
entry & IOAPIC_LVT_TRIGGER_MODE
|
||||||
delm_str[delm],
|
? "level" : "edge",
|
||||||
entry & IOAPIC_LVT_DEST_MODE ? "logical" : "physical");
|
entry & IOAPIC_LVT_MASKED ? "masked" : "",
|
||||||
|
delm_str[delm],
|
||||||
|
entry & IOAPIC_LVT_DEST_MODE
|
||||||
|
? "logical" : "physical");
|
||||||
|
|
||||||
remote_irr |= entry & IOAPIC_LVT_TRIGGER_MODE ?
|
remote_irr |= entry & IOAPIC_LVT_TRIGGER_MODE ?
|
||||||
(entry & IOAPIC_LVT_REMOTE_IRR ? (1 << i) : 0) : 0;
|
(entry & IOAPIC_LVT_REMOTE_IRR ? (1 << i) : 0) : 0;
|
||||||
}
|
}
|
||||||
ioapic_irr_dump(mon, " IRR", s->irr);
|
ioapic_irr_dump(buf, " IRR", s->irr);
|
||||||
ioapic_irr_dump(mon, " Remote IRR", remote_irr);
|
ioapic_irr_dump(buf, " Remote IRR", remote_irr);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ioapic_reset_common(DeviceState *dev)
|
void ioapic_reset_common(DeviceState *dev)
|
||||||
@ -171,13 +173,12 @@ static void ioapic_common_realize(DeviceState *dev, Error **errp)
|
|||||||
ioapic_no++;
|
ioapic_no++;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void ioapic_print_info(InterruptStatsProvider *obj,
|
static void ioapic_print_info(InterruptStatsProvider *obj, GString *buf)
|
||||||
Monitor *mon)
|
|
||||||
{
|
{
|
||||||
IOAPICCommonState *s = IOAPIC_COMMON(obj);
|
IOAPICCommonState *s = IOAPIC_COMMON(obj);
|
||||||
|
|
||||||
ioapic_dispatch_pre_save(s);
|
ioapic_dispatch_pre_save(s);
|
||||||
ioapic_print_redtbl(mon, s);
|
ioapic_print_redtbl(buf, s);
|
||||||
}
|
}
|
||||||
|
|
||||||
static const VMStateDescription vmstate_ioapic_common = {
|
static const VMStateDescription vmstate_ioapic_common = {
|
||||||
|
@ -10,7 +10,6 @@
|
|||||||
#include "qemu/osdep.h"
|
#include "qemu/osdep.h"
|
||||||
#include "cpu.h"
|
#include "cpu.h"
|
||||||
#include "migration/vmstate.h"
|
#include "migration/vmstate.h"
|
||||||
#include "monitor/monitor.h"
|
|
||||||
#include "hw/qdev-properties.h"
|
#include "hw/qdev-properties.h"
|
||||||
#include "hw/nmi.h"
|
#include "hw/nmi.h"
|
||||||
#include "hw/intc/intc.h"
|
#include "hw/intc/intc.h"
|
||||||
@ -27,10 +26,10 @@ static bool m68k_irqc_get_statistics(InterruptStatsProvider *obj,
|
|||||||
return true;
|
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);
|
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)
|
static void m68k_set_irq(void *opaque, int irq, int level)
|
||||||
|
@ -24,7 +24,6 @@
|
|||||||
|
|
||||||
#include "qemu/osdep.h"
|
#include "qemu/osdep.h"
|
||||||
#include "migration/vmstate.h"
|
#include "migration/vmstate.h"
|
||||||
#include "monitor/monitor.h"
|
|
||||||
#include "qemu/module.h"
|
#include "qemu/module.h"
|
||||||
#include "hw/sysbus.h"
|
#include "hw/sysbus.h"
|
||||||
#include "hw/intc/intc.h"
|
#include "hw/intc/intc.h"
|
||||||
@ -401,17 +400,17 @@ static bool slavio_intctl_get_statistics(InterruptStatsProvider *obj,
|
|||||||
}
|
}
|
||||||
#endif
|
#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);
|
SLAVIO_INTCTLState *s = SLAVIO_INTCTL(obj);
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
for (i = 0; i < MAX_CPUS; i++) {
|
for (i = 0; i < MAX_CPUS; i++) {
|
||||||
monitor_printf(mon, "per-cpu %d: pending 0x%08x\n", i,
|
g_string_append_printf(buf, "per-cpu %d: pending 0x%08x\n", i,
|
||||||
s->slaves[i].intreg_pending);
|
s->slaves[i].intreg_pending);
|
||||||
}
|
}
|
||||||
monitor_printf(mon, "master: pending 0x%08x, disabled 0x%08x\n",
|
g_string_append_printf(buf, "master: pending 0x%08x, disabled 0x%08x\n",
|
||||||
s->intregm_pending, s->intregm_disabled);
|
s->intregm_pending, s->intregm_disabled);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void slavio_intctl_init(Object *obj)
|
static void slavio_intctl_init(Object *obj)
|
||||||
|
10
hw/ppc/pnv.c
10
hw/ppc/pnv.c
@ -38,8 +38,6 @@
|
|||||||
#include "hw/loader.h"
|
#include "hw/loader.h"
|
||||||
#include "hw/nmi.h"
|
#include "hw/nmi.h"
|
||||||
#include "qapi/visitor.h"
|
#include "qapi/visitor.h"
|
||||||
#include "qapi/type-helpers.h"
|
|
||||||
#include "monitor/monitor.h"
|
|
||||||
#include "hw/intc/intc.h"
|
#include "hw/intc/intc.h"
|
||||||
#include "hw/ipmi/ipmi.h"
|
#include "hw/ipmi/ipmi.h"
|
||||||
#include "target/ppc/mmu-hash64.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;
|
return cpu ? ICP(pnv_cpu_state(cpu)->intc) : NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void pnv_pic_print_info(InterruptStatsProvider *obj,
|
static void pnv_pic_print_info(InterruptStatsProvider *obj, GString *buf)
|
||||||
Monitor *mon)
|
|
||||||
{
|
{
|
||||||
PnvMachineState *pnv = PNV_MACHINE(obj);
|
PnvMachineState *pnv = PNV_MACHINE(obj);
|
||||||
int i;
|
int i;
|
||||||
CPUState *cs;
|
CPUState *cs;
|
||||||
g_autoptr(GString) buf = g_string_new("");
|
|
||||||
g_autoptr(HumanReadableText) info = NULL;
|
|
||||||
|
|
||||||
CPU_FOREACH(cs) {
|
CPU_FOREACH(cs) {
|
||||||
PowerPCCPU *cpu = POWERPC_CPU(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++) {
|
for (i = 0; i < pnv->num_chips; i++) {
|
||||||
PNV_CHIP_GET_CLASS(pnv->chips[i])->pic_print_info(pnv->chips[i], buf);
|
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,
|
static int pnv_match_nvt(XiveFabric *xfb, uint8_t format,
|
||||||
|
@ -31,7 +31,6 @@
|
|||||||
#include "qapi/error.h"
|
#include "qapi/error.h"
|
||||||
#include "qapi/qapi-events-machine.h"
|
#include "qapi/qapi-events-machine.h"
|
||||||
#include "qapi/qapi-events-qdev.h"
|
#include "qapi/qapi-events-qdev.h"
|
||||||
#include "qapi/type-helpers.h"
|
|
||||||
#include "qapi/visitor.h"
|
#include "qapi/visitor.h"
|
||||||
#include "sysemu/sysemu.h"
|
#include "sysemu/sysemu.h"
|
||||||
#include "sysemu/hostmem.h"
|
#include "sysemu/hostmem.h"
|
||||||
@ -90,8 +89,6 @@
|
|||||||
#include "hw/ppc/spapr_nvdimm.h"
|
#include "hw/ppc/spapr_nvdimm.h"
|
||||||
#include "hw/ppc/spapr_numa.h"
|
#include "hw/ppc/spapr_numa.h"
|
||||||
|
|
||||||
#include "monitor/monitor.h"
|
|
||||||
|
|
||||||
#include <libfdt.h>
|
#include <libfdt.h>
|
||||||
|
|
||||||
/* SLOF memory layout:
|
/* 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;
|
return cpu ? spapr_cpu_state(cpu)->icp : NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void spapr_pic_print_info(InterruptStatsProvider *obj,
|
static void spapr_pic_print_info(InterruptStatsProvider *obj, GString *buf)
|
||||||
Monitor *mon)
|
|
||||||
{
|
{
|
||||||
SpaprMachineState *spapr = SPAPR_MACHINE(obj);
|
SpaprMachineState *spapr = SPAPR_MACHINE(obj);
|
||||||
g_autoptr(GString) buf = g_string_new("");
|
|
||||||
g_autoptr(HumanReadableText) info = NULL;
|
|
||||||
|
|
||||||
spapr_irq_print_info(spapr, buf);
|
spapr_irq_print_info(spapr, buf);
|
||||||
g_string_append_printf(buf, "irqchip: %s\n",
|
g_string_append_printf(buf, "irqchip: %s\n",
|
||||||
kvm_irqchip_in_kernel() ? "in-kernel" : "emulated");
|
kvm_irqchip_in_kernel() ? "in-kernel" : "emulated");
|
||||||
info = human_readable_text_from_str(buf);
|
|
||||||
monitor_puts(mon, info->human_readable_text);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -22,7 +22,7 @@ struct InterruptStatsProviderClass {
|
|||||||
*/
|
*/
|
||||||
bool (*get_statistics)(InterruptStatsProvider *obj, uint64_t **irq_counts,
|
bool (*get_statistics)(InterruptStatsProvider *obj, uint64_t **irq_counts,
|
||||||
unsigned int *nb_irqs);
|
unsigned int *nb_irqs);
|
||||||
void (*print_info)(InterruptStatsProvider *obj, Monitor *mon);
|
void (*print_info)(InterruptStatsProvider *obj, GString *buf);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -25,6 +25,7 @@
|
|||||||
#include "qapi/qapi-commands-machine.h"
|
#include "qapi/qapi-commands-machine.h"
|
||||||
#include "qapi/qapi-commands-misc.h"
|
#include "qapi/qapi-commands-misc.h"
|
||||||
#include "qapi/qmp/qdict.h"
|
#include "qapi/qmp/qdict.h"
|
||||||
|
#include "qapi/type-helpers.h"
|
||||||
#include "qemu/cutils.h"
|
#include "qemu/cutils.h"
|
||||||
#include "hw/intc/intc.h"
|
#include "hw/intc/intc.h"
|
||||||
#include "qemu/log.h"
|
#include "qemu/log.h"
|
||||||
@ -92,7 +93,12 @@ static int hmp_info_pic_foreach(Object *obj, void *opaque)
|
|||||||
intc = INTERRUPT_STATS_PROVIDER(obj);
|
intc = INTERRUPT_STATS_PROVIDER(obj);
|
||||||
k = INTERRUPT_STATS_PROVIDER_GET_CLASS(obj);
|
k = INTERRUPT_STATS_PROVIDER_GET_CLASS(obj);
|
||||||
if (k->print_info) {
|
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 {
|
} else {
|
||||||
monitor_printf(mon, "Interrupt controller information not available for %s.\n",
|
monitor_printf(mon, "Interrupt controller information not available for %s.\n",
|
||||||
object_get_typename(obj));
|
object_get_typename(obj));
|
||||||
|
Loading…
x
Reference in New Issue
Block a user