From patchwork Tue Aug 7 15:53:26 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luiz Capitulino X-Patchwork-Id: 175719 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 1DB9E2C00AD for ; Wed, 8 Aug 2012 02:23:59 +1000 (EST) Received: from localhost ([::1]:35544 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SymZZ-0001l1-4b for incoming@patchwork.ozlabs.org; Tue, 07 Aug 2012 12:23:57 -0400 Received: from eggs.gnu.org ([208.118.235.92]:46951) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Sym6T-00067Q-8p for qemu-devel@nongnu.org; Tue, 07 Aug 2012 11:53:59 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Sym6O-0005cA-OB for qemu-devel@nongnu.org; Tue, 07 Aug 2012 11:53:53 -0400 Received: from mx1.redhat.com ([209.132.183.28]:32101) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Sym6O-0005c2-EG for qemu-devel@nongnu.org; Tue, 07 Aug 2012 11:53:48 -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 q77FrkK4030687 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Tue, 7 Aug 2012 11:53:46 -0400 Received: from localhost (ovpn-113-157.phx2.redhat.com [10.3.113.157]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id q77FrjgK031694; Tue, 7 Aug 2012 11:53:45 -0400 From: Luiz Capitulino To: qemu-devel@nongnu.org Date: Tue, 7 Aug 2012 12:53:26 -0300 Message-Id: <1344354826-10375-16-git-send-email-lcapitulino@redhat.com> In-Reply-To: <1344354826-10375-1-git-send-email-lcapitulino@redhat.com> References: <1344354826-10375-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/35] migration: don't rely on any QERR_SOCKET_* 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 Use the in_progress argument for QERR_SOCKET_CONNECT_IN_PROGRESS. The other errors are handled the same by checking if the error is set and then calling migrate_fd_error() if it's. It's also necessary to change inet_connect_opts() not to set QERR_SOCKET_CONNECT_IN_PROGRESS. This error is only used by tcp_start_outgoing_migration() and not changing it along with the usage of in_progress would break migration. Furthermore this commit fixes a bug. Today, there's a spurious error report when migration succeeds: (qemu) migrate tcp:0:4444 migrate: Connection can not be completed immediately (qemu) After this commit no spurious error is reported anymore. Signed-off-by: Luiz Capitulino --- migration-tcp.c | 22 ++++++++-------------- qemu-sockets.c | 2 -- 2 files changed, 8 insertions(+), 16 deletions(-) diff --git a/migration-tcp.c b/migration-tcp.c index 18944a4..40c277f 100644 --- a/migration-tcp.c +++ b/migration-tcp.c @@ -82,27 +82,21 @@ 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); - - 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"); - 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"); + s->fd = inet_connect(host_port, false, &in_progress, errp); + if (error_is_set(errp)) { migrate_fd_error(s); return -1; + } else if (in_progress) { + DPRINTF("connect in progress\n"); + qemu_set_fd_handler2(s->fd, NULL, NULL, tcp_wait_for_connect, s); } else { - DPRINTF("unknown error\n"); - return -1; + migrate_fd_connect(s); } return 0; diff --git a/qemu-sockets.c b/qemu-sockets.c index 9cb47d4..361d890 100644 --- a/qemu-sockets.c +++ b/qemu-sockets.c @@ -284,8 +284,6 @@ int inet_connect_opts(QemuOpts *opts, bool *in_progress, Error **errp) if (in_progress) { *in_progress = true; } - - error_set(errp, QERR_SOCKET_CONNECT_IN_PROGRESS); } else if (rc < 0) { if (NULL == e->ai_next) fprintf(stderr, "%s: connect(%s,%s,%s,%s): %s\n", __FUNCTION__,