From patchwork Thu Aug 2 01:02:35 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luiz Capitulino X-Patchwork-Id: 174677 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 8D9312C0087 for ; Thu, 2 Aug 2012 12:53:33 +1000 (EST) Received: from localhost ([::1]:42204 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SwjpC-0004ve-Ha for incoming@patchwork.ozlabs.org; Wed, 01 Aug 2012 21:03:38 -0400 Received: from eggs.gnu.org ([208.118.235.92]:35405) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SwjoO-0003ka-5B for qemu-devel@nongnu.org; Wed, 01 Aug 2012 21:02:49 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1SwjoM-0003I6-8C for qemu-devel@nongnu.org; Wed, 01 Aug 2012 21:02:48 -0400 Received: from mx1.redhat.com ([209.132.183.28]:18601) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SwjoM-0003Hs-0R for qemu-devel@nongnu.org; Wed, 01 Aug 2012 21:02:46 -0400 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id q7212hmE027343 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Wed, 1 Aug 2012 21:02:43 -0400 Received: from localhost (ovpn-113-85.phx2.redhat.com [10.3.113.85]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id q7212gsR025717; Wed, 1 Aug 2012 21:02:43 -0400 From: Luiz Capitulino To: qemu-devel@nongnu.org Date: Wed, 1 Aug 2012 22:02:35 -0300 Message-Id: <1343869374-23417-16-git-send-email-lcapitulino@redhat.com> In-Reply-To: <1343869374-23417-1-git-send-email-lcapitulino@redhat.com> References: <1343869374-23417-1-git-send-email-lcapitulino@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.24 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 209.132.183.28 Cc: kwolf@redhat.com, aliguori@us.ibm.com, armbru@redhat.com, mdroth@linux.vnet.ibm.com, pbonzini@redhat.com, eblake@redhat.com Subject: [Qemu-devel] [PATCH 15/34] net: inet_connect(), inet_connect_opts(): return -errno 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 Next commit wants to use this. Signed-off-by: Luiz Capitulino --- This patch is an interesting case, because one of the goal of the error format that's being replaced was that callers could use it to know the error cause (with error_is_type(). However, the new error format doesn't allow this as most errors are class GenericError. So, we'll have to use errno to know the error cause, this is the case of inet_connect() when called by tcp_start_outgoing_migration(). qemu-sockets.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/qemu-sockets.c b/qemu-sockets.c index 33b65cf..82f4736 100644 --- a/qemu-sockets.c +++ b/qemu-sockets.c @@ -234,7 +234,7 @@ int inet_connect_opts(QemuOpts *opts, bool *in_progress, Error **errp) if (addr == NULL || port == NULL) { fprintf(stderr, "inet_connect: host and/or port not specified\n"); error_set(errp, QERR_SOCKET_CREATE_FAILED); - return -1; + return -EINVAL; } if (qemu_opt_get_bool(opts, "ipv4", 0)) @@ -247,7 +247,7 @@ int inet_connect_opts(QemuOpts *opts, bool *in_progress, Error **errp) fprintf(stderr,"getaddrinfo(%s,%s): %s\n", addr, port, gai_strerror(rc)); error_set(errp, QERR_SOCKET_CREATE_FAILED); - return -1; + return -EINVAL; } for (e = res; e != NULL; e = e->ai_next) { @@ -300,7 +300,7 @@ int inet_connect_opts(QemuOpts *opts, bool *in_progress, Error **errp) } error_set(errp, QERR_SOCKET_CONNECT_FAILED); freeaddrinfo(res); - return -1; + return -ENOTCONN; } int inet_dgram_opts(QemuOpts *opts) @@ -508,6 +508,7 @@ int inet_connect(const char *str, bool block, bool *in_progress, Error **errp) } sock = inet_connect_opts(opts, in_progress, errp); } else { + sock = -EINVAL; error_set(errp, QERR_SOCKET_CREATE_FAILED); } qemu_opts_del(opts);