Skip to content

Commit c0f97b1

Browse files
committed
meson: add -Diommufd=[auto]|enabled|disabled
iommufd feature has been checked based on the kernel header file in vfio.h in the current build system. Even if iommufd is supported by the current system, user might want to build and install libvfn with vfio rather than iommufd. This patch added -Diommufd option to meson to let user choose whether to include or not. Signed-off-by: Minwoo Im <minwoo.im@samsung.com>
1 parent 404443b commit c0f97b1

File tree

2 files changed

+30
-10
lines changed

2 files changed

+30
-10
lines changed

meson.build

Lines changed: 27 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -66,14 +66,31 @@ config_host = configuration_data()
6666
config_host.set('NVME_AQ_QSIZE', get_option('aq_qsize'),
6767
description: 'admin command queue size')
6868

69-
config_host.set('HAVE_VFIO_DEVICE_BIND_IOMMUFD',
70-
cc.has_header_symbol('linux/vfio.h', 'VFIO_DEVICE_BIND_IOMMUFD',
71-
include_directories: linux_headers),
72-
description: 'if VFIO_DEVICE_BIND_IOMMUFD is defined in linux/vfio.h')
73-
74-
config_host.set('HAVE_IOMMU_FAULT_QUEUE_ALLOC',
75-
cc.has_header_symbol('linux/iommufd.h', 'IOMMU_FAULT_QUEUE_ALLOC',
76-
include_directories: linux_headers),
69+
# Check iommufd option
70+
iommufd_opt = get_option('iommufd')
71+
has_iommufd = false
72+
73+
if not iommufd_opt.disabled()
74+
has_vfio_bind = cc.has_header_symbol('linux/vfio.h', 'VFIO_DEVICE_BIND_IOMMUFD',
75+
include_directories: linux_headers)
76+
77+
if has_vfio_bind
78+
has_iommufd = true
79+
elif iommufd_opt.enabled()
80+
error('iommufd enabled but VFIO_DEVICE_BIND_IOMMUFD not found in linux/vfio.h')
81+
endif
82+
endif
83+
84+
config_host.set('HAVE_VFIO_DEVICE_BIND_IOMMUFD', has_iommufd,
85+
description: 'if iommufd support is enabled')
86+
87+
has_fault_queue = false
88+
if has_iommufd
89+
has_fault_queue = cc.has_header_symbol('linux/iommufd.h', 'IOMMU_FAULT_QUEUE_ALLOC',
90+
include_directories: linux_headers)
91+
endif
92+
93+
config_host.set('HAVE_IOMMU_FAULT_QUEUE_ALLOC', has_fault_queue,
7794
description: 'if IOMMU_FAULT_QUEUE_ALLOC is defined in linux/iommufd.h')
7895

7996
subdir('internal')
@@ -180,6 +197,6 @@ summary_info = {}
180197
summary_info += {'Debugging': get_option('debug')}
181198
summary_info += {'Documentation': build_docs}
182199
summary_info += {'Profiling': get_option('profiling')}
183-
summary_info += {'iommufd': config_host.get('HAVE_VFIO_DEVICE_BIND_IOMMUFD')}
184-
summary_info += {'iommufd fault queue': config_host.get('HAVE_IOMMU_FAULT_QUEUE_ALLOC')}
200+
summary_info += {'iommufd': has_iommufd}
201+
summary_info += {'iommufd fault queue': has_fault_queue}
185202
summary(summary_info, bool_yn: true, section: 'Features')

meson_options.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,3 +15,6 @@ option('trace-events-file', type: 'string', value: 'config/trace-events-all',
1515

1616
option('linux-headers', type: 'string', value: '',
1717
description: 'path to linux headers')
18+
19+
option('iommufd', type: 'feature', value: 'auto',
20+
description: 'enable/disable iommufd support')

0 commit comments

Comments
 (0)