Received: from eggs.gnu.org ([140.186.70.92]:38636) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QOQb7-0005IO-Pv for qemu-devel@nongnu.org; Mon, 23 May 2011 04:34:46 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1QOQb6-0004Ne-N4 for qemu-devel@nongnu.org; Mon, 23 May 2011 04:34:45 -0400 Received: from mx1.redhat.com ([209.132.183.28]:50054) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QOQb6-0004NZ-Eg for qemu-devel@nongnu.org; Mon, 23 May 2011 04:34:44 -0400 From: Markus Armbruster References: <1305906601-25324-1-git-send-email-peter.maydell@linaro.org> <1305906601-25324-4-git-send-email-peter.maydell@linaro.org> Date: Mon, 23 May 2011 10:34:40 +0200 In-Reply-To: <1305906601-25324-4-git-send-email-peter.maydell@linaro.org> (Peter Maydell's message of "Fri, 20 May 2011 16:50:01 +0100") Message-ID: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Subject: Re: [Qemu-devel] [PATCH 3/3] net: Warn about "-net nic" options which were ignored List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Peter Maydell Cc: qemu-devel@nongnu.org, patches@linaro.org Peter Maydell writes: > 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 > --- > 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"); > + } > + } Nicer message would be possible if NICInfo had a Location for error_print_loc(). Out of this patch's scope. > } > > 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; > };