diff options
author | Joao Martins <joao.m.martins@oracle.com> | 2024-07-19 13:04:49 +0100 |
---|---|---|
committer | Cédric Le Goater <clg@redhat.com> | 2024-07-23 17:14:52 +0200 |
commit | 13e522f644e2b15fa857028a33e6a3b75e45158d (patch) | |
tree | 07e92ff3a1cd8a241c7866d2bc8b03dc4466001a /hw/vfio/helpers.c | |
parent | 07321a6d087d4ec9866cfb0c8b53692a59758976 (diff) |
vfio/pci: Extract mdev check into an helper
In preparation to skip initialization of the HostIOMMUDevice for mdev,
extract the checks that validate if a device is an mdev into helpers.
A vfio_device_is_mdev() is created, and subsystems consult VFIODevice::mdev
to check if it's mdev or not.
Signed-off-by: Joao Martins <joao.m.martins@oracle.com>
Reviewed-by: Cédric Le Goater <clg@redhat.com>
Reviewed-by: Zhenzhong Duan <zhenzhong.duan@intel.com>
Reviewed-by: Eric Auger <eric.auger@redhat.com>
Diffstat (limited to 'hw/vfio/helpers.c')
-rw-r--r-- | hw/vfio/helpers.c | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/hw/vfio/helpers.c b/hw/vfio/helpers.c index b14edd46ed..7e23e9080c 100644 --- a/hw/vfio/helpers.c +++ b/hw/vfio/helpers.c @@ -675,3 +675,17 @@ int vfio_device_get_aw_bits(VFIODevice *vdev) return HOST_IOMMU_DEVICE_CAP_AW_BITS_MAX; } + +bool vfio_device_is_mdev(VFIODevice *vbasedev) +{ + g_autofree char *subsys = NULL; + g_autofree char *tmp = NULL; + + if (!vbasedev->sysfsdev) { + return false; + } + + tmp = g_strdup_printf("%s/subsystem", vbasedev->sysfsdev); + subsys = realpath(tmp, NULL); + return subsys && (strcmp(subsys, "/sys/bus/mdev") == 0); +} |