Next commit wants to use this.

Signed-off-by: Luiz Capitulino <lcapitul...@redhat.com>
---

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


Reply via email to