|
@@ -82,27 +82,23 @@ static void tcp_wait_for_connect(void *opaque)
|
|
int tcp_start_outgoing_migration(MigrationState *s, const char *host_port,
|
|
int tcp_start_outgoing_migration(MigrationState *s, const char *host_port,
|
|
Error **errp)
|
|
Error **errp)
|
|
{
|
|
{
|
|
|
|
+ bool in_progress;
|
|
|
|
+
|
|
s->get_error = socket_errno;
|
|
s->get_error = socket_errno;
|
|
s->write = socket_write;
|
|
s->write = socket_write;
|
|
s->close = tcp_close;
|
|
s->close = tcp_close;
|
|
|
|
|
|
- s->fd = inet_connect(host_port, false, NULL, errp);
|
|
|
|
|
|
+ s->fd = inet_connect(host_port, false, &in_progress, errp);
|
|
|
|
+ if (error_is_set(errp)) {
|
|
|
|
+ migrate_fd_error(s);
|
|
|
|
+ return -1;
|
|
|
|
+ }
|
|
|
|
|
|
- if (!error_is_set(errp)) {
|
|
|
|
- migrate_fd_connect(s);
|
|
|
|
- } else if (error_is_type(*errp, QERR_SOCKET_CONNECT_IN_PROGRESS)) {
|
|
|
|
|
|
+ if (in_progress) {
|
|
DPRINTF("connect in progress\n");
|
|
DPRINTF("connect in progress\n");
|
|
qemu_set_fd_handler2(s->fd, NULL, NULL, tcp_wait_for_connect, s);
|
|
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 {
|
|
} else {
|
|
- DPRINTF("unknown error\n");
|
|
|
|
- return -1;
|
|
|
|
|
|
+ migrate_fd_connect(s);
|
|
}
|
|
}
|
|
|
|
|
|
return 0;
|
|
return 0;
|