Skip to contentSkip to conversation

Fix segmentation fault when VM shutdown with virtio-gpu unplugged

PATCH Superseded Binfeng Wu via 2 participants 3 messages Nov 10, 2023

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Fix segmentation fault when VM shutdown with virtio-gpu unplugged

From: wangmeiling <[email protected]>

In the virtio-gpu unrealize process, the vdev structure has been cleaned up. However, vm_change_state_handler is not cleaned up yet, which is related to vdev. This handler will be cleaned up when VM shutdown, but the vdev is already a null pointer at this time, this will lead to segmentation fault.

Signed-off-by [email protected]
Signed-off-by [email protected]
---
 hw/display/virtio-gpu-base.c | 2 ++
 1 file changed, 2 insertions(+)
hw/display/virtio-gpu-base.c +2 -0
index 37af256219..b31b8d683f 100644
@@ -252,6 +252,8 @@ virtio_gpu_base_device_unrealize(DeviceState *qdev)
 {
     VirtIOGPUBase *g = VIRTIO_GPU_BASE(qdev);
 
+    virtio_cleanup(VIRTIO_DEVICE(g));
+
     migrate_del_blocker(&g->migration_blocker);
 }
 
Signature · 1 line
2.20.1
Acked-by on v1 1/1
#1 lore raw
Quoted 9 lines · Binfeng Wu

From: wangmeiling <[email protected]>

In the virtio-gpu unrealize process, the vdev structure has been cleaned up. However, vm_change_state_handler is not cleaned up yet, which is related to vdev. This handler will be cleaned up when VM shutdown, but the vdev is already a null pointer at this time, this will lead to segmentation fault.

Signed-off-by [email protected]
Signed-off-by [email protected]

You need to add your real names, not just email.

With that:

Quoted 19 lines
---
 hw/display/virtio-gpu-base.c | 2 ++
 1 file changed, 2 insertions(+)
hw/display/virtio-gpu-base.c +2 -0
index 37af256219..b31b8d683f 100644
@@ -252,6 +252,8 @@ virtio_gpu_base_device_unrealize(DeviceState *qdev)
 {
     VirtIOGPUBase *g = VIRTIO_GPU_BASE(qdev);
 
+    virtio_cleanup(VIRTIO_DEVICE(g));
+
     migrate_del_blocker(&g->migration_blocker);
 }
 
Signature · 1 line
2.20.1
#2 lore raw

Sorry for this mistake. Please check now.
Please let us know if we need resubmit it.

From e798cf68b1a4043dcf8dda9b895812c1dab88da2 Mon Sep 17 00:00:00 2001
From: wangmeiling <[email protected]>
Date: Fri, 10 Nov 2023 10:17:54 +0800
Subject: [PATCH] Fix segmentation fault when VM shutdown with virtio-gpu
unplugged

In the virtio-gpu unrealize process, the vdev structure has been cleaned up. However, vm_change_state_handler is not cleaned up yet, which is related to vdev. This handler will be cleaned up when VM shutdown, but the vdev is already a null pointer at this time, this will lead to segmentation fault.

---
 hw/display/virtio-gpu-base.c | 2 ++
 1 file changed, 2 insertions(+)
hw/display/virtio-gpu-base.c +2 -0
index 37af256219..b31b8d683f 100644
@@ -252,6 +252,8 @@ virtio_gpu_base_device_unrealize(DeviceState *qdev)
 {
     VirtIOGPUBase *g = VIRTIO_GPU_BASE(qdev);
 
+    virtio_cleanup(VIRTIO_DEVICE(g));
+
     migrate_del_blocker(&g->migration_blocker);
 }
 

--
2.20.1

Quoted 39 lines · Michael S. Tsirkin
Quoted 9 lines · Binfeng Wu

From: wangmeiling <[email protected]>

In the virtio-gpu unrealize process, the vdev structure has been cleaned up. However, vm_change_state_handler is not cleaned up yet, which is related to vdev. This handler will be cleaned up when VM shutdown, but the vdev is already a null pointer at this time, this will lead to segmentation fault.

Signed-off-by [email protected]
Signed-off-by [email protected]

You need to add your real names, not just email.

With that:

Quoted 19 lines
---
 hw/display/virtio-gpu-base.c | 2 ++
 1 file changed, 2 insertions(+)
hw/display/virtio-gpu-base.c +2 -0
index 37af256219..b31b8d683f 100644
@@ -252,6 +252,8 @@ virtio_gpu_base_device_unrealize(DeviceState *qdev)
 {
     VirtIOGPUBase *g = VIRTIO_GPU_BASE(qdev);
 
+    virtio_cleanup(VIRTIO_DEVICE(g));
+
     migrate_del_blocker(&g->migration_blocker);
 }
 
Signature · 1 line
2.20.1

.