From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:53736) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Ys8u5-0007Qd-Fy for qemu-devel@nongnu.org; Tue, 12 May 2015 08:03:19 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Ys8tz-0003xs-Hf for qemu-devel@nongnu.org; Tue, 12 May 2015 08:03:17 -0400 Received: from mx1.redhat.com ([209.132.183.28]:60850) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Ys8tz-0003wt-BF for qemu-devel@nongnu.org; Tue, 12 May 2015 08:03:11 -0400 Received: from int-mx14.intmail.prod.int.phx2.redhat.com (int-mx14.intmail.prod.int.phx2.redhat.com [10.5.11.27]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id t4CC39o0015283 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL) for ; Tue, 12 May 2015 08:03:10 -0400 From: Markus Armbruster Date: Tue, 12 May 2015 14:02:55 +0200 Message-Id: <1431432187-10993-4-git-send-email-armbru@redhat.com> In-Reply-To: <1431432187-10993-1-git-send-email-armbru@redhat.com> References: <1431432187-10993-1-git-send-email-armbru@redhat.com> Subject: [Qemu-devel] [PATCH 03/15] net: Improve -net nic error reporting List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: stefanha@redhat.com When -net nic fails, it first reports a specific error, then a generic one, like this: $ qemu-system-x86_64 -net nic,netdev=nonexistant qemu-system-x86_64: -net nic,netdev=nonexistant: netdev 'nonexistant' not found qemu-system-x86_64: -net nic,netdev=nonexistant: Device 'nic' could not be initialized Convert net_init_nic() to Error to get rid of the unwanted second error message. Signed-off-by: Markus Armbruster --- net/net.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/net/net.c b/net/net.c index 5808c58..70ec33a 100644 --- a/net/net.c +++ b/net/net.c @@ -735,7 +735,6 @@ int qemu_find_nic_model(NICInfo *nd, const char * const *models, static int net_init_nic(const NetClientOptions *opts, const char *name, NetClientState *peer, Error **errp) { - /* FIXME error_setg(errp, ...) on failure */ int idx; NICInfo *nd; const NetLegacyNicOptions *nic; @@ -745,7 +744,7 @@ static int net_init_nic(const NetClientOptions *opts, const char *name, idx = nic_get_free_idx(); if (idx == -1 || nb_nics >= MAX_NICS) { - error_report("Too Many NICs"); + error_setg(errp, "Too Many NICs"); return -1; } @@ -756,7 +755,7 @@ static int net_init_nic(const NetClientOptions *opts, const char *name, if (nic->has_netdev) { nd->netdev = qemu_find_netdev(nic->netdev); if (!nd->netdev) { - error_report("netdev '%s' not found", nic->netdev); + error_setg(errp, "netdev '%s' not found", nic->netdev); return -1; } } else { @@ -773,19 +772,20 @@ static int net_init_nic(const NetClientOptions *opts, const char *name, if (nic->has_macaddr && net_parse_macaddr(nd->macaddr.a, nic->macaddr) < 0) { - error_report("invalid syntax for ethernet address"); + error_setg(errp, "invalid syntax for ethernet address"); return -1; } if (nic->has_macaddr && is_multicast_ether_addr(nd->macaddr.a)) { - error_report("NIC cannot have multicast MAC address (odd 1st byte)"); + error_setg(errp, + "NIC cannot have multicast MAC address (odd 1st byte)"); return -1; } qemu_macaddr_default_if_unset(&nd->macaddr); if (nic->has_vectors) { if (nic->vectors > 0x7ffffff) { - error_report("invalid # of vectors: %"PRIu32, nic->vectors); + error_setg(errp, "invalid # of vectors: %"PRIu32, nic->vectors); return -1; } nd->nvectors = nic->vectors; -- 1.9.3