qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Peter Maydell <peter.maydell@linaro.org>
To: qemu-devel@nongnu.org
Cc: Markus Armbruster <armbru@redhat.com>, patches@linaro.org
Subject: [Qemu-devel] [PATCH 3/3] net: Warn about "-net nic" options which were ignored
Date: Fri, 20 May 2011 16:50:01 +0100	[thread overview]
Message-ID: <1305906601-25324-4-git-send-email-peter.maydell@linaro.org> (raw)
In-Reply-To: <1305906601-25324-1-git-send-email-peter.maydell@linaro.org>

Diagnose the case where the user asked for a NIC via "-net nic"
but the board didn't instantiate that NIC (for example where the
user asked for two NICs but the board only supports one). Note
that this diagnostic doesn't apply to NICs created through -device,
because those are always instantiated.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
---
 hw/qdev.c |    1 +
 net.c     |   15 +++++++++++++++
 net.h     |    3 ++-
 3 files changed, 18 insertions(+), 1 deletions(-)

diff --git a/hw/qdev.c b/hw/qdev.c
index 9519f5d..2987901 100644
--- a/hw/qdev.c
+++ b/hw/qdev.c
@@ -468,6 +468,7 @@ void qdev_set_nic_properties(DeviceState *dev, NICInfo *nd)
         qdev_prop_exists(dev, "vectors")) {
         qdev_prop_set_uint32(dev, "vectors", nd->nvectors);
     }
+    nd->instantiated = 1;
 }
 
 BusState *qdev_get_child_bus(DeviceState *dev, const char *name)
diff --git a/net.c b/net.c
index 68c2840..a104976 100644
--- a/net.c
+++ b/net.c
@@ -1304,6 +1304,7 @@ void net_check_clients(void)
 {
     VLANState *vlan;
     VLANClientState *vc;
+    int i;
 
     /* Don't warn about the default network setup that you get if
      * no command line -net or -netdev options are specified. There
@@ -1348,6 +1349,20 @@ void net_check_clients(void)
                     vc->name);
         }
     }
+
+    /* Check that all NICs requested via -net nic actually got created.
+     * NICs created via -device don't need to be checked here because
+     * they are always instantiated.
+     */
+    for (i = 0; i < MAX_NICS; i++) {
+        NICInfo *nd = &nd_table[i];
+        if (nd->used && !nd->instantiated) {
+            fprintf(stderr, "Warning: requested NIC (%s, model %s) "
+                    "was not created (not supported by this machine?)\n",
+                    nd->name ? nd->name : "anonymous",
+                    nd->model ? nd->model : "unspecified");
+        }
+    }
 }
 
 static int net_init_client(QemuOpts *opts, void *dummy)
diff --git a/net.h b/net.h
index 6ceca50..5b883a9 100644
--- a/net.h
+++ b/net.h
@@ -133,7 +133,8 @@ struct NICInfo {
     char *devaddr;
     VLANState *vlan;
     VLANClientState *netdev;
-    int used;
+    int used;         /* is this slot in nd_table[] being used? */
+    int instantiated; /* does this NICInfo correspond to an instantiated NIC? */
     int nvectors;
 };
 
-- 
1.7.1

  parent reply	other threads:[~2011-05-20 15:50 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-05-20 15:49 [Qemu-devel] [PATCH 0/3] net: reimplement -net nic diagnostic fix Peter Maydell
2011-05-20 15:49 ` [Qemu-devel] [PATCH 1/3] Revert "net: Improve the warnings for dubious command line option combinations" Peter Maydell
2011-05-20 15:50 ` [Qemu-devel] [PATCH 2/3] net: Don't warn about the default network setup Peter Maydell
2011-05-23  8:30   ` Markus Armbruster
2011-05-23  8:55     ` Peter Maydell
2011-05-20 15:50 ` Peter Maydell [this message]
2011-05-23  8:34   ` [Qemu-devel] [PATCH 3/3] net: Warn about "-net nic" options which were ignored Markus Armbruster
2011-05-20 15:55 ` [Qemu-devel] [PATCH 0/3] net: reimplement -net nic diagnostic fix Jan Kiszka
2011-05-20 16:04   ` Peter Maydell
2011-05-20 16:07     ` Jan Kiszka
2011-05-20 16:12       ` Peter Maydell
2011-05-20 16:15         ` Jan Kiszka
2011-05-23  8:35 ` Markus Armbruster
2011-06-05 13:12 ` Peter Maydell
2011-06-22 11:39   ` Peter Maydell
2011-06-22 12:58 ` Anthony Liguori

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1305906601-25324-4-git-send-email-peter.maydell@linaro.org \
    --to=peter.maydell@linaro.org \
    --cc=armbru@redhat.com \
    --cc=patches@linaro.org \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).