diff mbox series

[PULL,24/37] qtest: Add set_irq_in command to set IRQ/GPIO level

Message ID 20190107163117.16269-25-peter.maydell@linaro.org
State Not Applicable
Headers show
Series target-arm queue | expand

Commit Message

Peter Maydell Jan. 7, 2019, 4:31 p.m. UTC
From: Steffen Görtz <contrib@steffen-goertz.de>


Adds a new qtest command "set_irq_in" which allows
to set qemu gpio lines to a given level.

Based on https://lists.gnu.org/archive/html/qemu-devel/2012-12/msg02363.html
which never got merged.

Signed-off-by: Steffen Görtz <contrib@steffen-goertz.de>

Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>

Reviewed-by: Thomas Huth <thuth@redhat.com>

Reviewed-by: Laurent Vivier <lvivier@redhat.com>

Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>

Message-id: 20190103091119.9367-2-stefanha@redhat.com
Originally-by: Matthew Ogilvie <mmogilvi_qemu@miniinfo.net>
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>

Reviewed-by: Thomas Huth <thuth@redhat.com>

Reviewed-by: Laurent Vivier <lvivier@redhat.com>

Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>

---
 tests/libqtest.h | 13 +++++++++++++
 qtest.c          | 43 +++++++++++++++++++++++++++++++++++++++++++
 tests/libqtest.c | 10 ++++++++++
 3 files changed, 66 insertions(+)

-- 
2.19.2

Comments

Zhijian Li (Fujitsu)" via Jan. 9, 2019, 5:58 a.m. UTC | #1
On Mon, Jan 07, 2019 at 04:31:04PM +0000, Peter Maydell wrote:
> From: Steffen Görtz <contrib@steffen-goertz.de>

> 

> Adds a new qtest command "set_irq_in" which allows

> to set qemu gpio lines to a given level.

> 

> Based on https://lists.gnu.org/archive/html/qemu-devel/2012-12/msg02363.html

> which never got merged.

> 

> Signed-off-by: Steffen Görtz <contrib@steffen-goertz.de>

> Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>

> Reviewed-by: Thomas Huth <thuth@redhat.com>

> Reviewed-by: Laurent Vivier <lvivier@redhat.com>

> Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>

> Message-id: 20190103091119.9367-2-stefanha@redhat.com

> Originally-by: Matthew Ogilvie <mmogilvi_qemu@miniinfo.net>


It is kind of interesting to see a part of my old thread(s)
resurrected, even if it isn't the part I was actually interested
in.

Note that my miniinfo email account no longer exists, but I
can still be reached at mmogilvi+qemu@zoho.com if desired.

Regarding the patch, I haven't kept up with changes to qemu
well enough to really have a useful opinion, although superficially
it looks good.  Perhaps it would make sense to include both
my old and new email addresses in the sign-off section, to both
tie it to the old threads and make it easier to reach me
if someone wants to contact me?  (But I'm not sure of a "clean"
way to do so, and it is probably low priority.  Perhaps this
current email is good enough?)

                - Matthew Ogilvie

P.S.: Explanation and keywords to find this message (and me) with
search tools:

With regards to qemu, my primary interest (from that thread and
related 2012 threads) is/was being able to run
"Microport UNIX System V/386 v2.1" (ca. 1987) under qemu, which
especially required:
   - Fixing various inaccuracies in qemu's model of the i8259
     interrupt controller.
   - Implementing very old graphics card model(s) that Microport UNIX
     actually knows how to control properly.  Perhaps original
     IBM monochrome display adaptor (MDA), CGA, and/or hercules
     graphics card.  Or else my nasty qemu hackish patches I wrote
     that allowed VGA to work in text mode despite Microport driving
     it like CGA in a way that didn't work with real VGA hardware.
Peter Maydell Jan. 10, 2019, 3:53 p.m. UTC | #2
On Wed, 9 Jan 2019 at 05:59, Matthew Ogilvie <mmogilvi+qemu@zoho.com> wrote:
>

> On Mon, Jan 07, 2019 at 04:31:04PM +0000, Peter Maydell wrote:

> > From: Steffen Görtz <contrib@steffen-goertz.de>

> >

> > Adds a new qtest command "set_irq_in" which allows

> > to set qemu gpio lines to a given level.

> >

> > Based on https://lists.gnu.org/archive/html/qemu-devel/2012-12/msg02363.html

> > which never got merged.

> >

> > Signed-off-by: Steffen Görtz <contrib@steffen-goertz.de>

> > Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>

> > Reviewed-by: Thomas Huth <thuth@redhat.com>

> > Reviewed-by: Laurent Vivier <lvivier@redhat.com>

> > Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>

> > Message-id: 20190103091119.9367-2-stefanha@redhat.com

> > Originally-by: Matthew Ogilvie <mmogilvi_qemu@miniinfo.net>

>

> It is kind of interesting to see a part of my old thread(s)

> resurrected, even if it isn't the part I was actually interested

> in.

>

> Note that my miniinfo email account no longer exists, but I

> can still be reached at mmogilvi+qemu@zoho.com if desired.

>

> Regarding the patch, I haven't kept up with changes to qemu

> well enough to really have a useful opinion, although superficially

> it looks good.  Perhaps it would make sense to include both

> my old and new email addresses in the sign-off section, to both

> tie it to the old threads and make it easier to reach me

> if someone wants to contact me?  (But I'm not sure of a "clean"

> way to do so, and it is probably low priority.  Perhaps this

> current email is good enough?)


Thanks for the followup. Unfortunately the commit is already
in master so we can't tweak the commit message at this point.
That shouldn't matter much, people don't often fish emails out
of old commit message logs to email anyway :-)

