diff options
author | Cédric Le Goater <clg@redhat.com> | 2025-03-26 08:51:01 +0100 |
---|---|---|
committer | Cédric Le Goater <clg@redhat.com> | 2025-04-25 09:01:37 +0200 |
commit | ac28680d5e7a84943cd9f55a4aae245d6d7fdcae (patch) | |
tree | 893b65b395afc205c3ca5f54823f95307c04efc7 | |
parent | 5cf52416e428836b1328ed47173a41948e1643bd (diff) | |
download | qemu-ac28680d5e7a84943cd9f55a4aae245d6d7fdcae.zip qemu-ac28680d5e7a84943cd9f55a4aae245d6d7fdcae.tar.gz qemu-ac28680d5e7a84943cd9f55a4aae245d6d7fdcae.tar.bz2 |
vfio: Introduce a new header file for helper services
Gather all helper routine declarations into "vfio-helpers.h" to reduce
exposure of VFIO internals in "hw/vfio/vfio-common.h".
Reviewed-by: John Levon <john.levon@nutanix.com>
Link: https://lore.kernel.org/qemu-devel/20250318095415.670319-16-clg@redhat.com
Reviewed-by: Zhenzhong Duan <zhenzhong.duan@intel.com>
Link: https://lore.kernel.org/qemu-devel/20250326075122.1299361-17-clg@redhat.com
Signed-off-by: Cédric Le Goater <clg@redhat.com>
-rw-r--r-- | hw/s390x/s390-pci-vfio.c | 1 | ||||
-rw-r--r-- | hw/vfio/common.c | 1 | ||||
-rw-r--r-- | hw/vfio/container.c | 1 | ||||
-rw-r--r-- | hw/vfio/helpers.c | 1 | ||||
-rw-r--r-- | hw/vfio/pci.c | 1 | ||||
-rw-r--r-- | hw/vfio/region.c | 1 | ||||
-rw-r--r-- | hw/vfio/vfio-helpers.h | 26 | ||||
-rw-r--r-- | include/hw/vfio/vfio-common.h | 7 |
8 files changed, 32 insertions, 7 deletions
diff --git a/hw/s390x/s390-pci-vfio.c b/hw/s390x/s390-pci-vfio.c index 748a51f..aaf9131 100644 --- a/hw/s390x/s390-pci-vfio.c +++ b/hw/s390x/s390-pci-vfio.c @@ -21,6 +21,7 @@ #include "hw/s390x/s390-pci-vfio.h" #include "hw/vfio/pci.h" #include "hw/vfio/vfio-container.h" +#include "hw/vfio/vfio-helpers.h" /* * Get the current DMA available count from vfio. Returns true if vfio is diff --git a/hw/vfio/common.c b/hw/vfio/common.c index c099d4d..18e5aac 100644 --- a/hw/vfio/common.c +++ b/hw/vfio/common.c @@ -44,6 +44,7 @@ #include "system/tcg.h" #include "system/tpm.h" #include "vfio-migration-internal.h" +#include "vfio-helpers.h" VFIODeviceList vfio_device_list = QLIST_HEAD_INITIALIZER(vfio_device_list); diff --git a/hw/vfio/container.c b/hw/vfio/container.c index 6ef53ee..b2d72f5 100644 --- a/hw/vfio/container.c +++ b/hw/vfio/container.c @@ -33,6 +33,7 @@ #include "qapi/error.h" #include "pci.h" #include "hw/vfio/vfio-container.h" +#include "vfio-helpers.h" #define TYPE_HOST_IOMMU_DEVICE_LEGACY_VFIO TYPE_HOST_IOMMU_DEVICE "-legacy-vfio" diff --git a/hw/vfio/helpers.c b/hw/vfio/helpers.c index 8940394..054ee6e 100644 --- a/hw/vfio/helpers.c +++ b/hw/vfio/helpers.c @@ -30,6 +30,7 @@ #include "qemu/error-report.h" #include "qemu/units.h" #include "monitor/monitor.h" +#include "vfio-helpers.h" /* * Common VFIO interrupt disable diff --git a/hw/vfio/pci.c b/hw/vfio/pci.c index b0aac2f..bade3b8 100644 --- a/hw/vfio/pci.c +++ b/hw/vfio/pci.c @@ -45,6 +45,7 @@ #include "migration/qemu-file.h" #include "system/iommufd.h" #include "vfio-migration-internal.h" +#include "vfio-helpers.h" #define TYPE_VFIO_PCI_NOHOTPLUG "vfio-pci-nohotplug" diff --git a/hw/vfio/region.c b/hw/vfio/region.c index 08cd69e..9049143 100644 --- a/hw/vfio/region.c +++ b/hw/vfio/region.c @@ -29,6 +29,7 @@ #include "qemu/error-report.h" #include "qemu/units.h" #include "monitor/monitor.h" +#include "vfio-helpers.h" /* * IO Port/MMIO - Beware of the endians, VFIO is always little endian diff --git a/hw/vfio/vfio-helpers.h b/hw/vfio/vfio-helpers.h new file mode 100644 index 0000000..d7e4dcb --- /dev/null +++ b/hw/vfio/vfio-helpers.h @@ -0,0 +1,26 @@ +/* + * VFIO helpers + * + * Copyright Red Hat, Inc. 2025 + * + * SPDX-License-Identifier: GPL-2.0-or-later + */ + +#ifndef HW_VFIO_VFIO_HELPERS_H +#define HW_VFIO_VFIO_HELPERS_H + +#ifdef CONFIG_LINUX +#include <linux/vfio.h> + +struct vfio_info_cap_header * +vfio_get_cap(void *ptr, uint32_t cap_offset, uint16_t id); +struct vfio_info_cap_header * +vfio_get_device_info_cap(struct vfio_device_info *info, uint16_t id); +struct vfio_info_cap_header * +vfio_get_region_info_cap(struct vfio_region_info *info, uint16_t id); + +#endif + +int vfio_bitmap_alloc(VFIOBitmap *vbmap, hwaddr size); + +#endif /* HW_VFIO_VFIO_HELPERS_H */ diff --git a/include/hw/vfio/vfio-common.h b/include/hw/vfio/vfio-common.h index bb11b82..8e46511 100644 --- a/include/hw/vfio/vfio-common.h +++ b/include/hw/vfio/vfio-common.h @@ -147,17 +147,10 @@ int vfio_get_region_info(VFIODevice *vbasedev, int index, int vfio_get_dev_region_info(VFIODevice *vbasedev, uint32_t type, uint32_t subtype, struct vfio_region_info **info); bool vfio_has_region_cap(VFIODevice *vbasedev, int region, uint16_t cap_type); -struct vfio_info_cap_header * -vfio_get_region_info_cap(struct vfio_region_info *info, uint16_t id); bool vfio_get_info_dma_avail(struct vfio_iommu_type1_info *info, unsigned int *avail); -struct vfio_info_cap_header * -vfio_get_device_info_cap(struct vfio_device_info *info, uint16_t id); -struct vfio_info_cap_header * -vfio_get_cap(void *ptr, uint32_t cap_offset, uint16_t id); #endif -int vfio_bitmap_alloc(VFIOBitmap *vbmap, hwaddr size); bool vfio_devices_all_dirty_tracking_started( const VFIOContainerBase *bcontainer); bool |