From nobody Wed Nov 5 16:57:11 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; 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 Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 153719225241441.71645568221754; Mon, 17 Sep 2018 06:50:52 -0700 (PDT) Received: from localhost ([::1]:35689 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1g1tvM-0003z5-86 for importer@patchew.org; Mon, 17 Sep 2018 09:50:48 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52933) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1g1tty-0003NL-U3 for qemu-devel@nongnu.org; Mon, 17 Sep 2018 09:49:23 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1g1ttt-0002o4-5v for qemu-devel@nongnu.org; Mon, 17 Sep 2018 09:49:22 -0400 Received: from szxga06-in.huawei.com ([45.249.212.32]:52913 helo=huawei.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1g1tts-0002VB-Lo; Mon, 17 Sep 2018 09:49:17 -0400 Received: from DGGEMS408-HUB.china.huawei.com (unknown [172.30.72.60]) by Forcepoint Email with ESMTP id 0DC4EACC4AD21; Mon, 17 Sep 2018 21:49:04 +0800 (CST) Received: from localhost (10.177.68.90) by DGGEMS408-HUB.china.huawei.com (10.3.19.208) with Microsoft SMTP Server id 14.3.399.0; Mon, 17 Sep 2018 21:48:54 +0800 From: liujunjie To: , Date: Mon, 17 Sep 2018 21:48:45 +0800 Message-ID: <20180917134845.12908-1-liujunjie23@huawei.com> X-Mailer: git-send-email 2.13.3.windows.1 MIME-Version: 1.0 X-Originating-IP: [10.177.68.90] X-CFilter-Loop: Reflected X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [fuzzy] X-Received-From: 45.249.212.32 Subject: [Qemu-devel] [PATCH v2] clean up callback when del virtqueue 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: weidong.huang@huawei.com, liujunjie , wangxinxin.wang@huawei.com, qemu-devel@nongnu.org, qemu-stable@nongnu.org, arei.gonglei@huawei.com, jianjay.zhou@huawei.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Before, we did not clear callback like handle_output when delete the virtqueue which may result be segmentfault. The scene is as follows: 1. Start a vm with multiqueue vhost-net, 2. then we write VIRTIO_PCI_GUEST_FEATURES in PCI configuration to triger multiqueue disable in this vm which will delete the virtqueue. In this step, the tx_bh is deleted but the callback virtio_net_handle_tx_bh still exist. 3. Finally, we write VIRTIO_PCI_QUEUE_NOTIFY in PCI configuration to notify the deleted virtqueue. In this way, virtio_net_handle_tx_bh will be called and qemu will be crashed. Although the way described above is uncommon, we had better reinforce it. Signed-off-by: liujunjie --- hw/virtio/virtio.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/hw/virtio/virtio.c b/hw/virtio/virtio.c index d4e4d98..dc8dcf8 100644 --- a/hw/virtio/virtio.c +++ b/hw/virtio/virtio.c @@ -1604,6 +1604,8 @@ void virtio_del_queue(VirtIODevice *vdev, int n) =20 vdev->vq[n].vring.num =3D 0; vdev->vq[n].vring.num_default =3D 0; + vdev->vq[n].handle_output =3D NULL; + vdev->vq[n].handle_aio_output =3D NULL; } =20 static void virtio_set_isr(VirtIODevice *vdev, int value) --=20 1.8.3.1