Patchwork [v8,08/10] qtest: fix qemu_irq_intercept_out()

login
register
mail settings
Submitter Matthew Ogilvie
Date Dec. 16, 2012, 11:56 p.m.
Message ID <1355702189-6994-9-git-send-email-mmogilvi_qemu@miniinfo.net>
Download mbox | patch
Permalink /patch/206763/
State New
Headers show

Comments

Matthew Ogilvie - Dec. 16, 2012, 11:56 p.m.
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_qemu@miniinfo.net>
---
 hw/irq.c | 11 ++++++++---
 hw/irq.h |  2 +-
 qtest.c  |  2 +-
 3 files changed, 10 insertions(+), 5 deletions(-)

Patch

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);
         }