mirror of https://github.com/xemu-project/xemu.git
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>
This commit is contained in:
parent
2d050ed07c
commit
dd014b4f49
|
@ -325,6 +325,20 @@ static char *virtio_bus_get_fw_dev_path(DeviceState *dev)
|
||||||
return NULL;
|
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)
|
static void virtio_bus_class_init(ObjectClass *klass, void *data)
|
||||||
{
|
{
|
||||||
BusClass *bus_class = BUS_CLASS(klass);
|
BusClass *bus_class = BUS_CLASS(klass);
|
||||||
|
|
|
@ -93,6 +93,7 @@ struct VirtioBusClass {
|
||||||
*/
|
*/
|
||||||
bool has_variable_vring_alignment;
|
bool has_variable_vring_alignment;
|
||||||
AddressSpace *(*get_dma_as)(DeviceState *d);
|
AddressSpace *(*get_dma_as)(DeviceState *d);
|
||||||
|
bool (*iommu_enabled)(DeviceState *d);
|
||||||
};
|
};
|
||||||
|
|
||||||
struct VirtioBusState {
|
struct VirtioBusState {
|
||||||
|
@ -154,5 +155,6 @@ void virtio_bus_release_ioeventfd(VirtioBusState *bus);
|
||||||
int virtio_bus_set_host_notifier(VirtioBusState *bus, int n, bool assign);
|
int virtio_bus_set_host_notifier(VirtioBusState *bus, int n, bool assign);
|
||||||
/* Tell the bus that the ioeventfd handler is no longer required. */
|
/* Tell the bus that the ioeventfd handler is no longer required. */
|
||||||
void virtio_bus_cleanup_host_notifier(VirtioBusState *bus, int n);
|
void virtio_bus_cleanup_host_notifier(VirtioBusState *bus, int n);
|
||||||
|
/* Whether the IOMMU is enabled for this device */
|
||||||
|
bool virtio_bus_device_iommu_enabled(VirtIODevice *vdev);
|
||||||
#endif /* VIRTIO_BUS_H */
|
#endif /* VIRTIO_BUS_H */
|
||||||
|
|
Loading…
Reference in New Issue