From patchwork Mon Apr 5 20:33:53 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luiz Capitulino X-Patchwork-Id: 49461 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 91C0FB7C8E for ; Tue, 6 Apr 2010 08:12:02 +1000 (EST) Received: from localhost ([127.0.0.1]:54795 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Nyt9A-0003ZZ-PP for incoming@patchwork.ozlabs.org; Mon, 05 Apr 2010 16:43:48 -0400 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1Nyt0p-0001dL-Uz for qemu-devel@nongnu.org; Mon, 05 Apr 2010 16:35:12 -0400 Received: from [140.186.70.92] (port=49488 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Nyt0l-0001Wd-Jw for qemu-devel@nongnu.org; Mon, 05 Apr 2010 16:35:11 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1Nyt0K-0001d6-Lj for qemu-devel@nongnu.org; Mon, 05 Apr 2010 16:34:42 -0400 Received: from mx1.redhat.com ([209.132.183.28]:14726) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1Nyt0K-0001d0-Cc for qemu-devel@nongnu.org; Mon, 05 Apr 2010 16:34:40 -0400 Received: from int-mx01.intmail.prod.int.phx2.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id o35KYdBw032458 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Mon, 5 Apr 2010 16:34:39 -0400 Received: from localhost (vpn-8-191.rdu.redhat.com [10.11.8.191]) by int-mx01.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id o35KYcjG027309; Mon, 5 Apr 2010 16:34:38 -0400 From: Luiz Capitulino To: aliguori@us.ibm.com Date: Mon, 5 Apr 2010 17:33:53 -0300 Message-Id: <1270499642-31543-13-git-send-email-lcapitulino@redhat.com> In-Reply-To: <1270499642-31543-1-git-send-email-lcapitulino@redhat.com> References: <1270499642-31543-1-git-send-email-lcapitulino@redhat.com> X-Scanned-By: MIMEDefang 2.67 on 10.5.11.11 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. Cc: Luiz Capitulino , qemu-devel@nongnu.org, Markus Armbruster Subject: [Qemu-devel] [PATCH 12/21] 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 From: Markus Armbruster 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 Signed-off-by: Luiz Capitulino --- net.c | 38 ++++++++++++++++++-------------------- 1 files changed, 18 insertions(+), 20 deletions(-) diff --git a/net.c b/net.c index 28d106b..71c0828 100644 --- a/net.c +++ b/net.c @@ -1065,18 +1065,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 && @@ -1085,21 +1079,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; } } @@ -1125,14 +1119,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; }