qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCHv2] Fix segmentation fault when VM shutdown with virtio-gpu unplug


From: Binfeng Wu
Subject: [PATCHv2] Fix segmentation fault when VM shutdown with virtio-gpu unplugged
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

>From 366ba4e21d8a11728957ccdcf974317e84fac140 Mon Sep 17 00:00:00 2001
From: wangmeiling <wangmeiling21@huawei.com>
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 <wangmeiling21@huawei.com>
Signed-off-by: Binfeng Wu <wubinfeng@huawei.com>
---
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 = VIRTIO_GPU_BASE(qdev);
+    VirtIODevice *vdev = VIRTIO_DEVICE(qdev);

+    virtio_del_queue(vdev, 0);
+    virtio_del_queue(vdev, 1);
+    virtio_cleanup(vdev);
     migrate_del_blocker(&g->migration_blocker);
 }

-- 
2.27.0




reply via email to

[Prev in Thread] Current Thread [Next in Thread]