From patchwork Tue Jun 5 15:28:08 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: 858585 jemmy X-Patchwork-Id: 10448505 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 5459260284 for ; Tue, 5 Jun 2018 15:38:13 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3719F297CD for ; Tue, 5 Jun 2018 15:38:13 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 34F1629848; Tue, 5 Jun 2018 15:38:13 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.8 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 737EE2A183 for ; Tue, 5 Jun 2018 15:32:58 +0000 (UTC) Received: from localhost ([::1]:47530 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fQDxB-00046O-IC for patchwork-qemu-devel@patchwork.kernel.org; Tue, 05 Jun 2018 11:32:57 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:40222) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fQDt7-0008Mw-21 for qemu-devel@nongnu.org; Tue, 05 Jun 2018 11:28:45 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fQDt3-0003yg-Ek for qemu-devel@nongnu.org; Tue, 05 Jun 2018 11:28:45 -0400 Received: from mail-pl0-x241.google.com ([2607:f8b0:400e:c01::241]:41292) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fQDt3-0003yN-9K for qemu-devel@nongnu.org; Tue, 05 Jun 2018 11:28:41 -0400 Received: by mail-pl0-x241.google.com with SMTP id az12-v6so1722726plb.8 for ; Tue, 05 Jun 2018 08:28:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=+pUg748FIAj70423DtRMW7r7pF08+rU+AmRIjUoxV9Y=; b=So1QoFYHoj2cjXRPoLhE8viprzo0p/DxAjKDn+SNKSJbq++wVsnqYmO/BhN/YuC0XW UzPUAOVN7MMgEObShHqKi1J6UGMO6fzRBQENBoAYMGfDYn6nv1lzOPaBj3Uv5NpENO14 7zNd7W9pxuOjYJimUMiVeNvt7Empg4A7uZZK6fEG/9XlM+pb3kTwwqpwz/SR12f9cbGS nLhJuADNILcqQ+lUy7VZWC8jNrd+8KcksPXQkPLfqtN27mkJJzil2hN1SpTKL8L+K3xZ kXtECsoUsbxX70tr8pdLtWRSRxaPSrOzHZHq7/rDjV34O6gd16/kAbhadEsrHFpVSc/C aZeQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=+pUg748FIAj70423DtRMW7r7pF08+rU+AmRIjUoxV9Y=; b=UaoR80Z9WUNmwL18L5+vJsslOYDOku/ZSTGxvXy34dSmi20HWHnYwkcLVs/BkDMHM0 K91MmslJVokyn/zk8ormC/mfwf3r5wrG/DFi9h4XJtiQ3jwcZjzrqMmfmAJKEtzERY8f CiNRF20f6f0sEVRBpyNNYtL4OGq01Uzb19vK86fxbk+7q/x4aoaNVENikGupfiwFH6QU 0/Wfi2Rk2yU+AvaHfS+kpCT4b+PNYWPvAE4wZZpNnM78gfFkP0ogiLbu4KyXwFrMlUlJ QJFLHaaP19vsI6vEZ8vIqSrw8fKjayLrjBX8hxQLou8m/1w2op6gUEQH0YV9wAVfclHZ Sk3w== X-Gm-Message-State: ALKqPwdR/l9QghTKY4t9OX6f/pcRiFQ6VZoimLg4EcGd5aowErSQ7pk4 W3VWaVqqpnUNkXjnzsYgCqQ= X-Google-Smtp-Source: ADUXVKIsM7i08X5XNzR1opTpXrDfCtI4VappSLG226tAX/uWaJZkQbtasBQiJ6r41uait3IGJE+eGw== X-Received: by 2002:a17:902:a416:: with SMTP id p22-v6mr26650587plq.228.1528212520472; Tue, 05 Jun 2018 08:28:40 -0700 (PDT) Received: from VM_93_245_centos.localdomain ([150.109.57.149]) by smtp.gmail.com with ESMTPSA id t14-v6sm101952007pfh.109.2018.06.05.08.28.38 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 05 Jun 2018 08:28:39 -0700 (PDT) From: Lidong Chen X-Google-Original-From: Lidong Chen To: zhang.zhanghailiang@huawei.com, quintela@redhat.com, dgilbert@redhat.com, berrange@redhat.com, aviadye@mellanox.com, pbonzini@redhat.com Date: Tue, 5 Jun 2018 23:28:08 +0800 Message-Id: <1528212489-19137-10-git-send-email-lidongchen@tencent.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1528212489-19137-1-git-send-email-lidongchen@tencent.com> References: <1528212489-19137-1-git-send-email-lidongchen@tencent.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400e:c01::241 Subject: [Qemu-devel] [PATCH v5 09/10] migration: poll the cm event while wait RDMA work request completion X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: galsha@mellanox.com, adido@mellanox.com, qemu-devel@nongnu.org, Lidong Chen Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP If the peer qemu is crashed, the qemu_rdma_wait_comp_channel function maybe loop forever. so we should also poll the cm event fd, and when receive RDMA_CM_EVENT_DISCONNECTED and RDMA_CM_EVENT_DEVICE_REMOVAL, we consider some error happened. Signed-off-by: Lidong Chen --- migration/rdma.c | 33 ++++++++++++++++++++++++++++++--- 1 file changed, 30 insertions(+), 3 deletions(-) diff --git a/migration/rdma.c b/migration/rdma.c index f12e8d5..bb6989e 100644 --- a/migration/rdma.c +++ b/migration/rdma.c @@ -1489,6 +1489,9 @@ static uint64_t qemu_rdma_poll(RDMAContext *rdma, uint64_t *wr_id_out, */ static int qemu_rdma_wait_comp_channel(RDMAContext *rdma) { + struct rdma_cm_event *cm_event; + int ret = -1; + /* * Coroutine doesn't start until migration_fd_process_incoming() * so don't yield unless we know we're running inside of a coroutine. @@ -1505,13 +1508,37 @@ static int qemu_rdma_wait_comp_channel(RDMAContext *rdma) * without hanging forever. */ while (!rdma->error_state && !rdma->received_error) { - GPollFD pfds[1]; + GPollFD pfds[2]; pfds[0].fd = rdma->comp_channel->fd; pfds[0].events = G_IO_IN | G_IO_HUP | G_IO_ERR; + pfds[0].revents = 0; + + pfds[1].fd = rdma->channel->fd; + pfds[1].events = G_IO_IN | G_IO_HUP | G_IO_ERR; + pfds[1].revents = 0; + /* 0.1s timeout, should be fine for a 'cancel' */ - switch (qemu_poll_ns(pfds, 1, 100 * 1000 * 1000)) { + switch (qemu_poll_ns(pfds, 2, 100 * 1000 * 1000)) { + case 2: case 1: /* fd active */ - return 0; + if (pfds[0].revents) { + return 0; + } + + if (pfds[1].revents) { + ret = rdma_get_cm_event(rdma->channel, &cm_event); + if (!ret) { + rdma_ack_cm_event(cm_event); + } + + error_report("receive cm event while wait comp channel," + "cm event is %d", cm_event->event); + if (cm_event->event == RDMA_CM_EVENT_DISCONNECTED || + cm_event->event == RDMA_CM_EVENT_DEVICE_REMOVAL) { + return -EPIPE; + } + } + break; case 0: /* Timeout, go around again */ break;