On 11/6/26 11:03, Marc-André Lureau wrote:
qemu_irq_intercept_in() saves original IRQ handlers by allocating
new QOM objects, which are never freed. On a PC machine, this leaks
IRQ objects (one per IOAPIC pin) on every qtest run.
Rather than tracking allocations to free later, avoid them: add an
"observer" field to IRQState, called by qemu_set_irq() after the
real handler. Interception sets the observer instead of rewriting
handlers, so there's nothing to save and nothing to leak.
Fix qemu_notirq() to route through qemu_set_irq() so inverted IRQs
trigger observers too. Drop the LSan suppression.
Reviewed-by: Fabiano Rosas <[email protected]>
Signed-off-by: Marc-André Lureau <[email protected]>
---
include/hw/core/irq.h | 6 +++---
hw/core/irq.c | 12 ++++++------
system/qtest.c | 5 +----
scripts/lsan_suppressions.txt | 8 --------
4 files changed, 10 insertions(+), 21 deletions(-)
diff --git a/hw/core/irq.c b/hw/core/irq.c
index 106805e2417..1b610e75e15 100644
--- a/hw/core/irq.c
+++ b/hw/core/irq.c
@@ -32,6 +32,9 @@ void qemu_set_irq(qemu_irq irq, int level)
return;
irq->handler(irq->opaque, irq->n, level);
+ if (unlikely(irq->observer)) {
+ irq->observer(irq->opaque, irq->n, level);
I note there is a behavioral change here: before the observer
was called *before* the normal handler, now it is called *after*.
I suppose there is not impact with current QTest implementation.
Reviewed-by: Philippe Mathieu-Daudé <[email protected]>
+ }
}