From patchwork Mon Aug 6 13:29:33 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: 858585 jemmy X-Patchwork-Id: 10557159 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 2A4BA157B for ; Mon, 6 Aug 2018 13:39:12 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 186F7294D5 for ; Mon, 6 Aug 2018 13:39:12 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 0A75B294EB; Mon, 6 Aug 2018 13:39:12 +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 84574294D5 for ; Mon, 6 Aug 2018 13:39:11 +0000 (UTC) Received: from localhost ([::1]:34163 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fmfj4-0002KI-Ql for patchwork-qemu-devel@patchwork.kernel.org; Mon, 06 Aug 2018 09:39:10 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:49188) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fmfaA-0003KT-Oi for qemu-devel@nongnu.org; Mon, 06 Aug 2018 09:29:59 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fmfa9-0008Hb-S3 for qemu-devel@nongnu.org; Mon, 06 Aug 2018 09:29:58 -0400 Received: from mail-pg1-x542.google.com ([2607:f8b0:4864:20::542]:42904) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fmfa9-0008HI-M4 for qemu-devel@nongnu.org; Mon, 06 Aug 2018 09:29:57 -0400 Received: by mail-pg1-x542.google.com with SMTP id y4-v6so6233467pgp.9 for ; Mon, 06 Aug 2018 06:29:57 -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=NJ8AlY4mjuV9hYO17hGvZ8dmi6Tk0gA05ynUsTBv4Fw=; b=txaRGJzmNB37ACeFnpbG7H6NsYX7i2+dFDAyUTU+ELuwbulyGvQerZiocajKK3R8G7 giC1YyC7B2fpT0n00pYh4bmRUGWrpj+yns8HrGdFGtQt/9cPIYo6UMJ1cgDrwHcjvaF9 4RtAtInU9TB5RoN6BoLnHx2XMsZCZxHg3mpXHYsfQ7G5Lth27yqcD2mEKb5rlMLAa2wS 8LLz61dHQyHbLE/NcBmpQCCWZxqkwf5xPLxXtTz7ET3giQz1a+pMAR+nv6VHRKVhXECR PrM7IOgFjP8qw8kCRKF+Cygv3gw8KPSJxOQ7XV6Xd7ST1USQWTtGmGEtNbew77wNj/uY pT9w== 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=NJ8AlY4mjuV9hYO17hGvZ8dmi6Tk0gA05ynUsTBv4Fw=; b=clEsZSK0zEuOWZ8nDOcJnoccrRiW7/hIwtY6PMRuDoSXyvnZCn1GnO8OFba/W13kaN S41CB4R95BXIJIGutI8iZQzTgacoY9N2c0sLP5jNSAPiHPC532QjUfFE4yj/D4FZ+eeJ ceDNxNI/ii+5yfec6LquDJAAOp14PL7BKp7YpUqcw04FfUz4RVniz4IUxgLJmsV8hFHJ slCp4cLdJW2cVIXe0BYhEsslwkAgUjpChyRCUQbtGiAn8TdtfRy159g158olW1VJ7FAt ceQP+JhBNp+TAaFYpzn4IuurhrQbn6V/+LZ5+cQnU9TqIEOu8lT8Wsq28AslU/tAzTHQ eTxQ== X-Gm-Message-State: AOUpUlEq2amVKDFbj86SBqm5RyNRt/kPPokv1X5klEBC5VQfolm+PSge pvGM4eDrXxux/qR9fPU2CqI= X-Google-Smtp-Source: AAOMgpfSZ7KNh7BU2M9tXaJaueKbDPjMLRHKwHaX5Q5l4Dcy4m43jBR0ysCdsa1qKJ4puYpQR5O6tA== X-Received: by 2002:a62:1b4a:: with SMTP id b71-v6mr16797446pfb.221.1533562196950; Mon, 06 Aug 2018 06:29:56 -0700 (PDT) Received: from VM_120_46_centos.localdomain ([119.28.87.64]) by smtp.gmail.com with ESMTPSA id f11-v6sm11756302pfa.131.2018.08.06.06.29.55 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 06 Aug 2018 06:29:56 -0700 (PDT) From: Lidong Chen X-Google-Original-From: Lidong Chen To: zhang.zhanghailiang@huawei.com, quintela@redhat.com, dgilbert@redhat.com Date: Mon, 6 Aug 2018 21:29:33 +0800 Message-Id: <1533562177-16447-8-git-send-email-lidongchen@tencent.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1533562177-16447-1-git-send-email-lidongchen@tencent.com> References: <1533562177-16447-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:4864:20::542 Subject: [Qemu-devel] [PATCH v6 07/11] 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: Gal Shachaf , Lidong Chen , Aviad Yehezkel , 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 From: Lidong Chen 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 Signed-off-by: Gal Shachaf Signed-off-by: Aviad Yehezkel Reviewed-by: Dr. David Alan Gilbert Reviewed-by: Juan Quintela --- migration/rdma.c | 33 ++++++++++++++++++++++++++++++--- 1 file changed, 30 insertions(+), 3 deletions(-) diff --git a/migration/rdma.c b/migration/rdma.c index d6bbf28..673f126 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;