From mboxrd@z Thu Jan 1 00:00:00 1970 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 From: Luiz Capitulino 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> Subject: [Qemu-devel] [PATCH 15/34] net: inet_connect(), inet_connect_opts(): return -errno List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: kwolf@redhat.com, aliguori@us.ibm.com, armbru@redhat.com, mdroth@linux.vnet.ibm.com, pbonzini@redhat.com, eblake@redhat.com 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); -- 1.7.11.2.249.g31c7954.dirty