From: Shameer Kolothum <[email protected]> Add vfio_device_get_feature() as a common helper to retrieve VFIO device features.
No functional change intended. Reviewed-by: Cédric Le Goater <[email protected]> Signed-off-by: Shameer Kolothum <[email protected]> Reviewed-by: Eric Auger <[email protected]> Tested-by: Eric Auger <[email protected]> Reviewed-by: Michael S. Tsirkin <[email protected]> Link: https://lore.kernel.org/qemu-devel/[email protected] Signed-off-by: Cédric Le Goater <[email protected]> --- include/hw/vfio/vfio-device.h | 3 +++ hw/vfio/container.c | 2 +- hw/vfio/device.c | 9 +++++++++ hw/vfio/listener.c | 4 ++-- 4 files changed, 15 insertions(+), 3 deletions(-) diff --git a/include/hw/vfio/vfio-device.h b/include/hw/vfio/vfio-device.h index f6f3d0e3786cf85553d75674828391e16f9fa250..35a5ec6d9224df515c354fe50fcf7c80c1241c8c 100644 --- a/include/hw/vfio/vfio-device.h +++ b/include/hw/vfio/vfio-device.h @@ -272,6 +272,9 @@ bool vfio_device_get_host_iommu_quirk_bypass_ro(VFIODevice *vbasedev, uint32_t type, void *caps, uint32_t size); +int vfio_device_get_feature(VFIODevice *vbasedev, + struct vfio_device_feature *feature); + int vfio_device_get_region_info(VFIODevice *vbasedev, int index, struct vfio_region_info **info); int vfio_device_get_region_info_type(VFIODevice *vbasedev, uint32_t type, diff --git a/hw/vfio/container.c b/hw/vfio/container.c index af16cd14db069882cc5fcf6349b433af3867f40c..4c2816b5741fa5232f104fb16fe919f7642f2a36 100644 --- a/hw/vfio/container.c +++ b/hw/vfio/container.c @@ -205,7 +205,7 @@ static int vfio_device_dma_logging_report(VFIODevice *vbasedev, hwaddr iova, feature->flags = VFIO_DEVICE_FEATURE_GET | VFIO_DEVICE_FEATURE_DMA_LOGGING_REPORT; - return vbasedev->io_ops->device_feature(vbasedev, feature); + return vfio_device_get_feature(vbasedev, feature); } static int vfio_container_iommu_query_dirty_bitmap( diff --git a/hw/vfio/device.c b/hw/vfio/device.c index 086f20f6762a3a86f52bbab840ef67f603850a01..973fc35b59d4bdaa34c0f2773ec78df0f151dfa2 100644 --- a/hw/vfio/device.c +++ b/hw/vfio/device.c @@ -547,6 +547,15 @@ bool vfio_device_get_host_iommu_quirk_bypass_ro(VFIODevice *vbasedev, return false; } +int vfio_device_get_feature(VFIODevice *vbasedev, + struct vfio_device_feature *feature) +{ + if (!vbasedev->io_ops || !vbasedev->io_ops->device_feature) { + return -EINVAL; + } + return vbasedev->io_ops->device_feature(vbasedev, feature); +} + /* * Traditional ioctl() based io */ diff --git a/hw/vfio/listener.c b/hw/vfio/listener.c index 8ba1cd255d146ab8055ab73c71eac640eafa1bdd..1087fdc142e05ecd7890b68a08bb562e161c501b 100644 --- a/hw/vfio/listener.c +++ b/hw/vfio/listener.c @@ -909,7 +909,7 @@ static void vfio_devices_dma_logging_stop(VFIOContainer *bcontainer) continue; } - ret = vbasedev->io_ops->device_feature(vbasedev, feature); + ret = vfio_device_get_feature(vbasedev, feature); if (ret != 0) { warn_report("%s: Failed to stop DMA logging, err %d (%s)", @@ -1014,7 +1014,7 @@ static bool vfio_devices_dma_logging_start(VFIOContainer *bcontainer, continue; } - ret = vbasedev->io_ops->device_feature(vbasedev, feature); + ret = vfio_device_get_feature(vbasedev, feature); if (ret) { error_setg_errno(errp, -ret, "%s: Failed to start DMA logging", vbasedev->name); -- 2.52.0
