Commit 3f63b4c6 authored by Jason Wang's avatar Jason Wang Committed by Michael S. Tsirkin
Browse files

vhost: check the existence of vhost_set_iotlb_callback



Add the check of vhost_set_iotlb_callback
before calling

Signed-off-by: default avatarJason Wang <jasowang@redhat.com>
Signed-off-by: default avatarCindy Lu <lulu@redhat.com>
Message-Id: <20200701145538.22333-6-lulu@redhat.com>
Reviewed-by: default avatarMichael S. Tsirkin <mst@redhat.com>
Signed-off-by: default avatarMichael S. Tsirkin <mst@redhat.com>
Acked-by: default avatarJason Wang <jasowang@redhat.com>
parent f19bcdfe
Loading
Loading
Loading
Loading
+6 −3
Original line number Diff line number Diff line
@@ -1686,7 +1686,8 @@ int vhost_dev_start(struct vhost_dev *hdev, VirtIODevice *vdev)
        }
    }

    if (vhost_dev_has_iommu(hdev)) {
    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,
@@ -1730,7 +1731,9 @@ void vhost_dev_stop(struct vhost_dev *hdev, VirtIODevice *vdev)
    }

    if (vhost_dev_has_iommu(hdev)) {
        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);