From nobody Wed Nov 19 18:41:44 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1702539421; cv=none; d=zohomail.com; s=zohoarc; b=amep/maxV+D5D6fIq8wZcPmtzz5cZ3W9yUstclMRF4e7iHdusBQZH7cQBda85XJPLT59x5uaCK94Q7HWZ2KgrO7yLAXL+c71Ql9Q66N3TpAlQtgoGSmzgISAdXxnJGYhen7/icP5nE9uNC4uS5QuMY5na4LHs9+j1F6WW3Oh+MM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1702539421; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:Reply-To:Sender:Subject:Subject:To:To:Message-Id; bh=kL206Aa2VQ5V0afO8R4q7N7GpAfsDrcBuZu4eKLaS3Q=; b=d51+Vxv4oZ2cOn6ngbHKkicQowmhpAHg4kO5JUF0Ab8ysq6lKzROKI4iGKREXjp4/htd69E5o8HjJ3IVT3g0kKGJjGOZ+Mytzpeehqg2WpkPWbTw6pKGNe0ruhKuUDsPJtPgi2YwMQowdbeof39e9pXK6Q35BDXlnj97O2EwGnU= ARC-Authentication-Results: i=1; mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1702539421504396.4099720813356; Wed, 13 Dec 2023 23:37:01 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rDgGL-0000g4-VV; Thu, 14 Dec 2023 02:36:06 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rDgGK-0000fg-Ar for qemu-devel@nongnu.org; Thu, 14 Dec 2023 02:36:04 -0500 Received: from szxga01-in.huawei.com ([45.249.212.187]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rDgGC-0000Hi-Lt for qemu-devel@nongnu.org; Thu, 14 Dec 2023 02:36:01 -0500 Received: from mail.maildlp.com (unknown [172.19.88.105]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4SrPJz144xzsS6k; Thu, 14 Dec 2023 15:35:31 +0800 (CST) Received: from kwepemm000016.china.huawei.com (unknown [7.193.23.210]) by mail.maildlp.com (Postfix) with ESMTPS id 287C01404F2; Thu, 14 Dec 2023 15:35:40 +0800 (CST) Received: from [10.174.187.88] (10.174.187.88) by kwepemm000016.china.huawei.com (7.193.23.210) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.35; Thu, 14 Dec 2023 15:35:39 +0800 To: "Michael S. Tsirkin" CC: , , Subject: [PATCHv2] Fix segmentation fault when VM shutdown with virtio-gpu unplugged Message-ID: <7bbbc0f3-2ad9-83ca-b39b-f976d0837daf@huawei.com> Date: Thu, 14 Dec 2023 15:35:29 +0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:68.0) Gecko/20100101 Thunderbird/68.10.0 MIME-Version: 1.0 Content-Language: en-US Content-Transfer-Encoding: quoted-printable X-Originating-IP: [10.174.187.88] X-ClientProxiedBy: dggems704-chm.china.huawei.com (10.3.19.181) To kwepemm000016.china.huawei.com (7.193.23.210) Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=45.249.212.187; envelope-from=wubinfeng@huawei.com; helo=szxga01-in.huawei.com X-Spam_score_int: -41 X-Spam_score: -4.2 X-Spam_bar: ---- X-Spam_report: (-4.2 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_DNSWL_MED=-2.3, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-to: Binfeng Wu From: Binfeng Wu via Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZM-MESSAGEID: 1702539423135100003 Content-Type: text/plain; charset="utf-8" From 366ba4e21d8a11728957ccdcf974317e84fac140 Mon Sep 17 00:00:00 2001 From: wangmeiling Date: Thu, 14 Dec 2023 07:22:08 +0000 Subject: [PATCH] Fix bugs when VM shutdown with virtio-gpu unplugged Virtio-gpu malloc memory for the queue when it realized, but the queues was= not released when it unrealized, which resulting in a memory leak. In addition, vm_change_state_handler is not cleaned up, which is related to vdev and will lead to segmentation fault when VM shutdown. Signed-off-by: wangmeiling Signed-off-by: Binfeng Wu --- V1->V2: - fix memory leak - add Signed-off-by tag hw/display/virtio-gpu-base.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/hw/display/virtio-gpu-base.c b/hw/display/virtio-gpu-base.c index 37af256219..4fc7ef8896 100644 --- a/hw/display/virtio-gpu-base.c +++ b/hw/display/virtio-gpu-base.c @@ -251,7 +251,11 @@ void virtio_gpu_base_device_unrealize(DeviceState *qdev) { VirtIOGPUBase *g =3D VIRTIO_GPU_BASE(qdev); + VirtIODevice *vdev =3D VIRTIO_DEVICE(qdev); + virtio_del_queue(vdev, 0); + virtio_del_queue(vdev, 1); + virtio_cleanup(vdev); migrate_del_blocker(&g->migration_blocker); } --=20 2.27.0