From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:56201) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YxYBB-0004Pj-Q3 for qemu-devel@nongnu.org; Wed, 27 May 2015 06:03:22 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YxYBA-000262-Rr for qemu-devel@nongnu.org; Wed, 27 May 2015 06:03:17 -0400 Received: from mx1.redhat.com ([209.132.183.28]:43306) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YxYBA-00025q-JF for qemu-devel@nongnu.org; Wed, 27 May 2015 06:03:16 -0400 From: Stefan Hajnoczi Date: Wed, 27 May 2015 11:02:53 +0100 Message-Id: <1432720988-20200-3-git-send-email-stefanha@redhat.com> In-Reply-To: <1432720988-20200-1-git-send-email-stefanha@redhat.com> References: <1432720988-20200-1-git-send-email-stefanha@redhat.com> Subject: [Qemu-devel] [PULL 02/17] net: Improve error message for -net hubport a bit List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Peter Maydell , Markus Armbruster , Stefan Hajnoczi From: Markus Armbruster Type "hubport" is valid only with -netdev. Unfortunately, that's detected late and the error message doesn't explain why: $ qemu-system-i386 -net hubport,id=foo,hubid=0 qemu-system-i386: -net hubport,id=foo,hubid=0: Device 'hubport' could not be initialized Improve the error message to "Parameter 'type' expects a net type". Not fixed: -net hubport without the parameters required by -netdev hubport still asks for those parameters: $ qemu-system-i386 -net hubport qemu-system-i386: -net hubport: Parameter 'hubid' is missing Signed-off-by: Markus Armbruster Reviewed-by: Eric Blake Message-id: 1431691143-1015-2-git-send-email-armbru@redhat.com Signed-off-by: Stefan Hajnoczi --- net/hub.c | 5 +---- net/net.c | 5 +++++ 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/net/hub.c b/net/hub.c index 2b60ab9..261f8cc 100644 --- a/net/hub.c +++ b/net/hub.c @@ -286,12 +286,9 @@ int net_init_hubport(const NetClientOptions *opts, const char *name, const NetdevHubPortOptions *hubport; assert(opts->kind == NET_CLIENT_OPTIONS_KIND_HUBPORT); + assert(!peer); hubport = opts->hubport; - if (peer) { - return -EINVAL; - } - net_hub_add_port(hubport->hubid, name); return 0; } diff --git a/net/net.c b/net/net.c index 7427f6a..d9aaeb5 100644 --- a/net/net.c +++ b/net/net.c @@ -882,6 +882,11 @@ static int net_client_init1(const void *object, int is_netdev, Error **errp) } else { u.net = object; opts = u.net->opts; + if (opts->kind == NET_CLIENT_OPTIONS_KIND_HUBPORT) { + error_set(errp, QERR_INVALID_PARAMETER_VALUE, "type", + "a net type"); + return -1; + } /* missing optional values have been initialized to "all bits zero" */ name = u.net->has_id ? u.net->id : u.net->name; } -- 2.4.1