Patchwork [2/3] net: Don't warn about the default network setup

login
register
mail settings
Submitter Peter Maydell
Date May 20, 2011, 3:50 p.m.
Message ID <1305906601-25324-3-git-send-email-peter.maydell@linaro.org>
Download mbox | patch
Permalink /patch/96637/
State New
Headers show

Comments

Peter Maydell - May 20, 2011, 3:50 p.m.
Don't warn about the default network setup that you get if no command line
-net options are specified.  There are two cases that we would otherwise
complain about:

(1) board doesn't support a NIC but the implicit "-net nic" requested one
(2) CONFIG_SLIRP not set, so the implicit "-net nic" sets up a nic that
isn't connected to anything

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
---
 net.c |   12 ++++++++++++
 1 files changed, 12 insertions(+), 0 deletions(-)
Markus Armbruster - May 23, 2011, 8:30 a.m.
Peter Maydell <peter.maydell@linaro.org> writes:

> Don't warn about the default network setup that you get if no command line
> -net options are specified.  There are two cases that we would otherwise
> complain about:
>
> (1) board doesn't support a NIC but the implicit "-net nic" requested one

Maybe such board should declare no_nic, similar to no_parallel &
friends.  But that's out of this patch's scope.

This complaint is only added in the next patch, isn't it?  I don't mind.

> (2) CONFIG_SLIRP not set, so the implicit "-net nic" sets up a nic that
> isn't connected to anything

This one's already there, I think.
Peter Maydell - May 23, 2011, 8:55 a.m.
On 23 May 2011 09:30, Markus Armbruster <armbru@redhat.com> wrote:
> Peter Maydell <peter.maydell@linaro.org> writes:
>
>> Don't warn about the default network setup that you get if no command line
>> -net options are specified.  There are two cases that we would otherwise
>> complain about:
>>
>> (1) board doesn't support a NIC but the implicit "-net nic" requested one
>
> Maybe such board should declare no_nic, similar to no_parallel &
> friends.  But that's out of this patch's scope.

I think in the brave new qdev world this kind of thing should be
handled generically by warning about any -device requested devices
which couldn't be plugged into anything sensible.

> This complaint is only added in the next patch, isn't it?  I don't mind.

It won't explicitly say "you asked for a NIC and didn't get one",
but it will make the obscurer complaint "Warning: vlan 0 with no
nics", because the implicit '-net user' is then not connected to
anything. I was deliberately slightly vague with the comment text
so it would be true both before and after the following patch :-)

>> (2) CONFIG_SLIRP not set, so the implicit "-net nic" sets up a nic that
>> isn't connected to anything
>
> This one's already there, I think.

No, without this patch qemu will complain
"Warning: vlan 0 is not connected to host network" if you configured
with --disable-slirp.

(--disable-slirp seems to have been left out of configure --help;
I assume that's an oversight.)

-- PMM

Patch

diff --git a/net.c b/net.c
index 1b521a9..68c2840 100644
--- a/net.c
+++ b/net.c
@@ -1305,6 +1305,18 @@  void net_check_clients(void)
     VLANState *vlan;
     VLANClientState *vc;
 
+    /* Don't warn about the default network setup that you get if
+     * no command line -net or -netdev options are specified. There
+     * are two cases that we would otherwise complain about:
+     * (1) board doesn't support a NIC but the implicit "-net nic"
+     * requested one
+     * (2) CONFIG_SLIRP not set, in which case the implicit "-net nic"
+     * sets up a nic that isn't connected to anything.
+     */
+    if (default_net) {
+        return;
+    }
+
     QTAILQ_FOREACH(vlan, &vlans, next) {
         int has_nic = 0, has_host_dev = 0;