Re: [PATCH 13/14] hw/vfio/ccw: Check CONFIG_IOMMUFD at runtime using iommufd_builtin()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 3/7/25 10:03, Philippe Mathieu-Daudé wrote:
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>
---
  hw/vfio/ccw.c       | 27 +++++++++++++--------------
  hw/vfio/meson.build |  2 +-
  2 files changed, 14 insertions(+), 15 deletions(-)

diff --git a/hw/vfio/ccw.c b/hw/vfio/ccw.c
index e5e0d9e3e7e..84d1437a568 100644
--- a/hw/vfio/ccw.c
+++ b/hw/vfio/ccw.c
@@ -15,7 +15,6 @@
   */
#include "qemu/osdep.h"
-#include CONFIG_DEVICES /* CONFIG_IOMMUFD */
  #include <linux/vfio.h>
  #include <linux/vfio_ccw.h>
  #include <sys/ioctl.h>
@@ -650,11 +649,12 @@ static void vfio_ccw_unrealize(DeviceState *dev)
  static const Property vfio_ccw_properties[] = {
      DEFINE_PROP_STRING("sysfsdev", VFIOCCWDevice, vdev.sysfsdev),
      DEFINE_PROP_BOOL("force-orb-pfch", VFIOCCWDevice, force_orb_pfch, false),
-#ifdef CONFIG_IOMMUFD
+    DEFINE_PROP_CCW_LOADPARM("loadparm", CcwDevice, loadparm),
+};
+
+static const Property vfio_ccw_iommufd_properties[] = {
      DEFINE_PROP_LINK("iommufd", VFIOCCWDevice, vdev.iommufd,
                       TYPE_IOMMUFD_BACKEND, IOMMUFDBackend *),
-#endif
-    DEFINE_PROP_CCW_LOADPARM("loadparm", CcwDevice, loadparm),
  };
static const VMStateDescription vfio_ccw_vmstate = {
@@ -682,12 +682,10 @@ static void vfio_ccw_instance_init(Object *obj)
                       DEVICE(vcdev), true);
  }
-#ifdef CONFIG_IOMMUFD
  static void vfio_ccw_set_fd(Object *obj, const char *str, Error **errp)
  {
      vfio_device_set_fd(&VFIO_CCW(obj)->vdev, str, errp);
  }
-#endif
static void vfio_ccw_class_init(ObjectClass *klass, void *data)
  {
@@ -695,9 +693,10 @@ static void vfio_ccw_class_init(ObjectClass *klass, void *data)
      S390CCWDeviceClass *cdc = S390_CCW_DEVICE_CLASS(klass);
device_class_set_props(dc, vfio_ccw_properties);
-#ifdef CONFIG_IOMMUFD
-    object_class_property_add_str(klass, "fd", NULL, vfio_ccw_set_fd);
-#endif
+    if (iommufd_builtin()) {
+        device_class_set_props(dc, vfio_ccw_iommufd_properties);
+        object_class_property_add_str(klass, "fd", NULL, vfio_ccw_set_fd);
+    }
      dc->vmsd = &vfio_ccw_vmstate;
      dc->desc = "VFIO-based subchannel assignment";
      set_bit(DEVICE_CATEGORY_MISC, dc->categories);
@@ -716,11 +715,11 @@ static void vfio_ccw_class_init(ObjectClass *klass, void *data)
      object_class_property_set_description(klass, /* 3.0 */
                                            "force-orb-pfch",
                                            "Force unlimited prefetch");
-#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");
+    }
      object_class_property_set_description(klass, /* 9.2 */
                                            "loadparm",
                                            "Define which devices that can be used for booting");
diff --git a/hw/vfio/meson.build b/hw/vfio/meson.build
index 510ebe6d720..bd6e1d999e4 100644
--- a/hw/vfio/meson.build
+++ b/hw/vfio/meson.build
@@ -7,7 +7,6 @@ vfio_ss.add(when: 'CONFIG_PSERIES', if_true: files('spapr.c'))
  vfio_ss.add(when: 'CONFIG_VFIO_PCI', if_true: files(
    'pci-quirks.c',
  ))
-vfio_ss.add(when: 'CONFIG_VFIO_CCW', if_true: files('ccw.c'))
  vfio_ss.add(when: 'CONFIG_VFIO_PLATFORM', if_true: files('platform.c'))
specific_ss.add_all(when: 'CONFIG_VFIO', if_true: vfio_ss)
@@ -26,6 +25,7 @@ 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_CCW', if_true: files('ccw.c'))
  system_ss.add(when: 'CONFIG_VFIO_PCI', if_true: files(
    'display.c',
    'pci.c',

Reviewed-by: Pierrick Bouvier <pierrick.bouvier@xxxxxxxxxx>





[Index of Archives]     [KVM ARM]     [KVM ia64]     [KVM ppc]     [Virtualization Tools]     [Spice Development]     [Libvirt]     [Libvirt Users]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite Questions]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux