From patchwork Mon Jun 10 06:35:16 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 803001 Delivered-To: patch@linaro.org Received: by 2002:adf:f147:0:b0:35b:5a80:51b4 with SMTP id y7csp1802672wro; Sun, 9 Jun 2024 23:36:21 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCWmvoiywhBsbKGGlrPrxeD9zSgezKgGkbpGjSt1QaAOnzBXNqTtQhsrsBgXsL1fwOtNV+x08YNlGhZmSYyFgYEF X-Google-Smtp-Source: AGHT+IEVzpJpYKPGWUkRQJWfr94mezDagNDOb9KQNj6Dk9HbJODnD7a1GZUvlfPlFQdMvzqLY90I X-Received: by 2002:ac8:5996:0:b0:440:f721:2c40 with SMTP id d75a77b69052e-440f7212ffemr21711461cf.37.1718001381162; Sun, 09 Jun 2024 23:36:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1718001381; cv=none; d=google.com; s=arc-20160816; b=CetWwZJikXekDwzxyQJTJXHyjM0S4SIBA54UEQ7YTm9aSIZ22qy1MbfUZHtfgaIJFE jloTcehZZwTWzsUXg+AYEtZa4o/qoPZPhuQVi3WsCkVigXwogfKKeBAlYKvOkLdkO4yU cdw6M6ZvdzDVjqhu5P8XMQbfHiDnIxSZXI+sydx75uIUFZX7z80vYChEmiqMNOYU5VMg wnOop8GszhoxTvGaiDULT60Rv6mOgMzeFhgAMlfeETNvBqjlW7KucXB2SejInqDy0rTm QISqFIZdGWI92i7vp2xkLt91DFd7VdtWh1Ul9fvL2EYgVCAGRwmCoJifEhxX3zzz7pi6 hMiQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=WSHT2oKRIgkAwXEwFKRYVcc2pOp65D9y1DNTV96pudc=; fh=RzDfCbLI6MPAtLMPqlQnErdUHwLOMip/ff3zpjxflbg=; b=G0mTMokzP1Jau16LnR8tQmnHaf5r1Yc2fJ9SIGGyTJrxi/bwvTR582Rp2FwSIXp1oI Ed34cGhaof38gyDYQGchnhl6xIThaddLqoUeLfq1jMkxLnbml4nju+1sVaxJKWSVHeP6 8eDRj402CPaSU5dSsWYwwenY/a3Rgk3cxFjDjdt4aP6fornNvI4bsZKe79NyCbJSliHi AWeg38ekciLLdy5dlCfB9Rx67ADnNNMR7y6wUUrOe41lxfHiYbyyU6k04JrDPh92z95Z Uajy4gMztiFbfWoX3GtP43ImB/pBRU/WLIVHctw/C0IxrrMEdACa8V19eWy+S7LkygQD BKHA==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=XMaFveqG; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id d75a77b69052e-4406034c4f9si36994331cf.795.2024.06.09.23.36.20 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Sun, 09 Jun 2024 23:36:21 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=XMaFveqG; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sGYcv-0006Iv-A3; Mon, 10 Jun 2024 02:35:33 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sGYcu-0006IQ-0u for qemu-devel@nongnu.org; Mon, 10 Jun 2024 02:35:32 -0400 Received: from mail-wr1-x433.google.com ([2a00:1450:4864:20::433]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sGYcr-0007M6-QQ for qemu-devel@nongnu.org; Mon, 10 Jun 2024 02:35:31 -0400 Received: by mail-wr1-x433.google.com with SMTP id ffacd0b85a97d-35f0aeff7a8so1841512f8f.2 for ; Sun, 09 Jun 2024 23:35:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1718001328; x=1718606128; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=WSHT2oKRIgkAwXEwFKRYVcc2pOp65D9y1DNTV96pudc=; b=XMaFveqGeqXetDVew2/wuO98R6Qs7SeRkoFK1QdgG37iWLJMqSFRSCP9zk5eRkfkAP 9aJ103ti31xu26nZgCM1vptZq/FxR3LUV6XDy6cj7VqDPZBemosOOZa5Ps2mrtgeZs3m q+3LX2joXpCIl6+shyWCuMsygwtl6Dg+8na+orPIDfSI9sE8y5AOcJN4mgxlYJs9F4Eq x+V3tCyFVSC3hGJ54T6zc+fjU3mBqeIgWXgW2/5kMK4ysCyzH2f+ZbaOx1Wjiq+M6Hk6 pIyotZQVEsslaIC6Av+LsSHioxmi3EmJ3SHPbFVZUbf08jyUqnU0Xbu1Sfqhe6nGWLse VNvA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1718001328; x=1718606128; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=WSHT2oKRIgkAwXEwFKRYVcc2pOp65D9y1DNTV96pudc=; b=SUBclX/hwKYomsMUE1FEFaJ0tS+Go9wjAy9CGCPDKI8+O01iH+gbjsc+MOZBPFRwFO JD7ElQFmT+2cYfSta6go20VirW28boRv7FPlTxytkUbhEBAyAbY38cInqKocBaZxBlDI BwpePzmk+aTZStwZuTzN/uuoYK8QqMY/8SIM/3rhHOjsB6KybYNEf8A4nsMbqJPuvXmO yGOMt6sMxehT8ImjU1iKRhXfo4IV+8ZdaSoII/U2z7KIYn86d6YucuVhGuazf3pWulc5 DkgN0tn3wxwlRs7CX2YWIdhvWQutzKm7mDiF5LPBCEfLJGGu7GIXdyqN68XLHUgySDQ8 ByDg== X-Gm-Message-State: AOJu0YxYxFPrztYmWc9LCy2JTjmaJ0tNwFlYxg0pr/AYDjheL4ABWz9c MDX2mh3tG431J4um/RNHJ2j7h1wUWT5hxLSIE1rzm11rsxt8IsTGhg9k4e+1K0b/Pux1rK3Gzyj t X-Received: by 2002:a05:6000:4008:b0:354:f7b9:75bd with SMTP id ffacd0b85a97d-35efedca5c0mr7717266f8f.47.1718001327916; Sun, 09 Jun 2024 23:35:27 -0700 (PDT) Received: from m1x-phil.lan ([176.176.129.242]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-35f1dc8e2a2sm3708153f8f.106.2024.06.09.23.35.25 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Sun, 09 Jun 2024 23:35:27 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: "Michael S. Tsirkin" , "Dr. David Alan Gilbert" , =?utf-8?q?Philippe_Mathieu-Dau?= =?utf-8?q?d=C3=A9?= , Mark Cave-Ayland , Harsh Prateek Bora , Eduardo Habkost , Marcel Apfelbaum , Paolo Bonzini , Laurent Vivier , David Gibson , =?utf-8?q?Daniel_P_=2E_Berrang?= =?utf-8?q?=C3=A9?= , Daniel Henrique Barboza , Eric Blake , Yanan Wang , =?utf-8?q?C=C3=A9dric_Le_Goater?= , Nicholas Piggin , Don Porter , =?utf-8?b?RnLDqWTDqXJpYyBCYXJyYXQ=?= , qemu-ppc@nongnu.org, Markus Armbruster Subject: [PATCH 1/2] hw/intc: Avoid using Monitor in INTERRUPT_STATS_PROVIDER::print_info() Date: Mon, 10 Jun 2024 08:35:16 +0200 Message-ID: <20240610063518.50680-2-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240610063518.50680-1-philmd@linaro.org> References: <20240610063518.50680-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::433; envelope-from=philmd@linaro.org; helo=mail-wr1-x433.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org 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é Reviewed-by: Daniel P. Berrangé --- 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(-) diff --git a/include/hw/intc/intc.h b/include/hw/intc/intc.h index 7018f608ca..e40194b8e3 100644 --- a/include/hw/intc/intc.h +++ b/include/hw/intc/intc.h @@ -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 diff --git a/hw/intc/goldfish_pic.c b/hw/intc/goldfish_pic.c index d662dfeb99..6cc1c69d26 100644 --- a/hw/intc/goldfish_pic.c +++ b/hw/intc/goldfish_pic.c @@ -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) diff --git a/hw/intc/i8259_common.c b/hw/intc/i8259_common.c index ee0041115c..d9558e3940 100644 --- a/hw/intc/i8259_common.c +++ b/hw/intc/i8259_common.c @@ -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) diff --git a/hw/intc/ioapic_common.c b/hw/intc/ioapic_common.c index efbe6958c8..769896353a 100644 --- a/hw/intc/ioapic_common.c +++ b/hw/intc/ioapic_common.c @@ -23,7 +23,6 @@ #include "qapi/error.h" #include "qemu/module.h" #include "migration/vmstate.h" -#include "monitor/monitor.h" #include "hw/intc/intc.h" #include "hw/intc/ioapic.h" #include "hw/intc/ioapic_internal.h" @@ -59,59 +58,62 @@ static bool ioapic_get_statistics(InterruptStatsProvider *obj, 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; - monitor_printf(mon, "%-10s ", name); + g_string_append_printf(buf, "%-10s ", name); if (bitmap == 0) { - monitor_printf(mon, "(none)\n"); + g_string_append_printf(buf, "(none)\n"); return; } for (i = 0; i < IOAPIC_NUM_PINS; 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[] = { "fixed", "lowest", "SMI", "...", "NMI", "INIT", "...", "extINT"}; uint32_t remote_irr = 0; int i; - monitor_printf(mon, "ioapic0: ver=0x%x id=0x%02x sel=0x%02x", - s->version, s->id, s->ioregsel); + g_string_append_printf(buf, "ioapic0: ver=0x%x id=0x%02x sel=0x%02x", + s->version, s->id, s->ioregsel); if (s->ioregsel) { - monitor_printf(mon, " (redir[%u])\n", - (s->ioregsel - IOAPIC_REG_REDTBL_BASE) >> 1); + g_string_append_printf(buf, " (redir[%u])\n", + (s->ioregsel - IOAPIC_REG_REDTBL_BASE) >> 1); } else { - monitor_printf(mon, "\n"); + g_string_append_c(buf, '\n'); } for (i = 0; i < IOAPIC_NUM_PINS; i++) { uint64_t entry = s->ioredtbl[i]; uint32_t delm = (uint32_t)((entry & IOAPIC_LVT_DELIV_MODE) >> IOAPIC_LVT_DELIV_MODE_SHIFT); - monitor_printf(mon, " pin %-2u 0x%016"PRIx64" dest=%"PRIx64 - " vec=%-3"PRIu64" %s %-5s %-6s %-6s %s\n", - i, entry, - (entry >> IOAPIC_LVT_DEST_SHIFT) & - (entry & IOAPIC_LVT_DEST_MODE ? 0xff : 0xf), - entry & IOAPIC_VECTOR_MASK, - entry & IOAPIC_LVT_POLARITY ? "active-lo" : "active-hi", - entry & IOAPIC_LVT_TRIGGER_MODE ? "level" : "edge", - entry & IOAPIC_LVT_MASKED ? "masked" : "", - delm_str[delm], - entry & IOAPIC_LVT_DEST_MODE ? "logical" : "physical"); + g_string_append_printf(buf, " pin %-2u 0x%016"PRIx64" dest=%"PRIx64 + " vec=%-3"PRIu64" %s %-5s %-6s %-6s %s\n", + i, entry, + (entry >> IOAPIC_LVT_DEST_SHIFT) & + (entry & IOAPIC_LVT_DEST_MODE ? 0xff : 0xf), + entry & IOAPIC_VECTOR_MASK, + entry & IOAPIC_LVT_POLARITY + ? "active-lo" : "active-hi", + entry & IOAPIC_LVT_TRIGGER_MODE + ? "level" : "edge", + entry & IOAPIC_LVT_MASKED ? "masked" : "", + delm_str[delm], + entry & IOAPIC_LVT_DEST_MODE + ? "logical" : "physical"); remote_irr |= entry & IOAPIC_LVT_TRIGGER_MODE ? (entry & IOAPIC_LVT_REMOTE_IRR ? (1 << i) : 0) : 0; } - ioapic_irr_dump(mon, " IRR", s->irr); - ioapic_irr_dump(mon, " Remote IRR", remote_irr); + ioapic_irr_dump(buf, " IRR", s->irr); + ioapic_irr_dump(buf, " Remote IRR", remote_irr); } void ioapic_reset_common(DeviceState *dev) @@ -171,13 +173,12 @@ static void ioapic_common_realize(DeviceState *dev, Error **errp) ioapic_no++; } -static void ioapic_print_info(InterruptStatsProvider *obj, - Monitor *mon) +static void ioapic_print_info(InterruptStatsProvider *obj, GString *buf) { IOAPICCommonState *s = IOAPIC_COMMON(obj); ioapic_dispatch_pre_save(s); - ioapic_print_redtbl(mon, s); + ioapic_print_redtbl(buf, s); } static const VMStateDescription vmstate_ioapic_common = { diff --git a/hw/intc/m68k_irqc.c b/hw/intc/m68k_irqc.c index 4b11fb9f72..cf3beefcfe 100644 --- a/hw/intc/m68k_irqc.c +++ b/hw/intc/m68k_irqc.c @@ -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) diff --git a/hw/intc/slavio_intctl.c b/hw/intc/slavio_intctl.c index 36b4a12f60..d6e49d29aa 100644 --- a/hw/intc/slavio_intctl.c +++ b/hw/intc/slavio_intctl.c @@ -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) diff --git a/hw/ppc/pnv.c b/hw/ppc/pnv.c index df74f032d7..03c595788f 100644 --- a/hw/ppc/pnv.c +++ b/hw/ppc/pnv.c @@ -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, diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c index cd9b811ac6..1f12d6c24b 100644 --- a/hw/ppc/spapr.c +++ b/hw/ppc/spapr.c @@ -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 /* 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); } /* diff --git a/monitor/hmp-cmds.c b/monitor/hmp-cmds.c index ea79148ee8..fbff7fdb57 100644 --- a/monitor/hmp-cmds.c +++ b/monitor/hmp-cmds.c @@ -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)); From patchwork Mon Jun 10 06:35:17 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 803000 Delivered-To: patch@linaro.org Received: by 2002:adf:f147:0:b0:35b:5a80:51b4 with SMTP id y7csp1802673wro; Sun, 9 Jun 2024 23:36:21 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCU2893rZAl4lB6/fs+wTQHwSMz/SOVzJ1VUjeEcm31DczxWQks714Xf3JTxg2Ij2wZMhlsNzDxTy2BbHI8xz4SX X-Google-Smtp-Source: AGHT+IHY8d+GUP9ogby+QcVoWytWO8v06TsWWBDqxu53DR5nZCqmPP8XvfzSIFAaca8gqDgeeVXq X-Received: by 2002:a0c:cdc1:0:b0:6b0:6244:d1db with SMTP id 6a1803df08f44-6b06244d26emr66763496d6.27.1718001381219; Sun, 09 Jun 2024 23:36:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1718001381; cv=none; d=google.com; s=arc-20160816; b=RhPgH498H4oxGu8CcS+kBV3mrNYLQHH6Rto2o/lnw7ryiKz7ljuscBCqaa8LmPwqBG q1onCRQ1eeFUB0F4LzrwtSeQyol2zIHzMzImDN9AmECTR5qRuXGq31MnlnWcRqgwy6eL dVGd4o0wdZim/BZe08Po10hYZSEHquy5EGd/pst9ftfT/dcc4V/ULh1DGuSKi2iiNotG hQpt6KCa9+Smw1GXxf0tBr+wUXbJIFUkNwOU7mTQbqAGAZpfJstAUgTzHf7rgICo2Cua QAMD17lqeoIwdPO52ywIL3stjcregSkdea6wCkrVKh2mgJ+WrcTE9exNXBRI5vAkzI0W Wnag== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=3cLqCWiC1J/ZUjSxyI/3+bTiT19Rcz0X6qNntKz3//M=; fh=RzDfCbLI6MPAtLMPqlQnErdUHwLOMip/ff3zpjxflbg=; b=op0LQmpov3o/iW51sKqGsz8mDtnV/PDwULbC4k+Hjd5FakKFhb8cf4Wxjw9xqQ3yeO sAtD8GD9Ff1ljiZdKpoRgOedrc8FCIFR9FYt/PmoSVkQcsIS1SpsZ9NZOiYBYgxW2wz5 b2SVxYFI31gZerMzDMVvTWik5QrWitpGnra7WkCh/ETbX8M1KxLpk8jcDIJg6CxbM552 sHJoYTZRxFgvhnYCnA+mhr61q4lw5FTYTrfjk0T9uNQEcLgPV/EbpwjHmLhRd7KlqsUd NljHPNMOrQufniBYdY0gCJU4mFfwRV+uusO2supJ/+TV5556/ubMIk/kMThEABCNeJyM elzQ==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=axOykuzG; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id 6a1803df08f44-6b082daeebcsi5974476d6.25.2024.06.09.23.36.21 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Sun, 09 Jun 2024 23:36:21 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=axOykuzG; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sGYd1-0006L7-3X; Mon, 10 Jun 2024 02:35:39 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sGYd0-0006Kc-0v for qemu-devel@nongnu.org; Mon, 10 Jun 2024 02:35:38 -0400 Received: from mail-wm1-x333.google.com ([2a00:1450:4864:20::333]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sGYcy-0007Nu-AT for qemu-devel@nongnu.org; Mon, 10 Jun 2024 02:35:37 -0400 Received: by mail-wm1-x333.google.com with SMTP id 5b1f17b1804b1-42198492353so5002215e9.1 for ; Sun, 09 Jun 2024 23:35:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1718001334; x=1718606134; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=3cLqCWiC1J/ZUjSxyI/3+bTiT19Rcz0X6qNntKz3//M=; b=axOykuzGwvcOsvrU2gkkVYghweAZoFgjy36rfNuLfz52qfdcKTPFmoL2iX0BPaaf2n zYplR3g+66uP8msH162wQj0Hh8FzAfG1rhxH1AuwO3IAu6sK5WGRhR0po90Y5VLv2IEz TRaUrwPBjQopRUCupMjFOZUGkpJnl/rwLN5MC6lS8d5qvGMNg1QWmpkAA+Gm6KY/VIqU UgdZNd8AYZdanT4UCNyZNcUSD+iWHyzPDDV/Xse2m4fwTB1bnDIr/1ALFXY6c2ZbITbT sQqovD2dtfNPVrn12Veoj2sWJwOC1AuGRLQanCwuZ+/jT80ai9XOefMGaSWBRLG2JOGG serQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1718001334; x=1718606134; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=3cLqCWiC1J/ZUjSxyI/3+bTiT19Rcz0X6qNntKz3//M=; b=pypibmQKvn+mQpkkaIjC0or+I06OPa1ssdeVPPbIowoFmdJswN3Mc2nRACcWPue8i2 gDV2N7cRJzNDIvJS8v1GD2ON1HckGhfq5wgDt5E7T5dtGkSaAVI8M5cqYQz35VBOT1/b QwUoOiMl/Y+FO3l9fxkK+UMHGClnW9LZ0MRxAS+42gl/KlE5Bp2Qoo4MoeDsY5i5Jrm1 T+L4XMur0yCKekWg1Ey8gQ4bV2zI14gWZxOu5jgBDwyrdO9Q1FhnK5QIO6wGmXxCS2AA 0O4po/A+uZLQ2iHnG2SOJZAozlqp+/VgsGsM959QBm8E77f7wHMhyPl4Wl3g5t1T05wl CPtQ== X-Gm-Message-State: AOJu0YxQnKG5x0UzZNXgQCo9UtPm0N1ii55WV9kndFSuQNY9R+zxzm2M QoAjo2ANosHqc9d7KfHKoouNpw2ThdxGnKE1jLH8LelQhdvAd3rWaChZAEFoNIpfXgDkMB6m42i M X-Received: by 2002:a05:600c:3547:b0:421:dd8c:3588 with SMTP id 5b1f17b1804b1-421dd8c3951mr10554165e9.21.1718001334369; Sun, 09 Jun 2024 23:35:34 -0700 (PDT) Received: from m1x-phil.lan ([176.176.129.242]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-35f29116506sm123147f8f.60.2024.06.09.23.35.32 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Sun, 09 Jun 2024 23:35:33 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: "Michael S. Tsirkin" , "Dr. David Alan Gilbert" , =?utf-8?q?Philippe_Mathieu-Dau?= =?utf-8?q?d=C3=A9?= , Mark Cave-Ayland , Harsh Prateek Bora , Eduardo Habkost , Marcel Apfelbaum , Paolo Bonzini , Laurent Vivier , David Gibson , =?utf-8?q?Daniel_P_=2E_Berrang?= =?utf-8?q?=C3=A9?= , Daniel Henrique Barboza , Eric Blake , Yanan Wang , =?utf-8?q?C=C3=A9dric_Le_Goater?= , Nicholas Piggin , Don Porter , =?utf-8?b?RnLDqWTDqXJpYyBCYXJyYXQ=?= , qemu-ppc@nongnu.org, Markus Armbruster Subject: [PATCH 2/2] hw/intc: Introduce x-query-interrupt-controllers QMP command Date: Mon, 10 Jun 2024 08:35:17 +0200 Message-ID: <20240610063518.50680-3-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240610063518.50680-1-philmd@linaro.org> References: <20240610063518.50680-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::333; envelope-from=philmd@linaro.org; helo=mail-wm1-x333.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org 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. Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Daniel P. Berrangé --- 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(-) diff --git a/qapi/machine.json b/qapi/machine.json index 453feb9347..1283d14493 100644 --- a/qapi/machine.json +++ b/qapi/machine.json @@ -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' ]} diff --git a/hw/core/machine-qmp-cmds.c b/hw/core/machine-qmp-cmds.c index 5972100b1f..130217da8f 100644 --- a/hw/core/machine-qmp-cmds.c +++ b/hw/core/machine-qmp-cmds.c @@ -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; diff --git a/monitor/hmp-cmds.c b/monitor/hmp-cmds.c index fbff7fdb57..45ee3a9e1f 100644 --- a/monitor/hmp-cmds.c +++ b/monitor/hmp-cmds.c @@ -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); diff --git a/hmp-commands-info.hx b/hmp-commands-info.hx index 20a9835ea8..cfd4ad5651 100644 --- a/hmp-commands-info.hx +++ b/hmp-commands-info.hx @@ -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