Convert the compile time check on the CONFIG_IOMMUFD definition
by a runtime one by calling iommufd_builtin().
Since the file doesn't use any target-specific knowledge anymore,
move it to system_ss[] to build it once.
Signed-off-by: Philippe Mathieu-Daudé <philmd@xxxxxxxxxx>
---
target/s390x/kvm/kvm_s390x.h | 2 +-
hw/vfio/ap.c | 27 +++++++++++++--------------
hw/vfio/meson.build | 2 +-
3 files changed, 15 insertions(+), 16 deletions(-)
diff --git a/target/s390x/kvm/kvm_s390x.h b/target/s390x/kvm/kvm_s390x.h
index 649dae5948a..7b1cce3e60d 100644
--- a/target/s390x/kvm/kvm_s390x.h
+++ b/target/s390x/kvm/kvm_s390x.h
@@ -10,7 +10,7 @@
#ifndef KVM_S390X_H
#define KVM_S390X_H
-#include "cpu-qom.h"
+#include "target/s390x/cpu-qom.h"
struct kvm_s390_irq;
diff --git a/hw/vfio/ap.c b/hw/vfio/ap.c
index c7ab4ff57ad..832b98532ea 100644
--- a/hw/vfio/ap.c
+++ b/hw/vfio/ap.c
@@ -11,7 +11,6 @@
*/
#include "qemu/osdep.h"
-#include CONFIG_DEVICES /* CONFIG_IOMMUFD */
#include <linux/vfio.h>
#include <sys/ioctl.h>
#include "qapi/error.h"
@@ -24,7 +23,7 @@
#include "qemu/module.h"
#include "qemu/option.h"
#include "qemu/config-file.h"
-#include "kvm/kvm_s390x.h"
+#include "target/s390x/kvm/kvm_s390x.h"
#include "migration/vmstate.h"
#include "hw/qdev-properties.h"
#include "hw/s390x/ap-bridge.h"
@@ -193,10 +192,11 @@ static void vfio_ap_unrealize(DeviceState *dev)
static const Property vfio_ap_properties[] = {
DEFINE_PROP_STRING("sysfsdev", VFIOAPDevice, vdev.sysfsdev),
-#ifdef CONFIG_IOMMUFD
+};
+
+static const Property vfio_ap_iommufd_properties[] = {
DEFINE_PROP_LINK("iommufd", VFIOAPDevice, vdev.iommufd,
TYPE_IOMMUFD_BACKEND, IOMMUFDBackend *),
-#endif
};
static void vfio_ap_reset(DeviceState *dev)
@@ -234,21 +234,20 @@ static void vfio_ap_instance_init(Object *obj)
vbasedev->mdev = true;
}
-#ifdef CONFIG_IOMMUFD
static void vfio_ap_set_fd(Object *obj, const char *str, Error **errp)
{
vfio_device_set_fd(&VFIO_AP_DEVICE(obj)->vdev, str, errp);
}
-#endif
static void vfio_ap_class_init(ObjectClass *klass, void *data)
{
DeviceClass *dc = DEVICE_CLASS(klass);
device_class_set_props(dc, vfio_ap_properties);
-#ifdef CONFIG_IOMMUFD
- object_class_property_add_str(klass, "fd", NULL, vfio_ap_set_fd);
-#endif
+ if (iommufd_builtin()) {
+ device_class_set_props(dc, vfio_ap_iommufd_properties);
+ object_class_property_add_str(klass, "fd", NULL, vfio_ap_set_fd);
+ }
dc->vmsd = &vfio_ap_vmstate;
dc->desc = "VFIO-based AP device assignment";
set_bit(DEVICE_CATEGORY_MISC, dc->categories);
@@ -261,11 +260,11 @@ static void vfio_ap_class_init(ObjectClass *klass, void *data)
object_class_property_set_description(klass, /* 3.1 */
"sysfsdev",
"Host sysfs path of assigned device");
-#ifdef CONFIG_IOMMUFD
- object_class_property_set_description(klass, /* 9.0 */
- "iommufd",
- "Set host IOMMUFD backend device");
-#endif
+ if (iommufd_builtin()) {
+ object_class_property_set_description(klass, /* 9.0 */
+ "iommufd",
+ "Set host IOMMUFD backend device");
+ }
}
static const TypeInfo vfio_ap_info = {
diff --git a/hw/vfio/meson.build b/hw/vfio/meson.build
index 9a004992c11..510ebe6d720 100644
--- a/hw/vfio/meson.build
+++ b/hw/vfio/meson.build
@@ -9,7 +9,6 @@ vfio_ss.add(when: 'CONFIG_VFIO_PCI', if_true: files(
))
vfio_ss.add(when: 'CONFIG_VFIO_CCW', if_true: files('ccw.c'))
vfio_ss.add(when: 'CONFIG_VFIO_PLATFORM', if_true: files('platform.c'))
-vfio_ss.add(when: 'CONFIG_VFIO_AP', if_true: files('ap.c'))
specific_ss.add_all(when: 'CONFIG_VFIO', if_true: vfio_ss)
@@ -26,6 +25,7 @@ system_ss.add(when: 'CONFIG_VFIO', if_true: files(
system_ss.add(when: ['CONFIG_VFIO', 'CONFIG_IOMMUFD'], if_true: files(
'iommufd.c',
))
+system_ss.add(when: 'CONFIG_VFIO_AP', if_true: files('ap.c'))
system_ss.add(when: 'CONFIG_VFIO_PCI', if_true: files(
'display.c',
'pci.c',