[PATCH 2/2] tests/qtest/npcm7xx_emc-test: Connect all NICs to a backend

Peter Maydell posted 2 patches 9 months, 3 weeks ago
Maintainers: Tyrone Ting <kfting@nuvoton.com>, Hao Wu <wuhaotsh@google.com>, Peter Maydell <peter.maydell@linaro.org>, Thomas Huth <thuth@redhat.com>, Laurent Vivier <lvivier@redhat.com>, Paolo Bonzini <pbonzini@redhat.com>
[PATCH 2/2] tests/qtest/npcm7xx_emc-test: Connect all NICs to a backend
Posted by Peter Maydell 9 months, 3 weeks ago
Currently QEMU will warn if there is a NIC on the board that
is not connected to a backend. By default the '-nic user' will
get used for all NICs, but if you manually connect a specific
NIC to a specific backend, then the other NICs on the board
have no backend and will be warned about:

qemu-system-arm: warning: nic npcm7xx-emc.1 has no peer
qemu-system-arm: warning: nic npcm-gmac.0 has no peer
qemu-system-arm: warning: nic npcm-gmac.1 has no peer

So suppress those warnings by manually connecting every NIC
on the board to some backend.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
---
 tests/qtest/npcm7xx_emc-test.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/tests/qtest/npcm7xx_emc-test.c b/tests/qtest/npcm7xx_emc-test.c
index f7646fae2c9..63f6cadb5cc 100644
--- a/tests/qtest/npcm7xx_emc-test.c
+++ b/tests/qtest/npcm7xx_emc-test.c
@@ -228,7 +228,10 @@ static int *packet_test_init(int module_num, GString *cmd_line)
      * KISS and use -nic. The driver accepts 'emc0' and 'emc1' as aliases
      * in the 'model' field to specify the device to match.
      */
