[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH 16/34] migration: don't rely on QERR_SOCKET_*
From: |
Luiz Capitulino |
Subject: |
[Qemu-devel] [PATCH 16/34] migration: don't rely on QERR_SOCKET_* |
Date: |
Wed, 1 Aug 2012 22:02:36 -0300 |
Use the error code returned by inet_connect() instead. This change
is needed because all QERR_SOCKET_* errors are going to be dropped
by a future commit.
Signed-off-by: Luiz Capitulino <address@hidden>
---
migration-tcp.c | 34 ++++++++++++++++++++--------------
1 file changed, 20 insertions(+), 14 deletions(-)
diff --git a/migration-tcp.c b/migration-tcp.c
index 18944a4..7fe0ffe 100644
--- a/migration-tcp.c
+++ b/migration-tcp.c
@@ -82,27 +82,33 @@ static void tcp_wait_for_connect(void *opaque)
int tcp_start_outgoing_migration(MigrationState *s, const char *host_port,
Error **errp)
{
+ bool in_progress;
+
s->get_error = socket_errno;
s->write = socket_write;
s->close = tcp_close;
- s->fd = inet_connect(host_port, false, NULL, errp);
+ s->fd = inet_connect(host_port, false, &in_progress, errp);
+ if (s->fd < 0) {
+ switch (s->fd) {
+ case -EINVAL:
+ DPRINTF("connect failed\n");
+ return -1;
+ case -ENOTCONN:
+ DPRINTF("connect failed\n");
+ migrate_fd_error(s);
+ return -1;
+ default:
+ DPRINTF("unknown error\n");
+ return -1;
+ }
+ }
- if (!error_is_set(errp)) {
- migrate_fd_connect(s);
- } else if (error_is_type(*errp, QERR_SOCKET_CONNECT_IN_PROGRESS)) {
- DPRINTF("connect in progress\n");
+ if (in_progress) {
qemu_set_fd_handler2(s->fd, NULL, NULL, tcp_wait_for_connect, s);
- } else if (error_is_type(*errp, QERR_SOCKET_CREATE_FAILED)) {
- DPRINTF("connect failed\n");
- return -1;
- } else if (error_is_type(*errp, QERR_SOCKET_CONNECT_FAILED)) {
- DPRINTF("connect failed\n");
- migrate_fd_error(s);
- return -1;
} else {
- DPRINTF("unknown error\n");
- return -1;
+ /* connected */
+ migrate_fd_connect(s);
}
return 0;
--
1.7.11.2.249.g31c7954.dirty
- Re: [Qemu-devel] [PATCH 15/34] net: inet_connect(), inet_connect_opts(): return -errno, (continued)
[Qemu-devel] [PATCH 17/34] qerror: drop QERR_SOCKET_CONNECT_IN_PROGRESS, Luiz Capitulino, 2012/08/01
[Qemu-devel] [PATCH 16/34] migration: don't rely on QERR_SOCKET_*,
Luiz Capitulino <=
[Qemu-devel] [PATCH 09/34] qerror: don't delay error message construction, Luiz Capitulino, 2012/08/01
[Qemu-devel] [PATCH 18/34] error: drop unused functions, Luiz Capitulino, 2012/08/01
[Qemu-devel] [PATCH 21/34] qapi: qapi-types.h: don't include qapi/qapi-types-core.h, Luiz Capitulino, 2012/08/01
[Qemu-devel] [PATCH 19/34] block: block_int: include qerror.h, Luiz Capitulino, 2012/08/01
[Qemu-devel] [PATCH 20/34] hmp: hmp.h: include qdict.h, Luiz Capitulino, 2012/08/01
[Qemu-devel] [PATCH 22/34] qapi: generate correct enum names for camel case enums, Luiz Capitulino, 2012/08/01
[Qemu-devel] [PATCH 23/34] qapi: don't convert enum strings to lowercase, Luiz Capitulino, 2012/08/01
[Qemu-devel] [PATCH 29/34] qmp: switch to the new error format on the wire, Luiz Capitulino, 2012/08/01