Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1F6CDC433E0 for ; Wed, 20 Jan 2021 14:47:18 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 6F80623382 for ; Wed, 20 Jan 2021 14:47:17 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 6F80623382 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=126.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:57806 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1l2ElQ-0008Of-3z for qemu-devel@archiver.kernel.org; Wed, 20 Jan 2021 09:47:16 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:54050) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1l24ur-00085Q-33 for qemu-devel@nongnu.org; Tue, 19 Jan 2021 23:16:21 -0500 Received: from mail-m964.mail.126.com ([123.126.96.4]:43206) by eggs.gnu.org with esmtps (TLS1.2:DHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1l24uk-0004W3-PY for qemu-devel@nongnu.org; Tue, 19 Jan 2021 23:16:20 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=126.com; s=s110527; h=From:Subject:Date:Message-Id; bh=HgFQroAYTO0ekSyc7y 6cIY3yz9vhIpwmkfwFa3ZVz5A=; b=jEAICN5XVgp4mDNpVfa8VfFQNR6fy4YPWH 5mj++Am4Te/8xDpE9VdncLAzKIX/hq8H6clUIojvemqv7pHaGPYvOiqPuma+geA8 t+HTeDhHHA9AyMomlZbL1KG1fKvMVYSPVspaPmXUSPDwIXKjhStgKpJBQqSxgD0G +CxVkqzS8= Received: from localhost.localdomain (unknown [111.205.198.3]) by smtp9 (Coremail) with SMTP id NeRpCgB3cnUjpwdgcpukRA--.20068S3; Wed, 20 Jan 2021 11:44:37 +0800 (CST) From: Bobo Du To: qemu-devel@nongnu.org Subject: [PATCH] vhost-user-blk.c:fix the qemu-kvm crash in the vhost-user-blk env. Date: Wed, 20 Jan 2021 11:44:33 +0800 Message-Id: <20210120034433.50547-1-dubo163@126.com> X-Mailer: git-send-email 2.17.0 X-CM-TRANSID: NeRpCgB3cnUjpwdgcpukRA--.20068S3 X-Coremail-Antispam: 1Uf129KBjvJXoW7Kr43CF47ur43WF13JF15twb_yoW8XrWUpF 1UZr1fKrykGF18C3yDA3WkKF1xAayrAF4UG397Ca4Yy3yUZw4Ivr1q9a90kr48ZFZayF48 JFWUtrW8CF15GaDanT9S1TB71UUUUUUqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDUYxBIdaVFxhVjvjDU0xZFpf9x0zRbAwsUUUUU= X-Originating-IP: [111.205.198.3] X-CM-SenderInfo: 5gxe0iiwt6ij2wof0z/1tbijgUgMFpEBiKiLwAAss Received-SPF: pass client-ip=123.126.96.4; envelope-from=dubo163@126.com; helo=mail-m964.mail.126.com X-Spam_score_int: -17 X-Spam_score: -1.8 X-Spam_bar: - X-Spam_report: (-1.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_ENVFROM_END_DIGIT=0.25, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-Mailman-Approved-At: Wed, 20 Jan 2021 09:45:03 -0500 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Bobo Du Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" In our spdk env, when we restart spdk vhost process, all the spdk vhost dev will be reconnected,if the vhost_user_blk_device_realize failed in the reconnect code goto label with the qemu_chr_fe_wait_connected, the vhost_user_cleanup will set user->chr be NULL,but the fe handler vhost_user_blk_event is still work on the env. If the vhost slave(eg:spdk) has not been done,we will see the qemu-kvm crash after reopen the vhost-user-blk dev: gdb debug info from qemu-kvm-2.10: [Thread debugging using libthread_db enabled] Using host libthread_db library "/lib64/libthread_db.so.1". Core was generated by `/usr/libexec/qemu-kvm -name guest=db1ae942ac9c5486bf93c7baac5fcce6,debug-thread'. Program terminated with signal 11, Segmentation fault. #0 qemu_chr_fe_set_msgfds (be=0x0, fds=0x0, num=0) at chardev/char-fe.c:144 144 Chardev *s = be->chr; So,we must reset the fe handler after the goto label virtio_err. Signed-off-by: Bobo Du --- hw/block/vhost-user-blk.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/hw/block/vhost-user-blk.c b/hw/block/vhost-user-blk.c index da4fbf9084..c90687ab82 100644 --- a/hw/block/vhost-user-blk.c +++ b/hw/block/vhost-user-blk.c @@ -507,6 +507,8 @@ virtio_err: } g_free(s->virtqs); virtio_cleanup(vdev); + qemu_chr_fe_set_handlers(&s->chardev, NULL, NULL, NULL, + NULL, NULL, NULL, false); vhost_user_cleanup(&s->vhost_user); } -- 2.17.0