From mboxrd@z Thu Jan 1 00:00:00 1970 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) From: Markus Armbruster Date: Thu, 25 Mar 2010 17:22:38 +0100 Message-Id: <1269534160-4550-10-git-send-email-armbru@redhat.com> In-Reply-To: <1269534160-4550-1-git-send-email-armbru@redhat.com> References: <1269534160-4550-1-git-send-email-armbru@redhat.com> Subject: [Qemu-devel] [PATCH v3 09/11] error: Convert net_client_init() to QError List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: lcapitulino@redhat.com 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; } -- 1.6.6.1