vhost: call destroy_device always in vhost_destroy_device_notify

Message ID 20210903075637.2201185-1-fengli@smartx.com (mailing list archive)
State Superseded, archived
Delegated to: Maxime Coquelin
Headers
Series vhost: call destroy_device always in vhost_destroy_device_notify |

Checks

Context Check Description
ci/checkpatch warning coding style issues
ci/iol-aarch64-compile-testing success Testing PASS
ci/iol-broadcom-Performance success Performance Testing PASS
ci/iol-x86_64-unit-testing success Testing PASS
ci/iol-broadcom-Functional success Functional Testing PASS
ci/iol-intel-Functional success Functional Testing PASS
ci/iol-intel-Performance success Performance Testing PASS
ci/iol-mellanox-Performance success Performance Testing PASS
ci/iol-x86_64-compile-testing success Testing PASS

Commit Message

Li Feng Sept. 3, 2021, 7:56 a.m. UTC
  Vhost-user client must send the mem table, kick fd, call fd on all vas,
then the device will be VIRTIO_DEV_RUNNING.

If the vhost-user communication is initialized partly, e.g.
- When initializing the vhost-user, try to restart the vhost-user
    backend;
- Seabios only initialized the vhost-scsi req vq.
The device is not with flags VIRTIO_DEV_RUNNING..

Root Cause:
The vhost session has been created, and added the scsi/blk requestq
poller into reactor, but when destroying the device, the requestq is not
unregistered.

Reproduce the crash on spdk vhost-user backend:
1. Create a VM;
2. Mount a ISO to a VM, start the VM, don't install the OS;
3. Restart the spdk_tgt;

Another discusstion is in seabiso:
https://patchew.org/Seabios/20210831122339.2591585-1-fengli@smartx.com/

Signed-off-by: Li Feng <fengli@smartx.com>
---
 lib/vhost/vhost.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
  

Patch

diff --git a/lib/vhost/vhost.c b/lib/vhost/vhost.c
index 355ff37651..191ba82c41 100644
--- a/lib/vhost/vhost.c
+++ b/lib/vhost/vhost.c
@@ -710,8 +710,8 @@  vhost_destroy_device_notify(struct virtio_net *dev)
 		if (vdpa_dev)
 			vdpa_dev->ops->dev_close(dev->vid);
 		dev->flags &= ~VIRTIO_DEV_RUNNING;
-		dev->notify_ops->destroy_device(dev->vid);
 	}
+	dev->notify_ops->destroy_device(dev->vid);
 }
 
 /*