thanks
-- PMM
Eric Blake Jan. 10, 2019, 4:26 p.m. UTC | #3
On 1/10/19 9:53 AM, Peter Maydell wrote:

>> Note that my miniinfo email account no longer exists, but I

>> can still be reached at mmogilvi+qemu@zoho.com if desired.

>>

>> Regarding the patch, I haven't kept up with changes to qemu

>> well enough to really have a useful opinion, although superficially

>> it looks good.  Perhaps it would make sense to include both

>> my old and new email addresses in the sign-off section, to both

>> tie it to the old threads and make it easier to reach me

>> if someone wants to contact me?  (But I'm not sure of a "clean"

>> way to do so, and it is probably low priority.  Perhaps this

>> current email is good enough?)

> 

> Thanks for the followup. Unfortunately the commit is already

> in master so we can't tweak the commit message at this point.

> That shouldn't matter much, people don't often fish emails out

> of old commit message logs to email anyway :-)


We can't change the commit message body, but if you are worried about
people still being able to reach you based about a patch they found
while browsing git history, we DO have .mailmap where you can list a new
preferred email address to use in place of any commits you made under an
old address.  Patching .mailmap is a nice (but optional) way to let
people know how to reach you, if you still expect to be reached.

-- 
Eric Blake, Principal Software Engineer
Red Hat, Inc.           +1-919-301-3226
Virtualization:  qemu.org | libvirt.org
diff mbox series

Patch

diff --git a/tests/libqtest.h b/tests/libqtest.h
index 9758c51be61..7ea94139b0c 100644
--- a/tests/libqtest.h
+++ b/tests/libqtest.h
@@ -230,6 +230,19 @@  void qtest_irq_intercept_in(QTestState *s, const char *string);
  */
 void qtest_irq_intercept_out(QTestState *s, const char *string);
 
+/**
+ * qtest_set_irq_in:
+ * @s: QTestState instance to operate on.
+ * @string: QOM path of a device
+ * @name: IRQ name
+ * @irq: IRQ number
+ * @level: IRQ level
+ *
+ * Force given device/irq GPIO-in pin to the given level.
+ */
+void qtest_set_irq_in(QTestState *s, const char *string, const char *name,
+                      int irq, int level);
+
 /**
  * qtest_outb:
  * @s: #QTestState instance to operate on.
diff --git a/qtest.c b/qtest.c
index 69b9e9962b5..451696b5dae 100644
--- a/qtest.c
+++ b/qtest.c
@@ -164,6 +164,17 @@  static bool qtest_opened;
  * where NUM is an IRQ number.  For the PC, interrupts can be intercepted
  * simply with "irq_intercept_in ioapic" (note that IRQ0 comes out with
  * NUM=0 even though it is remapped to GSI 2).
+ *
+ * Setting interrupt level:
+ *
+ *  > set_irq_in QOM-PATH NAME NUM LEVEL
+ *  < OK
+ *
+ *  where NAME is the name of the irq/gpio list, NUM is an IRQ number and
+ *  LEVEL is an signed integer IRQ level.
+ *
+ * Forcibly set the given interrupt pin to the given level.
+ *
  */
 
 static int hex2nib(char ch)
@@ -326,7 +337,39 @@  static void qtest_process_command(CharBackend *chr, gchar **words)
         irq_intercept_dev = dev;
         qtest_send_prefix(chr);
         qtest_send(chr, "OK\n");
+    } else if (strcmp(words[0], "set_irq_in") == 0) {
+        DeviceState *dev;
+        qemu_irq irq;
+        char *name;
+        int ret;
+        int num;
+        int level;
 
+        g_assert(words[1] && words[2] && words[3] && words[4]);
+
+        dev = DEVICE(object_resolve_path(words[1], NULL));
+        if (!dev) {
+            qtest_send_prefix(chr);
+            qtest_send(chr, "FAIL Unknown device\n");
+            return;
+        }
+
+        if (strcmp(words[2], "unnamed-gpio-in") == 0) {
+            name = NULL;
+        } else {
+            name = words[2];
+        }
+
+        ret = qemu_strtoi(words[3], NULL, 0, &num);
+        g_assert(!ret);
+        ret = qemu_strtoi(words[4], NULL, 0, &level);
+        g_assert(!ret);
+
+        irq = qdev_get_gpio_in_named(dev, name, num);
+
+        qemu_set_irq(irq, level);
+        qtest_send_prefix(chr);
+        qtest_send(chr, "OK\n");
     } else if (strcmp(words[0], "outb") == 0 ||
                strcmp(words[0], "outw") == 0 ||
                strcmp(words[0], "outl") == 0) {
diff --git a/tests/libqtest.c b/tests/libqtest.c
index 1d75d3c9363..55750dd68de 100644
--- a/tests/libqtest.c
+++ b/tests/libqtest.c
@@ -753,6 +753,16 @@  void qtest_irq_intercept_in(QTestState *s, const char *qom_path)
     qtest_rsp(s, 0);
 }
 
+void qtest_set_irq_in(QTestState *s, const char *qom_path, const char *name,
+                      int num, int level)
+{
+    if (!name) {
+        name = "unnamed-gpio-in";
+    }
+    qtest_sendf(s, "set_irq_in %s %s %d %d\n", qom_path, name, num, level);
+    qtest_rsp(s, 0);
+}
+
 static void qtest_out(QTestState *s, const char *cmd, uint16_t addr, uint32_t value)
 {
     qtest_sendf(s, "%s 0x%x 0x%x\n", cmd, addr, value);