From patchwork Thu Mar 25 16:22:38 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Markus Armbruster X-Patchwork-Id: 48546 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [199.232.76.165]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 0723EB7CF9 for ; Fri, 26 Mar 2010 03:54:53 +1100 (EST) Received: from localhost ([127.0.0.1]:34367 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NuqKY-0001pD-JQ for incoming@patchwork.ozlabs.org; Thu, 25 Mar 2010 12:54:50 -0400 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1Nuppp-0005nN-5j for qemu-devel@nongnu.org; Thu, 25 Mar 2010 12:23:05 -0400 Received: from [140.186.70.92] (port=36050 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Nuppe-0005ec-Mt for qemu-devel@nongnu.org; Thu, 25 Mar 2010 12:22:59 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1NuppU-0001G3-RZ for qemu-devel@nongnu.org; Thu, 25 Mar 2010 12:22:54 -0400 Received: from oxygen.pond.sub.org ([213.239.205.148]:52312) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1NuppU-0001Ey-Ei for qemu-devel@nongnu.org; Thu, 25 Mar 2010 12:22:44 -0400 Received: from blackfin.pond.sub.org (pD9E38AC7.dip.t-dialin.net [217.227.138.199]) by oxygen.pond.sub.org (Postfix) with ESMTPA id 0626B276DB4 for ; Thu, 25 Mar 2010 17:22:42 +0100 (CET) Received: by blackfin.pond.sub.org (Postfix, from userid 500) id 25661EF; Thu, 25 Mar 2010 17:22:41 +0100 (CET) From: Markus Armbruster To: qemu-devel@nongnu.org Date: Thu, 25 Mar 2010 17:22:38 +0100 Message-Id: <1269534160-4550-10-git-send-email-armbru@redhat.com> X-Mailer: git-send-email 1.6.6.1 In-Reply-To: <1269534160-4550-1-git-send-email-armbru@redhat.com> References: <1269534160-4550-1-git-send-email-armbru@redhat.com> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 3) Cc: lcapitulino@redhat.com Subject: [Qemu-devel] [PATCH v3 09/11] error: Convert net_client_init() to QError X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org The conversion is shallow: client type init() methods aren't converted. Converting them is a big job for relatively little practical benefit, so leave it for later. Signed-off-by: Markus Armbruster --- net.c | 38 ++++++++++++++++++-------------------- 1 files changed, 18 insertions(+), 20 deletions(-) diff --git a/net.c b/net.c index 9338f35..435997b 100644 --- a/net.c +++ b/net.c @@ -1057,18 +1057,12 @@ int net_client_init(Monitor *mon, QemuOpts *opts, int is_netdev) int i; type = qemu_opt_get(opts, "type"); + if (!type) { + qerror_report(QERR_MISSING_PARAMETER, "type"); + return -1; + } - if (!is_netdev) { - if (!type) { - error_report("No type specified for -net"); - return -1; - } - } else { - if (!type) { - error_report("No type specified for -netdev"); - return -1; - } - + if (is_netdev) { if (strcmp(type, "tap") != 0 && #ifdef CONFIG_SLIRP strcmp(type, "user") != 0 && @@ -1077,21 +1071,21 @@ int net_client_init(Monitor *mon, QemuOpts *opts, int is_netdev) strcmp(type, "vde") != 0 && #endif strcmp(type, "socket") != 0) { - error_report("The '%s' network backend type is not valid with -netdev", - type); + qerror_report(QERR_INVALID_PARAMETER_VALUE, "type", + "a netdev backend type"); return -1; } if (qemu_opt_get(opts, "vlan")) { - error_report("The 'vlan' parameter is not valid with -netdev"); + qerror_report(QERR_INVALID_PARAMETER, "vlan"); return -1; } if (qemu_opt_get(opts, "name")) { - error_report("The 'name' parameter is not valid with -netdev"); + qerror_report(QERR_INVALID_PARAMETER, "name"); return -1; } if (!qemu_opts_id(opts)) { - error_report("The id= parameter is required with -netdev"); + qerror_report(QERR_MISSING_PARAMETER, "id"); return -1; } } @@ -1117,14 +1111,18 @@ int net_client_init(Monitor *mon, QemuOpts *opts, int is_netdev) } if (net_client_types[i].init) { - return net_client_types[i].init(opts, mon, name, vlan); - } else { - return 0; + if (net_client_types[i].init(opts, mon, name, vlan) < 0) { + /* TODO push error reporting into init() methods */ + qerror_report(QERR_DEVICE_INIT_FAILED, type); + return -1; + } } + return 0; } } - error_report("Invalid -net type '%s'", type); + qerror_report(QERR_INVALID_PARAMETER_VALUE, "type", + "a network client type"); return -1; }