From nobody Sun Nov 2 11:47:01 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=gmail.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1527673911335834.8537956193876; Wed, 30 May 2018 02:51:51 -0700 (PDT) Received: from localhost ([::1]:37276 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fNxlj-0005uf-Dm for importer@patchew.org; Wed, 30 May 2018 05:51:47 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:40481) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fNxeZ-0000f5-U2 for qemu-devel@nongnu.org; Wed, 30 May 2018 05:44:25 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fNxeW-0006vm-P1 for qemu-devel@nongnu.org; Wed, 30 May 2018 05:44:23 -0400 Received: from mail-pl0-x241.google.com ([2607:f8b0:400e:c01::241]:34650) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fNxeW-0006va-H8 for qemu-devel@nongnu.org; Wed, 30 May 2018 05:44:20 -0400 Received: by mail-pl0-x241.google.com with SMTP id ay10-v6so10767801plb.1 for ; Wed, 30 May 2018 02:44:20 -0700 (PDT) Received: from VM_93_245_centos.localdomain ([150.109.57.149]) by smtp.gmail.com with ESMTPSA id 29-v6sm60565257pfj.14.2018.05.30.02.44.17 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 30 May 2018 02:44:19 -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=11VfxFQD7s5h6U1r0LB5IYQubrSVzc6pJoMQOfiI8xk=; b=PdOhgZ+lifBqtjIz/NSKWR4K7kRFG5425lf6Cq+/L9cu9fEK3CTzrDTVFC1/VLWKS8 D7iRpYO5dkoIxa9FLLfwPrMRUlcVEbzTMnxdonBsF1X/jJG6w5tzs+XLvaM3PYYih0Wa pKUfr++9rR05H4AaDxWDjBlxm7Xg4aoAUoTu4JDbBGg07wjBSPDH79WV4eI5Zk/pZ4FF 1jPEhFc0kToCBPpmyD81W5nIvJEKmcXquAqWk1hgUepQtDLZ4mbeJ0M4DzJanW14UloZ K72zV2Y+q4027isdzSBQLlQyCwWW+BLgJeQvIcGTVViMXXu5XrV1sRabw08pxOHxtad5 HKnQ== 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=11VfxFQD7s5h6U1r0LB5IYQubrSVzc6pJoMQOfiI8xk=; b=jaHiJDOa8olLD/lRi8qP0uLzIKrJ2gEtZcRjEoJV4n5SbnrxEzU5ciyrUN0EM6jUaQ zkZZnNiCxFHDRk/y0N0CS/ZChrHgo4mzsBAI2xrcVs8+rEkWO1+Oh0vEycfbj0TzHiTs sLgxG86j6q+blRNXzq8+Cdm2d/KVdj/LQqR3o0DWd3Fu8rqj0opHo1YwMIn4lDIZoNHX Oi2MYb1qvVKSFfwXOxABfP4TRVzG7Io5ClfmRG946H+apLIeKtOsgUlwEXRaeWt3DepA fqEwgqmz8g4g/0OjKFO4kAj+FswjC/85aJxks+OskbOB1nbeisSK81UXCCgFlm1SSmus fjcw== X-Gm-Message-State: ALKqPwf+w8J2kHjeAjA4mWUTktqBMwzJPjq/uARXVAsXtllqIsJtNp29 qw2KrL3CY/TvnwATFPX1NxFH2g== X-Google-Smtp-Source: ADUXVKI4ddPxEhhbaCAmNb+puFHlGB9+fP7xBItjRuShQpwV9vuNvPYyeZyCiHwxCzrhaxPeOvnU0Q== X-Received: by 2002:a17:902:4c88:: with SMTP id b8-v6mr2104421ple.285.1527673459683; Wed, 30 May 2018 02:44:19 -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: Wed, 30 May 2018 17:43:36 +0800 Message-Id: <1527673416-31268-13-git-send-email-lidongchen@tencent.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1527673416-31268-1-git-send-email-lidongchen@tencent.com> References: <1527673416-31268-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 v4 12/12] 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: adido@mellanox.com, qemu-devel@nongnu.org, Lidong Chen Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" 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=3D0x7ef7091d0580, nfds=3D2,= timeout=3D100000000) at qemu-timer.c:325 #2 0x00000000006b2fba in qemu_rdma_wait_comp_channel (rdma=3D0xd424000) at migration/rdma.c:1501 #3 0x00000000006b3191 in qemu_rdma_block_for_wrid (rdma=3D0xd424000, w= rid_requested=3D4000, byte_len=3D0x7ef7091d0640) at migration/rdma.c:1580 #4 0x00000000006b3638 in qemu_rdma_exchange_get_response (rdma=3D0xd42= 4000, head=3D0x7ef7091d0720, expecting=3D3, idx=3D0) at migration/rdma.c:= 1726 #5 0x00000000006b3ad6 in qemu_rdma_exchange_recv (rdma=3D0xd424000, he= ad=3D0x7ef7091d0720, expecting=3D3) at migration/rdma.c:1903 #6 0x00000000006b5d03 in qemu_rdma_get_buffer (opaque=3D0x6a57dc0, buf= =3D0x5c80030 "", pos=3D8, size=3D32768) at migration/rdma.c:2714 #7 0x00000000006a9635 in qemu_fill_buffer (f=3D0x5c80000) at migration= /qemu-file.c:232 #8 0x00000000006a9ecd in qemu_peek_byte (f=3D0x5c80000, offset=3D0) at migration/qemu-file.c:502 #9 0x00000000006a9f1f in qemu_get_byte (f=3D0x5c80000) at migration/qe= mu-file.c:515 #10 0x00000000006aa162 in qemu_get_be16 (f=3D0x5c80000) at migration/qe= mu-file.c:591 #11 0x00000000006a46d3 in source_return_path_thread ( opaque=3D0xd826a0 ) 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=3D0xd826f8 ) at util/qemu-thread-posix.c:504 #2 0x00000000006a4bc5 in await_return_path_close_on_source ( ms=3D0xd826a0 ) at migration/migration.c:1= 460 #3 0x00000000006a53e4 in migration_completion (s=3D0xd826a0 , current_active_state=3D4, old_vm_running=3D0x7ef7089cf976, start_ti= me=3D0x7ef7089cf980) at migration/migration.c:1695 #4 0x00000000006a5c54 in migration_thread (opaque=3D0xd826a0 ) 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 --- migration/rdma.c | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/migration/rdma.c b/migration/rdma.c index d611a06..0912b6a 100644 --- a/migration/rdma.c +++ b/migration/rdma.c @@ -3038,6 +3038,45 @@ static int qio_channel_rdma_close(QIOChannel *ioc, return 0; } =20 +static int +qio_channel_rdma_shutdown(QIOChannel *ioc, + QIOChannelShutdown how, + Error **errp) +{ + QIOChannelRDMA *rioc =3D QIO_CHANNEL_RDMA(ioc); + RDMAContext *rdmain, *rdmaout; + + rcu_read_lock(); + + rdmain =3D atomic_rcu_read(&rioc->rdmain); + rdmaout =3D atomic_rcu_read(&rioc->rdmain); + + switch (how) { + case QIO_CHANNEL_SHUTDOWN_READ: + if (rdmain) { + rdmain->error_state =3D -1; + } + break; + case QIO_CHANNEL_SHUTDOWN_WRITE: + if (rdmaout) { + rdmaout->error_state =3D -1; + } + break; + case QIO_CHANNEL_SHUTDOWN_BOTH: + default: + if (rdmain) { + rdmain->error_state =3D -1; + } + if (rdmaout) { + rdmaout->error_state =3D -1; + } + break; + } + + rcu_read_unlock(); + return 0; +} + /* * Parameters: * @offset =3D=3D 0 : @@ -3864,6 +3903,7 @@ static void qio_channel_rdma_class_init(ObjectClass *= klass, ioc_klass->io_close =3D qio_channel_rdma_close; ioc_klass->io_create_watch =3D qio_channel_rdma_create_watch; ioc_klass->io_set_aio_fd_handler =3D qio_channel_rdma_set_aio_fd_handl= er; + ioc_klass->io_shutdown =3D qio_channel_rdma_shutdown; } =20 static const TypeInfo qio_channel_rdma_info =3D { --=20 1.8.3.1