So that the free of iova tree struct can be safely deferred to until the last vq referencing it goes away.
Signed-off-by: Si-Wei Liu <si-wei....@oracle.com> --- hw/virtio/vhost-vdpa.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/hw/virtio/vhost-vdpa.c b/hw/virtio/vhost-vdpa.c index 4f026db..ea2dfc8 100644 --- a/hw/virtio/vhost-vdpa.c +++ b/hw/virtio/vhost-vdpa.c @@ -815,7 +815,10 @@ static int vhost_vdpa_cleanup(struct vhost_dev *dev) } vhost_vdpa_host_notifiers_uninit(dev, dev->nvqs); - memory_listener_unregister(&v->shared->listener); + if (vhost_vdpa_last_dev(dev) && v->shared->listener_registered) { + memory_listener_unregister(&v->shared->listener); + v->shared->listener_registered = false; + } vhost_vdpa_svq_cleanup(dev); dev->opaque = NULL; -- 1.8.3.1