aboutsummaryrefslogtreecommitdiff
path: root/hw/virtio
diff options
context:
space:
mode:
authorJason Wang <jasowang@redhat.com>2021-08-04 11:48:01 +0800
committerMichael S. Tsirkin <mst@redhat.com>2021-09-04 16:35:17 -0400
commitdd014b4f4967e85c021033193d70d7526b7214cb (patch)
tree24ae9ae9ed3a19b9d8faded83ae02b598029eb50 /hw/virtio
parent2d050ed07c97a88202dac3eef64263e1f2556bfe (diff)
virtio-bus: introduce iommu_enabled()
This patch introduce a new method for the virtio-bus for the transport to report whether or not the IOMMU is enabled for the device. Signed-off-by: Jason Wang <jasowang@redhat.com> Message-Id: <20210804034803.1644-2-jasowang@redhat.com> Reviewed-by: Michael S. Tsirkin <mst@redhat.com> Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Diffstat (limited to 'hw/virtio')
-rw-r--r--hw/virtio/virtio-bus.c14
1 files changed, 14 insertions, 0 deletions
diff --git a/hw/virtio/virtio-bus.c b/hw/virtio/virtio-bus.c
index 859978d248..d23db98c56 100644
--- a/hw/virtio/virtio-bus.c
+++ b/hw/virtio/virtio-bus.c
@@ -325,6 +325,20 @@ static char *virtio_bus_get_fw_dev_path(DeviceState *dev)
return NULL;
}
+bool virtio_bus_device_iommu_enabled(VirtIODevice *vdev)
+{
+ DeviceState *qdev = DEVICE(vdev);
+ BusState *qbus = BUS(qdev_get_parent_bus(qdev));
+ VirtioBusState *bus = VIRTIO_BUS(qbus);
+ VirtioBusClass *klass = VIRTIO_BUS_GET_CLASS(bus);
+
+ if (!klass->iommu_enabled) {
+ return false;
+ }
+
+ return klass->iommu_enabled(qbus->parent);
+}
+
static void virtio_bus_class_init(ObjectClass *klass, void *data)
{
BusClass *bus_class = BUS_CLASS(klass);