For the 8259 (at least), we need to modify the entries in gpio_out (which is pointing at PICCommonState::int_out) in-place rather than change it to point to a totally different table. The 8259 sends its output to int_out even if gpio_out is a different table.
Signed-off-by: Matthew Ogilvie <mmogilvi_q...@miniinfo.net> --- hw/irq.c | 11 ++++++++--- hw/irq.h | 2 +- qtest.c | 2 +- 3 files changed, 10 insertions(+), 5 deletions(-) diff --git a/hw/irq.c b/hw/irq.c index f4e2a78..60fa152 100644 --- a/hw/irq.c +++ b/hw/irq.c @@ -129,8 +129,13 @@ void qemu_irq_intercept_in(qemu_irq *gpio_in, qemu_irq_handler handler, int n) } } -void qemu_irq_intercept_out(qemu_irq **gpio_out, qemu_irq_handler handler, int n) +void qemu_irq_intercept_out(qemu_irq *gpio_out, qemu_irq_handler handler, int n) { - qemu_irq *old_irqs = *gpio_out; - *gpio_out = qemu_allocate_irqs(handler, old_irqs, n); + int i; + qemu_irq *old_irqs = qemu_allocate_irqs(NULL, NULL, n); + for (i = 0; i < n; i++) { + *old_irqs[i] = *gpio_out[i]; + gpio_out[i]->handler = handler; + gpio_out[i]->opaque = old_irqs; + } } diff --git a/hw/irq.h b/hw/irq.h index 610e6b7..8dc26cf 100644 --- a/hw/irq.h +++ b/hw/irq.h @@ -52,6 +52,6 @@ qemu_irq *qemu_irq_proxy(qemu_irq **target, int n); /* For internal use in qtest. Similar to qemu_irq_split, but operating on an existing vector of qemu_irq. */ void qemu_irq_intercept_in(qemu_irq *gpio_in, qemu_irq_handler handler, int n); -void qemu_irq_intercept_out(qemu_irq **gpio_out, qemu_irq_handler handler, int n); +void qemu_irq_intercept_out(qemu_irq *gpio_out, qemu_irq_handler handler, int n); #endif diff --git a/qtest.c b/qtest.c index fbfab4e..6965910 100644 --- a/qtest.c +++ b/qtest.c @@ -232,7 +232,7 @@ static void qtest_process_command(CharDriverState *chr, gchar **words) } if (words[0][14] == 'o') { - qemu_irq_intercept_out(&dev->gpio_out, qtest_irq_handler, dev->num_gpio_out); + qemu_irq_intercept_out(dev->gpio_out, qtest_irq_handler, dev->num_gpio_out); } else { qemu_irq_intercept_in(dev->gpio_in, qtest_irq_handler, dev->num_gpio_in); } -- 1.7.10.2.484.gcd07cc5