Message ID | 20250307180337.14811-11-philmd@linaro.org |
---|---|
State | Superseded |
Headers | show |
Series | hw/vfio: Build various objects once | expand |
On 3/7/25 10:03, Philippe Mathieu-Daudé wrote: > iommufd_builtin() can be used to check at runtime whether > the IOMMUFD feature is built in a qemu-system binary. > > Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org> > --- > docs/devel/vfio-iommufd.rst | 2 +- > include/system/iommufd.h | 8 ++++++++ > 2 files changed, 9 insertions(+), 1 deletion(-) > > diff --git a/docs/devel/vfio-iommufd.rst b/docs/devel/vfio-iommufd.rst > index 3d1c11f175e..08882094eee 100644 > --- a/docs/devel/vfio-iommufd.rst > +++ b/docs/devel/vfio-iommufd.rst > @@ -88,7 +88,7 @@ Step 2: configure QEMU > ---------------------- > > Interactions with the ``/dev/iommu`` are abstracted by a new iommufd > -object (compiled in with the ``CONFIG_IOMMUFD`` option). > +object (which availability can be checked at runtime using ``iommufd_builtin()``). > > Any QEMU device (e.g. VFIO device) wishing to use ``/dev/iommu`` must > be linked with an iommufd object. It gets a new optional property > diff --git a/include/system/iommufd.h b/include/system/iommufd.h > index cbab75bfbf6..ce459254025 100644 > --- a/include/system/iommufd.h > +++ b/include/system/iommufd.h > @@ -63,4 +63,12 @@ bool iommufd_backend_get_dirty_bitmap(IOMMUFDBackend *be, uint32_t hwpt_id, > Error **errp); > > #define TYPE_HOST_IOMMU_DEVICE_IOMMUFD TYPE_HOST_IOMMU_DEVICE "-iommufd" > + > +static inline bool iommufd_builtin(void) > +{ > + bool ambig = false; > + > + return object_resolve_path_type("", TYPE_IOMMUFD_BACKEND, &ambig) || ambig; > +} > + > #endif Reviewed-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
On 3/7/25 10:03, Philippe Mathieu-Daudé wrote: > iommufd_builtin() can be used to check at runtime whether > the IOMMUFD feature is built in a qemu-system binary. > > Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org> > --- > docs/devel/vfio-iommufd.rst | 2 +- > include/system/iommufd.h | 8 ++++++++ > 2 files changed, 9 insertions(+), 1 deletion(-) > > diff --git a/docs/devel/vfio-iommufd.rst b/docs/devel/vfio-iommufd.rst > index 3d1c11f175e..08882094eee 100644 > --- a/docs/devel/vfio-iommufd.rst > +++ b/docs/devel/vfio-iommufd.rst > @@ -88,7 +88,7 @@ Step 2: configure QEMU > ---------------------- > > Interactions with the ``/dev/iommu`` are abstracted by a new iommufd > -object (compiled in with the ``CONFIG_IOMMUFD`` option). > +object (which availability can be checked at runtime using ``iommufd_builtin()``). > > Any QEMU device (e.g. VFIO device) wishing to use ``/dev/iommu`` must > be linked with an iommufd object. It gets a new optional property > diff --git a/include/system/iommufd.h b/include/system/iommufd.h > index cbab75bfbf6..ce459254025 100644 > --- a/include/system/iommufd.h > +++ b/include/system/iommufd.h > @@ -63,4 +63,12 @@ bool iommufd_backend_get_dirty_bitmap(IOMMUFDBackend *be, uint32_t hwpt_id, > Error **errp); > > #define TYPE_HOST_IOMMU_DEVICE_IOMMUFD TYPE_HOST_IOMMU_DEVICE "-iommufd" > + > +static inline bool iommufd_builtin(void) > +{ > + bool ambig = false; > + > + return object_resolve_path_type("", TYPE_IOMMUFD_BACKEND, &ambig) || ambig; > +} > + > #endif Interesting solution. Reviewed-by: Richard Henderson <richard.henderson@linaro.org> r~
On 7/3/25 21:33, Richard Henderson wrote: > On 3/7/25 10:03, Philippe Mathieu-Daudé wrote: >> iommufd_builtin() can be used to check at runtime whether >> the IOMMUFD feature is built in a qemu-system binary. >> >> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org> >> --- >> docs/devel/vfio-iommufd.rst | 2 +- >> include/system/iommufd.h | 8 ++++++++ >> 2 files changed, 9 insertions(+), 1 deletion(-) >> >> diff --git a/docs/devel/vfio-iommufd.rst b/docs/devel/vfio-iommufd.rst >> index 3d1c11f175e..08882094eee 100644 >> --- a/docs/devel/vfio-iommufd.rst >> +++ b/docs/devel/vfio-iommufd.rst >> @@ -88,7 +88,7 @@ Step 2: configure QEMU >> ---------------------- >> Interactions with the ``/dev/iommu`` are abstracted by a new iommufd >> -object (compiled in with the ``CONFIG_IOMMUFD`` option). >> +object (which availability can be checked at runtime using >> ``iommufd_builtin()``). >> Any QEMU device (e.g. VFIO device) wishing to use ``/dev/iommu`` must >> be linked with an iommufd object. It gets a new optional property >> diff --git a/include/system/iommufd.h b/include/system/iommufd.h >> index cbab75bfbf6..ce459254025 100644 >> --- a/include/system/iommufd.h >> +++ b/include/system/iommufd.h >> @@ -63,4 +63,12 @@ bool >> iommufd_backend_get_dirty_bitmap(IOMMUFDBackend *be, uint32_t hwpt_id, >> Error **errp); >> #define TYPE_HOST_IOMMU_DEVICE_IOMMUFD TYPE_HOST_IOMMU_DEVICE "- >> iommufd" >> + >> +static inline bool iommufd_builtin(void) >> +{ >> + bool ambig = false; >> + >> + return object_resolve_path_type("", TYPE_IOMMUFD_BACKEND, &ambig) >> || ambig; >> +} >> + >> #endif > > Interesting solution. Actually this isn't appropriate as this checks for an *instance*, while we only want the *class*. I'll respin a different approach.
diff --git a/docs/devel/vfio-iommufd.rst b/docs/devel/vfio-iommufd.rst index 3d1c11f175e..08882094eee 100644 --- a/docs/devel/vfio-iommufd.rst +++ b/docs/devel/vfio-iommufd.rst @@ -88,7 +88,7 @@ Step 2: configure QEMU ---------------------- Interactions with the ``/dev/iommu`` are abstracted by a new iommufd -object (compiled in with the ``CONFIG_IOMMUFD`` option). +object (which availability can be checked at runtime using ``iommufd_builtin()``). Any QEMU device (e.g. VFIO device) wishing to use ``/dev/iommu`` must be linked with an iommufd object. It gets a new optional property diff --git a/include/system/iommufd.h b/include/system/iommufd.h index cbab75bfbf6..ce459254025 100644 --- a/include/system/iommufd.h +++ b/include/system/iommufd.h @@ -63,4 +63,12 @@ bool iommufd_backend_get_dirty_bitmap(IOMMUFDBackend *be, uint32_t hwpt_id, Error **errp); #define TYPE_HOST_IOMMU_DEVICE_IOMMUFD TYPE_HOST_IOMMU_DEVICE "-iommufd" + +static inline bool iommufd_builtin(void) +{ + bool ambig = false; + + return object_resolve_path_type("", TYPE_IOMMUFD_BACKEND, &ambig) || ambig; +} + #endif
iommufd_builtin() can be used to check at runtime whether the IOMMUFD feature is built in a qemu-system binary. Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org> --- docs/devel/vfio-iommufd.rst | 2 +- include/system/iommufd.h | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-)