From patchwork Wed May 27 10:03:03 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Hajnoczi X-Patchwork-Id: 477045 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 1152E1402A2 for ; Wed, 27 May 2015 20:10:44 +1000 (AEST) Received: from localhost ([::1]:52901 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YxYIM-00006F-5c for incoming@patchwork.ozlabs.org; Wed, 27 May 2015 06:10:42 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:56346) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YxYBW-0004xR-98 for qemu-devel@nongnu.org; Wed, 27 May 2015 06:03:42 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YxYBV-0002E8-GH for qemu-devel@nongnu.org; Wed, 27 May 2015 06:03:38 -0400 Received: from mx1.redhat.com ([209.132.183.28]:49629) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YxYBV-0002E3-Bq for qemu-devel@nongnu.org; Wed, 27 May 2015 06:03:37 -0400 Received: from int-mx13.intmail.prod.int.phx2.redhat.com (int-mx13.intmail.prod.int.phx2.redhat.com [10.5.11.26]) by mx1.redhat.com (Postfix) with ESMTPS id 0A4F48F30C; Wed, 27 May 2015 10:03:37 +0000 (UTC) Received: from localhost (ovpn-112-78.ams2.redhat.com [10.36.112.78]) by int-mx13.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t4RA3Z0I012520; Wed, 27 May 2015 06:03:36 -0400 From: Stefan Hajnoczi To: Date: Wed, 27 May 2015 11:03:03 +0100 Message-Id: <1432720988-20200-13-git-send-email-stefanha@redhat.com> In-Reply-To: <1432720988-20200-1-git-send-email-stefanha@redhat.com> References: <1432720988-20200-1-git-send-email-stefanha@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.26 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: Peter Maydell , Markus Armbruster , Stefan Hajnoczi Subject: [Qemu-devel] [PULL 12/17] tap-linux: Convert tap_open() to Error X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org From: Markus Armbruster Signed-off-by: Markus Armbruster Reviewed-by: Eric Blake Message-id: 1431691143-1015-12-git-send-email-armbru@redhat.com Signed-off-by: Stefan Hajnoczi --- net/tap-linux.c | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/net/tap-linux.c b/net/tap-linux.c index be18382..6c3caef 100644 --- a/net/tap-linux.c +++ b/net/tap-linux.c @@ -39,7 +39,6 @@ int tap_open(char *ifname, int ifname_size, int *vnet_hdr, int vnet_hdr_required, int mq_required, Error **errp) { - /* FIXME error_setg(errp, ...) on failure */ struct ifreq ifr; int fd, ret; int len = sizeof(struct virtio_net_hdr); @@ -47,7 +46,7 @@ int tap_open(char *ifname, int ifname_size, int *vnet_hdr, TFR(fd = open(PATH_NET_TUN, O_RDWR)); if (fd < 0) { - error_report("could not open %s: %m", PATH_NET_TUN); + error_setg_errno(errp, errno, "could not open %s", PATH_NET_TUN); return -1; } memset(&ifr, 0, sizeof(ifr)); @@ -71,8 +70,8 @@ int tap_open(char *ifname, int ifname_size, int *vnet_hdr, } if (vnet_hdr_required && !*vnet_hdr) { - error_report("vnet_hdr=1 requested, but no kernel " - "support for IFF_VNET_HDR available"); + error_setg(errp, "vnet_hdr=1 requested, but no kernel " + "support for IFF_VNET_HDR available"); close(fd); return -1; } @@ -87,8 +86,8 @@ int tap_open(char *ifname, int ifname_size, int *vnet_hdr, if (mq_required) { if (!(features & IFF_MULTI_QUEUE)) { - error_report("multiqueue required, but no kernel " - "support for IFF_MULTI_QUEUE available"); + error_setg(errp, "multiqueue required, but no kernel " + "support for IFF_MULTI_QUEUE available"); close(fd); return -1; } else { @@ -103,9 +102,11 @@ int tap_open(char *ifname, int ifname_size, int *vnet_hdr, ret = ioctl(fd, TUNSETIFF, (void *) &ifr); if (ret != 0) { if (ifname[0] != '\0') { - error_report("could not configure %s (%s): %m", PATH_NET_TUN, ifr.ifr_name); + error_setg_errno(errp, errno, "could not configure %s (%s)", + PATH_NET_TUN, ifr.ifr_name); } else { - error_report("could not configure %s: %m", PATH_NET_TUN); + error_setg_errno(errp, errno, "could not configure %s", + PATH_NET_TUN); } close(fd); return -1;