-    g_string_append_printf(cmd_line, " -nic socket,fd=%d,model=emc%d ",
+    g_string_append_printf(cmd_line, " -nic socket,fd=%d,model=emc%d "
+                           "-nic user,model=npcm7xx-emc "
+                           "-nic user,model=npcm-gmac "
+                           "-nic user,model=npcm-gmac",
                            test_sockets[1], module_num);
 
     g_test_queue_destroy(packet_test_clear, test_sockets);
-- 
2.34.1
Re: [PATCH 2/2] tests/qtest/npcm7xx_emc-test: Connect all NICs to a backend
Posted by Thomas Huth 9 months, 3 weeks ago
On 06/02/2024 18.12, Peter Maydell wrote:
> Currently QEMU will warn if there is a NIC on the board that
> is not connected to a backend. By default the '-nic user' will
> get used for all NICs, but if you manually connect a specific
> NIC to a specific backend, then the other NICs on the board
> have no backend and will be warned about:
> 
> qemu-system-arm: warning: nic npcm7xx-emc.1 has no peer
> qemu-system-arm: warning: nic npcm-gmac.0 has no peer
> qemu-system-arm: warning: nic npcm-gmac.1 has no peer
> 
> So suppress those warnings by manually connecting every NIC
> on the board to some backend.
> 
> Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
> ---
>   tests/qtest/npcm7xx_emc-test.c | 5 ++++-
>   1 file changed, 4 insertions(+), 1 deletion(-)
> 
> diff --git a/tests/qtest/npcm7xx_emc-test.c b/tests/qtest/npcm7xx_emc-test.c
> index f7646fae2c9..63f6cadb5cc 100644
> --- a/tests/qtest/npcm7xx_emc-test.c
> +++ b/tests/qtest/npcm7xx_emc-test.c
> @@ -228,7 +228,10 @@ static int *packet_test_init(int module_num, GString *cmd_line)
>        * KISS and use -nic. The driver accepts 'emc0' and 'emc1' as aliases
>        * in the 'model' field to specify the device to match.
>        */
> -    g_string_append_printf(cmd_line, " -nic socket,fd=%d,model=emc%d ",
> +    g_string_append_printf(cmd_line, " -nic socket,fd=%d,model=emc%d "
> +                           "-nic user,model=npcm7xx-emc "
> +                           "-nic user,model=npcm-gmac "
> +                           "-nic user,model=npcm-gmac",

Alternatively, use -nic hubport,hubid=0 in case we even want to run this 
test without slirp support, too (but currently there is already a check for 
this in the meson.build file, so -nic user should be fine, too). Anyway,

Reviewed-by: Thomas Huth <thuth@redhat.com>
Re: [PATCH 2/2] tests/qtest/npcm7xx_emc-test: Connect all NICs to a backend
Posted by David Woodhouse 9 months, 3 weeks ago
On Tue, 2024-02-06 at 17:12 +0000, Peter Maydell wrote:
> Currently QEMU will warn if there is a NIC on the board that
> is not connected to a backend. By default the '-nic user' will
> get used for all NICs, but if you manually connect a specific
> NIC to a specific backend, then the other NICs on the board
> have no backend and will be warned about:
> 
> qemu-system-arm: warning: nic npcm7xx-emc.1 has no peer
> qemu-system-arm: warning: nic npcm-gmac.0 has no peer
> qemu-system-arm: warning: nic npcm-gmac.1 has no peer
> 
> So suppress those warnings by manually connecting every NIC
> on the board to some backend.
> 
> Signed-off-by: Peter Maydell <peter.maydell@linaro.org>

Reviewed-by: David Woodhouse <dwmw@amazon.co.uk>


... although do we want to expand this test to cover the GMACs? 
Re: [PATCH 2/2] tests/qtest/npcm7xx_emc-test: Connect all NICs to a backend
Posted by Peter Maydell 9 months, 3 weeks ago
On Tue, 6 Feb 2024 at 17:36, David Woodhouse <dwmw2@infradead.org> wrote:
>
> On Tue, 2024-02-06 at 17:12 +0000, Peter Maydell wrote:
> > Currently QEMU will warn if there is a NIC on the board that
> > is not connected to a backend. By default the '-nic user' will
> > get used for all NICs, but if you manually connect a specific
> > NIC to a specific backend, then the other NICs on the board
> > have no backend and will be warned about:
> >
> > qemu-system-arm: warning: nic npcm7xx-emc.1 has no peer
> > qemu-system-arm: warning: nic npcm-gmac.0 has no peer
> > qemu-system-arm: warning: nic npcm-gmac.1 has no peer
> >
> > So suppress those warnings by manually connecting every NIC
> > on the board to some backend.
> >
> > Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
>
> Reviewed-by: David Woodhouse <dwmw@amazon.co.uk>
>
>
> ... although do we want to expand this test to cover the GMACs?

It's very specific to details of how to program the particular
ethernet controller. The GMAC is supposed to be covered by
npcm_gmac-test.c (but that has issues of its own, see
https://lore.kernel.org/qemu-devel/CAFEAcA_gkQz7q+PhiqrVd+YrVJvLt1H=Ypp4av9qn+6mYC6jdA@mail.gmail.com/
and in any case doesn't yet try to actually exercise the device
beyond a rather minimal "check the register reset values"
test that doesn't need any particular backend connected).

thanks
-- PMM
Re: [PATCH 2/2] tests/qtest/npcm7xx_emc-test: Connect all NICs to a backend
Posted by Peter Maydell 9 months, 3 weeks ago
On Tue, 6 Feb 2024 at 17:12, Peter Maydell <peter.maydell@linaro.org> wrote:
>
> Currently QEMU will warn if there is a NIC on the board that
> is not connected to a backend. By default the '-nic user' will
> get used for all NICs, but if you manually connect a specific
> NIC to a specific backend, then the other NICs on the board
> have no backend and will be warned about:
>
> qemu-system-arm: warning: nic npcm7xx-emc.1 has no peer
> qemu-system-arm: warning: nic npcm-gmac.0 has no peer
> qemu-system-arm: warning: nic npcm-gmac.1 has no peer
>
> So suppress those warnings by manually connecting every NIC
> on the board to some backend.
>
> Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
> ---
>  tests/qtest/npcm7xx_emc-test.c | 5 ++++-
>  1 file changed, 4 insertions(+), 1 deletion(-)
>
> diff --git a/tests/qtest/npcm7xx_emc-test.c b/tests/qtest/npcm7xx_emc-test.c
> index f7646fae2c9..63f6cadb5cc 100644
> --- a/tests/qtest/npcm7xx_emc-test.c
> +++ b/tests/qtest/npcm7xx_emc-test.c
> @@ -228,7 +228,10 @@ static int *packet_test_init(int module_num, GString *cmd_line)
>       * KISS and use -nic. The driver accepts 'emc0' and 'emc1' as aliases
>       * in the 'model' field to specify the device to match.
>       */

Whoops, made the classic "create patch without having saved in
the editor" mistake. I meant to also include this change to
the comment:

     /*
      * KISS and use -nic. The driver accepts 'emc0' and 'emc1' as aliases
      * in the 'model' field to specify the device to match.
+     * We wire up the other NICs on the board to the 'user' backend
+     * purely to suppress the "warning: nic npcm7xx-emc.1 has no peer"
+     * etc warnings that otherwise are currently produced.
      */


> -    g_string_append_printf(cmd_line, " -nic socket,fd=%d,model=emc%d ",
> +    g_string_append_printf(cmd_line, " -nic socket,fd=%d,model=emc%d "
> +                           "-nic user,model=npcm7xx-emc "
> +                           "-nic user,model=npcm-gmac "
> +                           "-nic user,model=npcm-gmac",
>                             test_sockets[1], module_num);
>
>      g_test_queue_destroy(packet_test_clear, test_sockets);
> --
> 2.34.1
>

thanks
-- PMM