From patchwork Thu Mar 18 16:33:16 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Markus Armbruster X-Patchwork-Id: 48075 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 43831B7DE4 for ; Fri, 19 Mar 2010 04:12:35 +1100 (EST) Received: from localhost ([127.0.0.1]:33113 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NsJGq-0005yc-46 for incoming@patchwork.ozlabs.org; Thu, 18 Mar 2010 13:12:32 -0400 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1NsIf7-0008Tf-Jy for qemu-devel@nongnu.org; Thu, 18 Mar 2010 12:33:33 -0400 Received: from [199.232.76.173] (port=40354 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NsIf5-0008Rf-MO for qemu-devel@nongnu.org; Thu, 18 Mar 2010 12:33:31 -0400 Received: from Debian-exim by monty-python.gnu.org with spam-scanned (Exim 4.60) (envelope-from ) id 1NsIf0-0005N2-8j for qemu-devel@nongnu.org; Thu, 18 Mar 2010 12:33:31 -0400 Received: from oxygen.pond.sub.org ([213.239.205.148]:56562) by monty-python.gnu.org with esmtps (TLS-1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1NsIey-0005MS-HM for qemu-devel@nongnu.org; Thu, 18 Mar 2010 12:33:24 -0400 Received: from blackfin.pond.sub.org (pD9E3ACC8.dip.t-dialin.net [217.227.172.200]) by oxygen.pond.sub.org (Postfix) with ESMTPA id 2828B2DD35C for ; Thu, 18 Mar 2010 17:33:22 +0100 (CET) Received: by blackfin.pond.sub.org (Postfix, from userid 500) id 2093FD8; Thu, 18 Mar 2010 17:33:17 +0100 (CET) From: Markus Armbruster To: qemu-devel@nongnu.org Date: Thu, 18 Mar 2010 17:33:16 +0100 Message-Id: <1268929996-28763-10-git-send-email-armbru@redhat.com> X-Mailer: git-send-email 1.6.6.1 In-Reply-To: <1268929996-28763-1-git-send-email-armbru@redhat.com> References: <1268929996-28763-1-git-send-email-armbru@redhat.com> X-detected-operating-system: by monty-python.gnu.org: GNU/Linux 2.6 (newer, 3) Cc: lcapitulino@redhat.com Subject: [Qemu-devel] [PATCH 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..1f3c39c 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 backend type"); return -1; }