From nobody Wed Oct 22 17:06:53 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1519148706561242.62195489760165; Tue, 20 Feb 2018 09:45:06 -0800 (PST) Received: from localhost ([::1]:56855 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eoByT-0005wN-Ml for importer@patchew.org; Tue, 20 Feb 2018 12:45:05 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:46626) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eoBtz-0002LO-Eo for qemu-devel@nongnu.org; Tue, 20 Feb 2018 12:40:28 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eoBtw-0000Pp-0p for qemu-devel@nongnu.org; Tue, 20 Feb 2018 12:40:27 -0500 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:39576 helo=mx1.redhat.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1eoBtv-0000OM-IQ for qemu-devel@nongnu.org; Tue, 20 Feb 2018 12:40:23 -0500 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id BFE5340FB639 for ; Tue, 20 Feb 2018 17:40:20 +0000 (UTC) Received: from thh440s.redhat.com (ovpn-116-114.ams2.redhat.com [10.36.116.114]) by smtp.corp.redhat.com (Postfix) with ESMTP id 8061FAE7B6; Tue, 20 Feb 2018 17:40:17 +0000 (UTC) From: Thomas Huth To: qemu-devel@nongnu.org, Jason Wang , "Dr. David Alan Gilbert" Date: Tue, 20 Feb 2018 18:39:59 +0100 Message-Id: <1519148406-15006-2-git-send-email-thuth@redhat.com> In-Reply-To: <1519148406-15006-1-git-send-email-thuth@redhat.com> References: <1519148406-15006-1-git-send-email-thuth@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.11.54.5 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.7]); Tue, 20 Feb 2018 17:40:20 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.7]); Tue, 20 Feb 2018 17:40:20 +0000 (UTC) for IP:'10.11.54.5' DOMAIN:'int-mx05.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'thuth@redhat.com' RCPT:'' X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 66.187.233.73 Subject: [Qemu-devel] [PATCH v2 1/8] net: Move error reporting from net_init_client/netdev to the calling site X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Paolo Bonzini , Stefan Hajnoczi Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" It looks strange that net_init_client() and net_init_netdev() both take an "Error **errp" parameter, but then do the error reporting with "error_report_err(local_err)" on their own. Let's move the error reporting to the calling site instead to simplify this code a little bit. Reviewed-by: Eric Blake Reviewed-by: Paolo Bonzini Signed-off-by: Thomas Huth --- include/net/net.h | 2 +- net/net.c | 29 +++++------------------------ vl.c | 3 ++- 3 files changed, 8 insertions(+), 26 deletions(-) diff --git a/include/net/net.h b/include/net/net.h index 3fc48e4..bdd4d9f 100644 --- a/include/net/net.h +++ b/include/net/net.h @@ -206,7 +206,7 @@ extern const char *legacy_bootp_filename; =20 int net_client_init(QemuOpts *opts, bool is_netdev, Error **errp); int net_client_parse(QemuOptsList *opts_list, const char *str); -int net_init_clients(void); +int net_init_clients(Error **errp); void net_check_clients(void); void net_cleanup(void); void hmp_host_net_add(Monitor *mon, const QDict *qdict); diff --git a/net/net.c b/net/net.c index 7d42925..e213a61 100644 --- a/net/net.c +++ b/net/net.c @@ -1520,46 +1520,27 @@ void net_check_clients(void) =20 static int net_init_client(void *dummy, QemuOpts *opts, Error **errp) { - Error *local_err =3D NULL; - - net_client_init(opts, false, &local_err); - if (local_err) { - error_report_err(local_err); - return -1; - } - - return 0; + return net_client_init(opts, false, errp); } =20 static int net_init_netdev(void *dummy, QemuOpts *opts, Error **errp) { - Error *local_err =3D NULL; - int ret; - - ret =3D net_client_init(opts, true, &local_err); - if (local_err) { - error_report_err(local_err); - return -1; - } - - return ret; + return net_client_init(opts, true, errp); } =20 -int net_init_clients(void) +int net_init_clients(Error **errp) { - QemuOptsList *net =3D qemu_find_opts("net"); - net_change_state_entry =3D qemu_add_vm_change_state_handler(net_vm_change_state_handler, NULL= ); =20 QTAILQ_INIT(&net_clients); =20 if (qemu_opts_foreach(qemu_find_opts("netdev"), - net_init_netdev, NULL, NULL)) { + net_init_netdev, NULL, errp)) { return -1; } =20 - if (qemu_opts_foreach(net, net_init_client, NULL, NULL)) { + if (qemu_opts_foreach(qemu_find_opts("net"), net_init_client, NULL, er= rp)) { return -1; } =20 diff --git a/vl.c b/vl.c index 9e7235d..698b681 100644 --- a/vl.c +++ b/vl.c @@ -4476,7 +4476,8 @@ int main(int argc, char **argv, char **envp) =20 colo_info_init(); =20 - if (net_init_clients() < 0) { + if (net_init_clients(&err) < 0) { + error_report_err(err); exit(1); } =20 --=20 1.8.3.1