Commit e91bdf25f7 for qemu.org

commit e91bdf25f751cc58794a15d69a1981de66d9952e
Author: Peter Maydell <peter.maydell@linaro.org>
Date:   Mon Oct 26 12:56:54 2026 +0000

    system/qtest: Check ngl->name for irq_intercept_in

    Currently we check the name of the NamedGPIOList when doing
    irq_intercept_out, but not for irq_intercept_in.  Even though we
    don't currently support irq_intercept_in on named GPIO lines, we
    still need to check the name, because otherwise we will install the
    observer on every set of GPIO inputs the device has, rather than only
    for the unnamed GPIO inputs.

    This doesn't currently affect any test cases, because of all the
    tests which use irq_intercept_in only tests/qtest-l2vic-test.c uses
    it on a device that creates named GPIO inputs.  That device has both
    unnamed GPIO inputs and a named GPIO input "reset".  The effect is
    that a change in the "reset" line state looks like a change in
    interrupt input line 0; but since the test doesn't cause "reset" to
    change this doesn't happen and there are no observable effects of the
    bug.

    Check the ngl->name against the specified one for both input
    and output interception. (Currently this will be equivalent to
    a check against NULL for input intercepts.) As we're now checking
    for an exact name match unconditionally, we can break out of the
    loop as soon as we've found it.

    Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
    Reviewed-by: Fabiano Rosas <farosas@suse.de>
    Signed-off-by: Fabiano Rosas <farosas@suse.de>

diff --git a/system/qtest.c b/system/qtest.c
index a3de815ce6..5ff3f9f27d 100644
--- a/system/qtest.c
+++ b/system/qtest.c
@@ -422,23 +422,24 @@ static void qtest_process_command(CharFrontend *chr, gchar **words)
         }

         QLIST_FOREACH(ngl, &dev->gpios, node) {
-            /* We don't support inbound interception of named GPIOs yet */
+            /* NULL is valid and matchable, for "unnamed GPIO" */
+            if (g_strcmp0(ngl->name, words[2]) != 0) {
+                continue;
+            }
+
             if (is_outbound) {
-                /* NULL is valid and matchable, for "unnamed GPIO" */
-                if (g_strcmp0(ngl->name, words[2]) == 0) {
-                    int i;
-                    qtest_init_irq_intercept(ngl->num_out);
-                    for (i = 0; i < ngl->num_out; ++i) {
-                        qtest_install_gpio_out_intercept(dev, ngl->name, i);
-                    }
-                    interception_succeeded = true;
+                int i;
+                qtest_init_irq_intercept(ngl->num_out);
+                for (i = 0; i < ngl->num_out; ++i) {
+                    qtest_install_gpio_out_intercept(dev, ngl->name, i);
                 }
             } else {
                 qtest_init_irq_intercept(ngl->num_in);
                 qemu_irq_set_observer(ngl->in, qtest_irq_handler,
                                       ngl->num_in);
-                interception_succeeded = true;
             }
+            interception_succeeded = true;
+            break;
         }

         if (interception_succeeded) {