From patchwork Fri May 20 15:50:01 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 96638 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [140.186.70.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 2D0C3B71A4 for ; Sat, 21 May 2011 01:51:27 +1000 (EST) Received: from localhost ([::1]:44096 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QNRz2-0007PE-K3 for incoming@patchwork.ozlabs.org; Fri, 20 May 2011 11:51:24 -0400 Received: from eggs.gnu.org ([140.186.70.92]:44689) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QNRxs-0005Wt-QP for qemu-devel@nongnu.org; Fri, 20 May 2011 11:50:14 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1QNRxr-0001Kw-SD for qemu-devel@nongnu.org; Fri, 20 May 2011 11:50:12 -0400 Received: from mnementh.archaic.org.uk ([81.2.115.146]:49864) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QNRxr-0001GH-F1 for qemu-devel@nongnu.org; Fri, 20 May 2011 11:50:11 -0400 Received: from pm215 by mnementh.archaic.org.uk with local (Exim 4.72) (envelope-from ) id 1QNRxh-0006az-QV; Fri, 20 May 2011 16:50:01 +0100 From: Peter Maydell To: qemu-devel@nongnu.org Date: Fri, 20 May 2011 16:50:01 +0100 Message-Id: <1305906601-25324-4-git-send-email-peter.maydell@linaro.org> X-Mailer: git-send-email 1.7.2.5 In-Reply-To: <1305906601-25324-1-git-send-email-peter.maydell@linaro.org> References: <1305906601-25324-1-git-send-email-peter.maydell@linaro.org> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 2) X-Received-From: 81.2.115.146 Cc: Markus Armbruster , patches@linaro.org Subject: [Qemu-devel] [PATCH 3/3] net: Warn about "-net nic" options which were ignored X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.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 --- 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; };