From patchwork Mon Aug 6 13:29:34 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: 858585 jemmy X-Patchwork-Id: 10557151 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 1A5F3157D for ; Mon, 6 Aug 2018 13:34:56 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 08D0229502 for ; Mon, 6 Aug 2018 13:34:56 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id F16FA29538; Mon, 6 Aug 2018 13:34:55 +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 CC03729502 for ; Mon, 6 Aug 2018 13:34:54 +0000 (UTC) Received: from localhost ([::1]:34136 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fmfew-0007dc-1A for patchwork-qemu-devel@patchwork.kernel.org; Mon, 06 Aug 2018 09:34:54 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:49200) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fmfaC-0003Md-RL for qemu-devel@nongnu.org; Mon, 06 Aug 2018 09:30:02 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fmfaB-0008IC-OE for qemu-devel@nongnu.org; Mon, 06 Aug 2018 09:30:00 -0400 Received: from mail-pg1-x535.google.com ([2607:f8b0:4864:20::535]:33953) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fmfaB-0008I0-GB for qemu-devel@nongnu.org; Mon, 06 Aug 2018 09:29:59 -0400 Received: by mail-pg1-x535.google.com with SMTP id y5-v6so6251375pgv.1 for ; Mon, 06 Aug 2018 06:29:59 -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=UaUc+NfHOvncluzDJkjXLlo2mSi7ZcHceZZz9mI6xM4=; b=fCo/GFr+J/6bt2OPOLXZQDnwfWAaVX5epXI9I5GOUbd7Qz6RhdpAIa2lq5HYcuPHiZ n6a//5mvmu3WhJkB4FY0Y76bIoM/0Oy6C4YhXAA1SNsgzNdyIG0G1fYEfXr80x32Fj8b VPM6j7Av/hpOYqzNKfKr7DaDwWwMtqJBgKUSU6kDkbudBDFzFPrQxtnIxjrMQbFGBSWA cGfTLiVnZaPr4g976iL0uhVZMxERrjWMm6ZaiG0rTA9Z3C2xa+K9IN99x9G1gwd9m9Iu z80axT09CIXhm3r3qeoQuNnpDCEkyHWt4dErgNplU6z/kNQB5SvsbOtUAMiaHCtvda46 k36g== 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=UaUc+NfHOvncluzDJkjXLlo2mSi7ZcHceZZz9mI6xM4=; b=K5cG44lrF57UCxJgwXTAjH30vVQvVlUP0+N19hi7Pwol/MC6CS1yye3f9oNisyZQAX PJFigiZiV0tt+GuDotnUxed+IcYO/Pq4CbEfCdao3KI5cmLBdEHElFYCC77hz2+WQz1a /wHoGNlWpfgNPGG2jmxOz4rj7J1ers1guFgZ6nsjgjolxJi84bJUhKsFK82JmKe5mYr0 WFLgPQ/LSZHXp9FYKW8RNDtqafUgvhsLqMOMEfrz7HgN4sPfclbXmjbPYjKScZTbai/L HgZO/kczWHILr3xry6PiemMJSjJazEDJ8vs/pwIjI2ZUSLQHbh9pBF5G2kCA3zb3Aj96 2dZg== X-Gm-Message-State: AOUpUlF/8SxsgkTfPDp388R+yon34jzXl8QT7/bU01vYCPm1Vuu0eXpd efVUV3NAo5o9ITv1m1T0Gbg= X-Google-Smtp-Source: AAOMgpe45al1Ai27lRzScf9F5kjPAKnK8NYZZIU7WK4nkm16InwQPzi4cs8XrVq7c1u65dSPWv+DRQ== X-Received: by 2002:aa7:8713:: with SMTP id b19-v6mr17081155pfo.151.1533562198669; Mon, 06 Aug 2018 06:29:58 -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.57 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 06 Aug 2018 06:29:58 -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:34 +0800 Message-Id: <1533562177-16447-9-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::535 Subject: [Qemu-devel] [PATCH v6 08/11] migration: implement the shutdown for RDMA QIOChannel 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: Lidong Chen , 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 Because RDMA QIOChannel not implement shutdown function, If the to_dst_file was set error, the return path thread will wait forever. and the migration thread will wait return path thread exit. the backtrace of return path thread is: (gdb) bt #0 0x00007f372a76bb0f in ppoll () from /lib64/libc.so.6 #1 0x000000000071dc24 in qemu_poll_ns (fds=0x7ef7091d0580, nfds=2, timeout=100000000) at qemu-timer.c:325 #2 0x00000000006b2fba in qemu_rdma_wait_comp_channel (rdma=0xd424000) at migration/rdma.c:1501 #3 0x00000000006b3191 in qemu_rdma_block_for_wrid (rdma=0xd424000, wrid_requested=4000, byte_len=0x7ef7091d0640) at migration/rdma.c:1580 #4 0x00000000006b3638 in qemu_rdma_exchange_get_response (rdma=0xd424000, head=0x7ef7091d0720, expecting=3, idx=0) at migration/rdma.c:1726 #5 0x00000000006b3ad6 in qemu_rdma_exchange_recv (rdma=0xd424000, head=0x7ef7091d0720, expecting=3) at migration/rdma.c:1903 #6 0x00000000006b5d03 in qemu_rdma_get_buffer (opaque=0x6a57dc0, buf=0x5c80030 "", pos=8, size=32768) at migration/rdma.c:2714 #7 0x00000000006a9635 in qemu_fill_buffer (f=0x5c80000) at migration/qemu-file.c:232 #8 0x00000000006a9ecd in qemu_peek_byte (f=0x5c80000, offset=0) at migration/qemu-file.c:502 #9 0x00000000006a9f1f in qemu_get_byte (f=0x5c80000) at migration/qemu-file.c:515 #10 0x00000000006aa162 in qemu_get_be16 (f=0x5c80000) at migration/qemu-file.c:591 #11 0x00000000006a46d3 in source_return_path_thread ( opaque=0xd826a0 ) at migration/migration.c:1331 #12 0x00007f372aa49e25 in start_thread () from /lib64/libpthread.so.0 #13 0x00007f372a77635d in clone () from /lib64/libc.so.6 the backtrace of migration thread is: (gdb) bt #0 0x00007f372aa4af57 in pthread_join () from /lib64/libpthread.so.0 #1 0x00000000007d5711 in qemu_thread_join (thread=0xd826f8 ) at util/qemu-thread-posix.c:504 #2 0x00000000006a4bc5 in await_return_path_close_on_source ( ms=0xd826a0 ) at migration/migration.c:1460 #3 0x00000000006a53e4 in migration_completion (s=0xd826a0 , current_active_state=4, old_vm_running=0x7ef7089cf976, start_time=0x7ef7089cf980) at migration/migration.c:1695 #4 0x00000000006a5c54 in migration_thread (opaque=0xd826a0 ) at migration/migration.c:1837 #5 0x00007f372aa49e25 in start_thread () from /lib64/libpthread.so.0 #6 0x00007f372a77635d in clone () from /lib64/libc.so.6 Signed-off-by: Lidong Chen Reviewed-by: Dr. David Alan Gilbert Reviewed-by: Juan Quintela --- migration/rdma.c | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/migration/rdma.c b/migration/rdma.c index 673f126..1affc46 100644 --- a/migration/rdma.c +++ b/migration/rdma.c @@ -3039,6 +3039,45 @@ static int qio_channel_rdma_close(QIOChannel *ioc, return 0; } +static int +qio_channel_rdma_shutdown(QIOChannel *ioc, + QIOChannelShutdown how, + Error **errp) +{ + QIOChannelRDMA *rioc = QIO_CHANNEL_RDMA(ioc); + RDMAContext *rdmain, *rdmaout; + + rcu_read_lock(); + + rdmain = atomic_rcu_read(&rioc->rdmain); + rdmaout = atomic_rcu_read(&rioc->rdmain); + + switch (how) { + case QIO_CHANNEL_SHUTDOWN_READ: + if (rdmain) { + rdmain->error_state = -1; + } + break; + case QIO_CHANNEL_SHUTDOWN_WRITE: + if (rdmaout) { + rdmaout->error_state = -1; + } + break; + case QIO_CHANNEL_SHUTDOWN_BOTH: + default: + if (rdmain) { + rdmain->error_state = -1; + } + if (rdmaout) { + rdmaout->error_state = -1; + } + break; + } + + rcu_read_unlock(); + return 0; +} + /* * Parameters: * @offset == 0 : @@ -3865,6 +3904,7 @@ static void qio_channel_rdma_class_init(ObjectClass *klass, ioc_klass->io_close = qio_channel_rdma_close; ioc_klass->io_create_watch = qio_channel_rdma_create_watch; ioc_klass->io_set_aio_fd_handler = qio_channel_rdma_set_aio_fd_handler; + ioc_klass->io_shutdown = qio_channel_rdma_shutdown; } static const TypeInfo qio_channel_rdma_info = {