mirror of
https://github.com/xemu-project/xemu.git
synced 2024-11-30 15:00:34 +00:00
vhost: check the existence of vhost_set_iotlb_callback
Add the check of vhost_set_iotlb_callback before calling Signed-off-by: Jason Wang <jasowang@redhat.com> Signed-off-by: Cindy Lu <lulu@redhat.com> Message-Id: <20200701145538.22333-6-lulu@redhat.com> Reviewed-by: Michael S. Tsirkin <mst@redhat.com> Signed-off-by: Michael S. Tsirkin <mst@redhat.com> Acked-by: Jason Wang <jasowang@redhat.com>
This commit is contained in:
parent
f19bcdfedd
commit
3f63b4c655
@ -1686,8 +1686,9 @@ int vhost_dev_start(struct vhost_dev *hdev, VirtIODevice *vdev)
|
||||
}
|
||||
}
|
||||
|
||||
if (vhost_dev_has_iommu(hdev)) {
|
||||
hdev->vhost_ops->vhost_set_iotlb_callback(hdev, true);
|
||||
if (vhost_dev_has_iommu(hdev) &&
|
||||
hdev->vhost_ops->vhost_set_iotlb_callback) {
|
||||
hdev->vhost_ops->vhost_set_iotlb_callback(hdev, true);
|
||||
|
||||
/* Update used ring information for IOTLB to work correctly,
|
||||
* vhost-kernel code requires for this.*/
|
||||
@ -1730,7 +1731,9 @@ void vhost_dev_stop(struct vhost_dev *hdev, VirtIODevice *vdev)
|
||||
}
|
||||
|
||||
if (vhost_dev_has_iommu(hdev)) {
|
||||
hdev->vhost_ops->vhost_set_iotlb_callback(hdev, false);
|
||||
if (hdev->vhost_ops->vhost_set_iotlb_callback) {
|
||||
hdev->vhost_ops->vhost_set_iotlb_callback(hdev, false);
|
||||
}
|
||||
memory_listener_unregister(&hdev->iommu_listener);
|
||||
}
|
||||
vhost_log_put(hdev, true);
|
||||
|
Loading…
Reference in New Issue
Block a user