public inbox for qemu-devel@nongnu.org
 help / color / mirror / Atom feed
* [PATCH v4 0/8] hw/vfio: single-binary
@ 2026-03-17 19:42 Pierrick Bouvier
  2026-03-17 19:42 ` [PATCH v4 1/8] hw/vfio/listener.c: remove CONFIG_KVM Pierrick Bouvier
                   ` (9 more replies)
  0 siblings, 10 replies; 20+ messages in thread
From: Pierrick Bouvier @ 2026-03-17 19:42 UTC (permalink / raw)
  To: qemu-devel
  Cc: Pierrick Bouvier, Cédric Le Goater, Richard Henderson,
	eric.auger, qemu-ppc, Paolo Bonzini, philmd

This series makes changes to hw/vfio to compile files only once.
Changes are pretty straightforward and are mostly extraction of kvm/other config
specific functions to proper files.
This is the last hw/* subsystem that needs to be changed for single-binary.

v4
--

- rewrite commit description for "hw/vfio: eradicate CONFIG_IOMMU from sources"

v2 (sent as v3)
---------------

- use global stub_ss (fix some missing dependencies in this case)
- move kvm_enabled() guard check on function calls
- s/Vfio spapr kvm/VFIO sPAPR KVM/

Pierrick Bouvier (8):
  hw/vfio/listener.c: remove CONFIG_KVM
  hw/vfio/helpers.c: extract kvm helpers in kvm-helpers.c
  hw/vfio/pci-quirks.c: remove CONFIG_VFIO_IGD
  hw/vfio: eradicate CONFIG_IOMMU from sources
  hw/vfio/pci.c: eradicate CONFIG_KVM
  hw/vfio/ap.c: use full path for target specific header
  hw/vfio/spapr.c: extract vfio_spapr_kvm_attach_tce to
    hw/vfio/kvm-spapr.c
  hw/vfio: all vfio files can now be common files

 meson.build                  |   2 +-
 hw/vfio/kvm-spapr.h          |  12 +++
 hw/vfio/pci.h                |   2 +
 target/s390x/kvm/kvm_s390x.h |   2 +-
 hw/vfio/ap.c                 |  11 +-
 hw/vfio/ccw.c                |   9 --
 hw/vfio/helpers.c            | 172 -------------------------------
 hw/vfio/igd-stubs.c          |  20 ++++
 hw/vfio/kvm-helpers.c        | 192 +++++++++++++++++++++++++++++++++++
 hw/vfio/kvm-spapr.c          |  47 +++++++++
 hw/vfio/kvm-stubs.c          |  34 +++++++
 hw/vfio/listener.c           |   4 -
 hw/vfio/pci-quirks.c         |   5 -
 hw/vfio/pci.c                |  39 ++-----
 hw/vfio/spapr.c              |  30 +-----
 hw/vfio/meson.build          |   6 +-
 16 files changed, 329 insertions(+), 258 deletions(-)
 create mode 100644 hw/vfio/kvm-spapr.h
 create mode 100644 hw/vfio/igd-stubs.c
 create mode 100644 hw/vfio/kvm-helpers.c
 create mode 100644 hw/vfio/kvm-spapr.c
 create mode 100644 hw/vfio/kvm-stubs.c

-- 
2.47.3



^ permalink raw reply	[flat|nested] 20+ messages in thread

* [PATCH v4 1/8] hw/vfio/listener.c: remove CONFIG_KVM
  2026-03-17 19:42 [PATCH v4 0/8] hw/vfio: single-binary Pierrick Bouvier
@ 2026-03-17 19:42 ` Pierrick Bouvier
  2026-03-17 19:42 ` [PATCH v4 2/8] hw/vfio/helpers.c: extract kvm helpers in kvm-helpers.c Pierrick Bouvier
                   ` (8 subsequent siblings)
  9 siblings, 0 replies; 20+ messages in thread
From: Pierrick Bouvier @ 2026-03-17 19:42 UTC (permalink / raw)
  To: qemu-devel
  Cc: Pierrick Bouvier, Cédric Le Goater, Richard Henderson,
	eric.auger, qemu-ppc, Paolo Bonzini, philmd

Code concerned is under a kvm_enabled() guard.

Reviewed-by: Cédric Le Goater <clg@redhat.com>
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Signed-off-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
---
 hw/vfio/listener.c | 4 ----
 1 file changed, 4 deletions(-)

diff --git a/hw/vfio/listener.c b/hw/vfio/listener.c
index 960da9e0a93..31c3113f8fb 100644
--- a/hw/vfio/listener.c
+++ b/hw/vfio/listener.c
@@ -20,9 +20,7 @@
 
 #include "qemu/osdep.h"
 #include <sys/ioctl.h>
-#ifdef CONFIG_KVM
 #include <linux/kvm.h>
-#endif
 #include <linux/vfio.h>
 
 #include "exec/target_page.h"
@@ -303,11 +301,9 @@ static bool vfio_ram_discard_register_listener(VFIOContainer *bcontainer,
     if (bcontainer->dma_max_mappings) {
         unsigned int vrdl_count = 0, vrdl_mappings = 0, max_memslots = 512;
 
-#ifdef CONFIG_KVM
         if (kvm_enabled()) {
             max_memslots = kvm_get_max_memslots();
         }
-#endif
 
         QLIST_FOREACH(vrdl, &bcontainer->vrdl_list, next) {
             hwaddr start, end;
-- 
2.47.3



^ permalink raw reply related	[flat|nested] 20+ messages in thread

* [PATCH v4 2/8] hw/vfio/helpers.c: extract kvm helpers in kvm-helpers.c
  2026-03-17 19:42 [PATCH v4 0/8] hw/vfio: single-binary Pierrick Bouvier
  2026-03-17 19:42 ` [PATCH v4 1/8] hw/vfio/listener.c: remove CONFIG_KVM Pierrick Bouvier
@ 2026-03-17 19:42 ` Pierrick Bouvier
  2026-03-17 19:42 ` [PATCH v4 3/8] hw/vfio/pci-quirks.c: remove CONFIG_VFIO_IGD Pierrick Bouvier
                   ` (7 subsequent siblings)
  9 siblings, 0 replies; 20+ messages in thread
From: Pierrick Bouvier @ 2026-03-17 19:42 UTC (permalink / raw)
  To: qemu-devel
  Cc: Pierrick Bouvier, Cédric Le Goater, Richard Henderson,
	eric.auger, qemu-ppc, Paolo Bonzini, philmd

Because those functions use kvm specific types, they need to be isolated
in another source file.
This allows us to link kvm-helpers only in configurations with
CONFIG_KVM.

Reviewed-by: Cédric Le Goater <clg@redhat.com>
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Signed-off-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
---
 hw/vfio/helpers.c     | 172 -------------------------------------
 hw/vfio/kvm-helpers.c | 192 ++++++++++++++++++++++++++++++++++++++++++
 hw/vfio/kvm-stubs.c   |  26 ++++++
 hw/vfio/meson.build   |   2 +
 4 files changed, 220 insertions(+), 172 deletions(-)
 create mode 100644 hw/vfio/kvm-helpers.c
 create mode 100644 hw/vfio/kvm-stubs.c

diff --git a/hw/vfio/helpers.c b/hw/vfio/helpers.c
index 00d42d3b98e..65c6dba0428 100644
--- a/hw/vfio/helpers.c
+++ b/hw/vfio/helpers.c
@@ -22,7 +22,6 @@
 #include "qemu/osdep.h"
 #include <sys/ioctl.h>
 
-#include "system/kvm.h"
 #include "exec/cpu-common.h"
 #include "hw/vfio/vfio-device.h"
 #include "hw/core/hw-error.h"
@@ -107,177 +106,6 @@ bool vfio_get_info_dma_avail(struct vfio_iommu_type1_info *info,
     return true;
 }
 
-#ifdef CONFIG_KVM
-/*
- * We have a single VFIO pseudo device per KVM VM.  Once created it lives
- * for the life of the VM.  Closing the file descriptor only drops our
- * reference to it and the device's reference to kvm.  Therefore once
- * initialized, this file descriptor is only released on QEMU exit and
- * we'll re-use it should another vfio device be attached before then.
- */
-int vfio_kvm_device_fd = -1;
-
-/*
- * Confidential virtual machines:
- * During reset of confidential vms, the kvm vm file descriptor changes.
- * In this case, the old vfio kvm file descriptor is
- * closed and a new descriptor is created against the new kvm vm file
- * descriptor.
- */
-
-typedef struct VFIODeviceFd {
-    int fd;
-    QLIST_ENTRY(VFIODeviceFd) node;
-} VFIODeviceFd;
-
-static QLIST_HEAD(, VFIODeviceFd) vfio_device_fds =
-    QLIST_HEAD_INITIALIZER(vfio_device_fds);
-
-static void vfio_device_fd_list_add(int fd)
-{
-    VFIODeviceFd *file_fd;
-    file_fd = g_malloc0(sizeof(*file_fd));
-    file_fd->fd = fd;
-    QLIST_INSERT_HEAD(&vfio_device_fds, file_fd, node);
-}
-
-static void vfio_device_fd_list_remove(int fd)
-{
-    VFIODeviceFd *file_fd, *next;
-
-    QLIST_FOREACH_SAFE(file_fd, &vfio_device_fds, node, next) {
-        if (file_fd->fd == fd) {
-            QLIST_REMOVE(file_fd, node);
-            g_free(file_fd);
-            break;
-        }
-    }
-}
-
-static int vfio_device_fd_rebind(NotifierWithReturn *notifier, void *data,
-                                  Error **errp)
-{
-    VFIODeviceFd *file_fd;
-    struct kvm_device_attr attr = {
-        .group = KVM_DEV_VFIO_FILE,
-        .attr = KVM_DEV_VFIO_FILE_ADD,
-    };
-    struct kvm_create_device cd = {
-        .type = KVM_DEV_TYPE_VFIO,
-    };
-
-    /* we are not interested in pre vmfd change notification */
-    if (((VmfdChangeNotifier *)data)->pre) {
-        return 0;
-    }
-
-    if (kvm_vm_ioctl(kvm_state, KVM_CREATE_DEVICE, &cd)) {
-        error_setg_errno(errp, errno, "Failed to create KVM VFIO device");
-        return -errno;
-    }
-
-    if (vfio_kvm_device_fd != -1) {
-        close(vfio_kvm_device_fd);
-    }
-
-    vfio_kvm_device_fd = cd.fd;
-
-    QLIST_FOREACH(file_fd, &vfio_device_fds, node) {
-        attr.addr = (uint64_t)(unsigned long)&file_fd->fd;
-        if (ioctl(vfio_kvm_device_fd, KVM_SET_DEVICE_ATTR, &attr)) {
-            error_setg_errno(errp, errno,
-                             "Failed to add fd %d to KVM VFIO device",
-                             file_fd->fd);
-            return -errno;
-        }
-    }
-    return 0;
-}
-
-static struct NotifierWithReturn vfio_vmfd_change_notifier = {
-    .notify = vfio_device_fd_rebind,
-};
-
-#endif
-
-void vfio_kvm_device_close(void)
-{
-#ifdef CONFIG_KVM
-    kvm_close();
-    if (vfio_kvm_device_fd != -1) {
-        close(vfio_kvm_device_fd);
-        vfio_kvm_device_fd = -1;
-    }
-#endif
-}
-
-int vfio_kvm_device_add_fd(int fd, Error **errp)
-{
-#ifdef CONFIG_KVM
-    struct kvm_device_attr attr = {
-        .group = KVM_DEV_VFIO_FILE,
-        .attr = KVM_DEV_VFIO_FILE_ADD,
-        .addr = (uint64_t)(unsigned long)&fd,
-    };
-
-    if (!kvm_enabled()) {
-        return 0;
-    }
-
-    if (vfio_kvm_device_fd < 0) {
-        struct kvm_create_device cd = {
-            .type = KVM_DEV_TYPE_VFIO,
-        };
-
-        if (kvm_vm_ioctl(kvm_state, KVM_CREATE_DEVICE, &cd)) {
-            error_setg_errno(errp, errno, "Failed to create KVM VFIO device");
-            return -errno;
-        }
-
-        vfio_kvm_device_fd = cd.fd;
-        /*
-         * If the vm file descriptor changes, add a notifier so that we can
-         * re-create the vfio_kvm_device_fd.
-         */
-        kvm_vmfd_add_change_notifier(&vfio_vmfd_change_notifier);
-    }
-
-    if (ioctl(vfio_kvm_device_fd, KVM_SET_DEVICE_ATTR, &attr)) {
-        error_setg_errno(errp, errno, "Failed to add fd %d to KVM VFIO device",
-                         fd);
-        return -errno;
-    }
-
-    vfio_device_fd_list_add(fd);
-#endif
-    return 0;
-}
-
-int vfio_kvm_device_del_fd(int fd, Error **errp)
-{
-#ifdef CONFIG_KVM
-    struct kvm_device_attr attr = {
-        .group = KVM_DEV_VFIO_FILE,
-        .attr = KVM_DEV_VFIO_FILE_DEL,
-        .addr = (uint64_t)(unsigned long)&fd,
-    };
-
-    if (vfio_kvm_device_fd < 0) {
-        error_setg(errp, "KVM VFIO device isn't created yet");
-        return -EINVAL;
-    }
-
-    if (ioctl(vfio_kvm_device_fd, KVM_SET_DEVICE_ATTR, &attr)) {
-        error_setg_errno(errp, errno,
-                         "Failed to remove fd %d from KVM VFIO device", fd);
-        return -errno;
-    }
-
-    vfio_device_fd_list_remove(fd);
-#endif
-    return 0;
-}
-
 struct vfio_device_info *vfio_get_device_info(int fd)
 {
     struct vfio_device_info *info;
diff --git a/hw/vfio/kvm-helpers.c b/hw/vfio/kvm-helpers.c
new file mode 100644
index 00000000000..d71c9590aaa
--- /dev/null
+++ b/hw/vfio/kvm-helpers.c
@@ -0,0 +1,192 @@
+/*
+ * low level and IOMMU backend agnostic helpers used by VFIO devices,
+ * related to regions, interrupts, capabilities
+ *
+ * Copyright Red Hat, Inc. 2012
+ *
+ * Authors:
+ *  Alex Williamson <alex.williamson@redhat.com>
+ *
+ * SPDX-License-Identifier: GPL-2.0-or-later
+ *
+ * Based on qemu-kvm device-assignment:
+ *  Adapted for KVM by Qumranet.
+ *  Copyright (c) 2007, Neocleus, Alex Novik (alex@neocleus.com)
+ *  Copyright (c) 2007, Neocleus, Guy Zana (guy@neocleus.com)
+ *  Copyright (C) 2008, Qumranet, Amit Shah (amit.shah@qumranet.com)
+ *  Copyright (C) 2008, Red Hat, Amit Shah (amit.shah@redhat.com)
+ *  Copyright (C) 2008, IBM, Muli Ben-Yehuda (muli@il.ibm.com)
+ */
+
+#include "qemu/osdep.h"
+#include <sys/ioctl.h>
+
+#include <linux/kvm.h>
+#include "system/kvm.h"
+#include "exec/cpu-common.h"
+#include "hw/vfio/vfio-device.h"
+#include "hw/core/hw-error.h"
+#include "qapi/error.h"
+#include "vfio-helpers.h"
+
+/*
+ * We have a single VFIO pseudo device per KVM VM.  Once created it lives
+ * for the life of the VM.  Closing the file descriptor only drops our
+ * reference to it and the device's reference to kvm.  Therefore once
+ * initialized, this file descriptor is only released on QEMU exit and
+ * we'll re-use it should another vfio device be attached before then.
+ */
+int vfio_kvm_device_fd = -1;
+
+/*
+ * Confidential virtual machines:
+ * During reset of confidential vms, the kvm vm file descriptor changes.
+ * In this case, the old vfio kvm file descriptor is
+ * closed and a new descriptor is created against the new kvm vm file
+ * descriptor.
+ */
+
+typedef struct VFIODeviceFd {
+    int fd;
+    QLIST_ENTRY(VFIODeviceFd) node;
+} VFIODeviceFd;
+
+static QLIST_HEAD(, VFIODeviceFd) vfio_device_fds =
+    QLIST_HEAD_INITIALIZER(vfio_device_fds);
+
+static void vfio_device_fd_list_add(int fd)
+{
+    VFIODeviceFd *file_fd;
+    file_fd = g_malloc0(sizeof(*file_fd));
+    file_fd->fd = fd;
+    QLIST_INSERT_HEAD(&vfio_device_fds, file_fd, node);
+}
+
+static void vfio_device_fd_list_remove(int fd)
+{
+    VFIODeviceFd *file_fd, *next;
+
+    QLIST_FOREACH_SAFE(file_fd, &vfio_device_fds, node, next) {
+        if (file_fd->fd == fd) {
+            QLIST_REMOVE(file_fd, node);
+            g_free(file_fd);
+            break;
+        }
+    }
+}
+
+static int vfio_device_fd_rebind(NotifierWithReturn *notifier, void *data,
+                                  Error **errp)
+{
+    VFIODeviceFd *file_fd;
+    struct kvm_device_attr attr = {
+        .group = KVM_DEV_VFIO_FILE,
+        .attr = KVM_DEV_VFIO_FILE_ADD,
+    };
+    struct kvm_create_device cd = {
+        .type = KVM_DEV_TYPE_VFIO,
+    };
+
+    /* we are not interested in pre vmfd change notification */
+    if (((VmfdChangeNotifier *)data)->pre) {
+        return 0;
+    }
+
+    if (kvm_vm_ioctl(kvm_state, KVM_CREATE_DEVICE, &cd)) {
+        error_setg_errno(errp, errno, "Failed to create KVM VFIO device");
+        return -errno;
+    }
+
+    if (vfio_kvm_device_fd != -1) {
+        close(vfio_kvm_device_fd);
+    }
+
+    vfio_kvm_device_fd = cd.fd;
+
+    QLIST_FOREACH(file_fd, &vfio_device_fds, node) {
+        attr.addr = (uint64_t)(unsigned long)&file_fd->fd;
+        if (ioctl(vfio_kvm_device_fd, KVM_SET_DEVICE_ATTR, &attr)) {
+            error_setg_errno(errp, errno,
+                             "Failed to add fd %d to KVM VFIO device",
+                             file_fd->fd);
+            return -errno;
+        }
+    }
+    return 0;
+}
+
+static struct NotifierWithReturn vfio_vmfd_change_notifier = {
+    .notify = vfio_device_fd_rebind,
+};
+
+void vfio_kvm_device_close(void)
+{
+    kvm_close();
+    if (vfio_kvm_device_fd != -1) {
+        close(vfio_kvm_device_fd);
+        vfio_kvm_device_fd = -1;
+    }
+}
+
+int vfio_kvm_device_add_fd(int fd, Error **errp)
+{
+    struct kvm_device_attr attr = {
+        .group = KVM_DEV_VFIO_FILE,
+        .attr = KVM_DEV_VFIO_FILE_ADD,
+        .addr = (uint64_t)(unsigned long)&fd,
+    };
+
+    if (!kvm_enabled()) {
+        return 0;
+    }
+
+    if (vfio_kvm_device_fd < 0) {
+        struct kvm_create_device cd = {
+            .type = KVM_DEV_TYPE_VFIO,
+        };
+
+        if (kvm_vm_ioctl(kvm_state, KVM_CREATE_DEVICE, &cd)) {
+            error_setg_errno(errp, errno, "Failed to create KVM VFIO device");
+            return -errno;
+        }
+
+        vfio_kvm_device_fd = cd.fd;
+        /*
+         * If the vm file descriptor changes, add a notifier so that we can
+         * re-create the vfio_kvm_device_fd.
+         */
+        kvm_vmfd_add_change_notifier(&vfio_vmfd_change_notifier);
+    }
+
+    if (ioctl(vfio_kvm_device_fd, KVM_SET_DEVICE_ATTR, &attr)) {
+        error_setg_errno(errp, errno, "Failed to add fd %d to KVM VFIO device",
+                         fd);
+        return -errno;
+    }
+
+    vfio_device_fd_list_add(fd);
+    return 0;
+}
+
+int vfio_kvm_device_del_fd(int fd, Error **errp)
+{
+    struct kvm_device_attr attr = {
+        .group = KVM_DEV_VFIO_FILE,
+        .attr = KVM_DEV_VFIO_FILE_DEL,
+        .addr = (uint64_t)(unsigned long)&fd,
+    };
+
+    if (vfio_kvm_device_fd < 0) {
+        error_setg(errp, "KVM VFIO device isn't created yet");
+        return -EINVAL;
+    }
+
+    if (ioctl(vfio_kvm_device_fd, KVM_SET_DEVICE_ATTR, &attr)) {
+        error_setg_errno(errp, errno,
+                         "Failed to remove fd %d from KVM VFIO device", fd);
+        return -errno;
+    }
+
+    vfio_device_fd_list_remove(fd);
+    return 0;
+}
diff --git a/hw/vfio/kvm-stubs.c b/hw/vfio/kvm-stubs.c
new file mode 100644
index 00000000000..5a489d1b711
--- /dev/null
+++ b/hw/vfio/kvm-stubs.c
@@ -0,0 +1,26 @@
+/*
+ * Stubs for kvm helpers
+ *
+ * SPDX-License-Identifier: GPL-2.0-or-later
+ */
+
+#include "qemu/osdep.h"
+
+#include "hw/vfio/vfio-device.h"
+#include "qapi/error.h"
+#include "vfio-helpers.h"
+
+void vfio_kvm_device_close(void)
+{
+    return;
+}
+
+int vfio_kvm_device_add_fd(int fd, Error **errp)
+{
+    return 0;
+}
+
+int vfio_kvm_device_del_fd(int fd, Error **errp)
+{
+    return 0;
+}
diff --git a/hw/vfio/meson.build b/hw/vfio/meson.build
index 82f68698fb8..f2a7728d3d0 100644
--- a/hw/vfio/meson.build
+++ b/hw/vfio/meson.build
@@ -7,6 +7,8 @@ vfio_ss.add(files(
   'container-legacy.c',
   'helpers.c',
 ))
+vfio_ss.add(when: 'CONFIG_KVM', if_true: files('kvm-helpers.c'))
+stub_ss.add(files('kvm-stubs.c'))
 vfio_ss.add(when: 'CONFIG_PSERIES', if_true: files('spapr.c'))
 vfio_ss.add(when: 'CONFIG_VFIO_PCI', if_true: files(
   'pci-quirks.c',
-- 
2.47.3



^ permalink raw reply related	[flat|nested] 20+ messages in thread

* [PATCH v4 3/8] hw/vfio/pci-quirks.c: remove CONFIG_VFIO_IGD
  2026-03-17 19:42 [PATCH v4 0/8] hw/vfio: single-binary Pierrick Bouvier
  2026-03-17 19:42 ` [PATCH v4 1/8] hw/vfio/listener.c: remove CONFIG_KVM Pierrick Bouvier
  2026-03-17 19:42 ` [PATCH v4 2/8] hw/vfio/helpers.c: extract kvm helpers in kvm-helpers.c Pierrick Bouvier
@ 2026-03-17 19:42 ` Pierrick Bouvier
  2026-03-18  8:11   ` Cédric Le Goater
  2026-03-17 19:42 ` [PATCH v4 4/8] hw/vfio: eradicate CONFIG_IOMMU from sources Pierrick Bouvier
                   ` (6 subsequent siblings)
  9 siblings, 1 reply; 20+ messages in thread
From: Pierrick Bouvier @ 2026-03-17 19:42 UTC (permalink / raw)
  To: qemu-devel
  Cc: Pierrick Bouvier, Cédric Le Goater, Richard Henderson,
	eric.auger, qemu-ppc, Paolo Bonzini, philmd

Add stubs for needed functions.

As well, we need to add pixman to qemuutil library dependencies since
pixman is transitively included from pci.h header, which is needed to be
able to include prototypes for stubs we declared.
In file included from include/ui/console.h:4,
                 from ../hw/vfio/vfio-display.h:12,
                 from ../hw/vfio/pci.h:25,
                 from ../hw/vfio/igd-stubs.c:9:
include/ui/qemu-pixman.h:10:10: fatal error: pixman.h: No such file or directory
   10 | #include <pixman.h>
      |          ^~~~~~~~~~

On OpenBSD, opengl headers are not available in default include path,
and thus we need to add opengl to list of qemuutil dependencies.
In file included from /home/root/qemu/include/ui/console.h:9:
/home/root/qemu/include/ui/surface.h:11:11: fatal error: 'epoxy/gl.h' file not found

Finally, vfio_pci_hot_reset_info must be forwarded declared on non linux
platforms:
In file included from ../hw/vfio/igd-stubs.c:9:
../hw/vfio/pci.h:265:44: error: 'struct vfio_pci_hot_reset_info' declared inside parameter list will not be visible outside of this definition or declaration [-Werror]
  265 |                                     struct vfio_pci_hot_reset_info **info_p);
      |

Reviewed-by: Cédric Le Goater <clg@redhat.com>
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Signed-off-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>

Signed-off-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
---
 meson.build          |  2 +-
 hw/vfio/pci.h        |  2 ++
 hw/vfio/igd-stubs.c  | 20 ++++++++++++++++++++
 hw/vfio/pci-quirks.c |  5 -----
 hw/vfio/meson.build  |  1 +
 5 files changed, 24 insertions(+), 6 deletions(-)
 create mode 100644 hw/vfio/igd-stubs.c

diff --git a/meson.build b/meson.build
index b2154bb9287..ab726ea1152 100644
--- a/meson.build
+++ b/meson.build
@@ -3781,7 +3781,7 @@ util_ss = util_ss.apply({})
 libqemuutil = static_library('qemuutil',
                              build_by_default: false,
                              sources: util_ss.sources() + stub_ss.sources() + genh,
-                             dependencies: [util_ss.dependencies(), libm, threads, glib, socket, malloc, rt])
+                             dependencies: [util_ss.dependencies(), libm, threads, glib, socket, malloc, rt, pixman, opengl])
 qemuutil = declare_dependency(link_with: libqemuutil,
                               sources: genh + version_res,
                               dependencies: [event_loop_base])
diff --git a/hw/vfio/pci.h b/hw/vfio/pci.h
index d6495d7f297..c3a1f53d350 100644
--- a/hw/vfio/pci.h
+++ b/hw/vfio/pci.h
@@ -258,6 +258,8 @@ bool vfio_probe_igd_config_quirk(VFIOPCIDevice *vdev, Error **errp);
 
 extern const PropertyInfo qdev_prop_nv_gpudirect_clique;
 
+struct vfio_pci_hot_reset_info;
+
 void vfio_pci_pre_reset(VFIOPCIDevice *vdev);
 void vfio_pci_post_reset(VFIOPCIDevice *vdev);
 bool vfio_pci_host_match(PCIHostDeviceAddress *addr, const char *name);
diff --git a/hw/vfio/igd-stubs.c b/hw/vfio/igd-stubs.c
new file mode 100644
index 00000000000..f7687d90912
--- /dev/null
+++ b/hw/vfio/igd-stubs.c
@@ -0,0 +1,20 @@
+/*
+ * IGD device quirks stubs
+ *
+ * SPDX-License-Identifier: GPL-2.0-or-later
+ */
+
+#include "qemu/osdep.h"
+#include "qapi/qmp/qerror.h"
+#include "pci.h"
+#include "pci-quirks.h"
+
+void vfio_probe_igd_bar0_quirk(VFIOPCIDevice *vdev, int nr)
+{
+    return;
+}
+
+bool vfio_probe_igd_config_quirk(VFIOPCIDevice *vdev, Error **errp)
+{
+    return true;
+}
diff --git a/hw/vfio/pci-quirks.c b/hw/vfio/pci-quirks.c
index 7b907b9360d..ab864048943 100644
--- a/hw/vfio/pci-quirks.c
+++ b/hw/vfio/pci-quirks.c
@@ -11,7 +11,6 @@
  */
 
 #include "qemu/osdep.h"
-#include CONFIG_DEVICES
 #include "exec/memop.h"
 #include "qemu/units.h"
 #include "qemu/log.h"
@@ -1128,11 +1127,9 @@ static void vfio_probe_rtl8168_bar2_quirk(VFIOPCIDevice *vdev, int nr)
  */
 bool vfio_config_quirk_setup(VFIOPCIDevice *vdev, Error **errp)
 {
-#ifdef CONFIG_VFIO_IGD
     if (!vfio_probe_igd_config_quirk(vdev, errp)) {
         return false;
     }
-#endif
     return true;
 }
 
@@ -1179,9 +1176,7 @@ void vfio_bar_quirk_setup(VFIOPCIDevice *vdev, int nr)
     vfio_probe_nvidia_bar5_quirk(vdev, nr);
     vfio_probe_nvidia_bar0_quirk(vdev, nr);
     vfio_probe_rtl8168_bar2_quirk(vdev, nr);
-#ifdef CONFIG_VFIO_IGD
     vfio_probe_igd_bar0_quirk(vdev, nr);
-#endif
 }
 
 void vfio_bar_quirk_exit(VFIOPCIDevice *vdev, int nr)
diff --git a/hw/vfio/meson.build b/hw/vfio/meson.build
index f2a7728d3d0..6c00a7f51bb 100644
--- a/hw/vfio/meson.build
+++ b/hw/vfio/meson.build
@@ -17,6 +17,7 @@ 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_AP', if_true: files('ap.c'))
 vfio_ss.add(when: 'CONFIG_VFIO_IGD', if_true: files('igd.c'))
+stub_ss.add(files('igd-stubs.c'))
 
 specific_ss.add_all(when: 'CONFIG_VFIO', if_true: vfio_ss)
 
-- 
2.47.3



^ permalink raw reply related	[flat|nested] 20+ messages in thread

* [PATCH v4 4/8] hw/vfio: eradicate CONFIG_IOMMU from sources
  2026-03-17 19:42 [PATCH v4 0/8] hw/vfio: single-binary Pierrick Bouvier
                   ` (2 preceding siblings ...)
  2026-03-17 19:42 ` [PATCH v4 3/8] hw/vfio/pci-quirks.c: remove CONFIG_VFIO_IGD Pierrick Bouvier
@ 2026-03-17 19:42 ` Pierrick Bouvier
  2026-03-17 19:42 ` [PATCH v4 5/8] hw/vfio/pci.c: eradicate CONFIG_KVM Pierrick Bouvier
                   ` (5 subsequent siblings)
  9 siblings, 0 replies; 20+ messages in thread
From: Pierrick Bouvier @ 2026-03-17 19:42 UTC (permalink / raw)
  To: qemu-devel
  Cc: Pierrick Bouvier, Cédric Le Goater, Richard Henderson,
	eric.auger, qemu-ppc, Paolo Bonzini, philmd

This commit removes usage of CONFIG_IOMMU in hw/vfio sources, exposing
inconditionally iommufd related properties, which are declared
statically (in const arrays). The alternative to expose them dynamically
is more complex and requires boilerplate to set properties at runtime,
with set_* callbacks and added logic to check if iommufd backend is
available, with no obvious benefit.

One possible difference is that user may see a different error message
when trying to attach a vfio device with a QEMU not supporting iommufd,
without declaring iommufd object associated.

Instead of:
```
$ qemu-system-* -device vfio-pci,host=0000:01:00.0,iommufd=iommufd0
qemu-system-*: -device vfio-pci,host=0000:01:00.0,iommufd=iommufd0: Property 'vfio-pci.iommufd' not found
```
User will now see:
```
qemu-system-aarch64: -device vfio-pci,host=0000:01:00.0,iommufd=iommufd0: Device 'iommufd0' not found
```

However, since declaring the iommufd object is needed, error reported
before and after is still the same:
```
$ qemu-system-* -object iommufd,id=iommufd0 -device vfio-pci,host=0000:01:00.0,iommufd=iommufd0
qemu-system-*: invalid object type: iommufd
```

Signed-off-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
---
 hw/vfio/ap.c  |  9 ---------
 hw/vfio/ccw.c |  9 ---------
 hw/vfio/pci.c | 11 -----------
 3 files changed, 29 deletions(-)

diff --git a/hw/vfio/ap.c b/hw/vfio/ap.c
index e58a0169af9..856fa2678cd 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"
@@ -279,10 +278,8 @@ static void vfio_ap_unrealize(DeviceState *dev)
 
 static const Property vfio_ap_properties[] = {
     DEFINE_PROP_STRING("sysfsdev", VFIOAPDevice, vdev.sysfsdev),
-#ifdef CONFIG_IOMMUFD
     DEFINE_PROP_LINK("iommufd", VFIOAPDevice, vdev.iommufd,
                      TYPE_IOMMUFD_BACKEND, IOMMUFDBackend *),
-#endif
 };
 
 static void vfio_ap_reset(DeviceState *dev)
@@ -320,21 +317,17 @@ 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, const 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
     dc->vmsd = &vfio_ap_vmstate;
     dc->desc = "VFIO-based AP device assignment";
     set_bit(DEVICE_CATEGORY_MISC, dc->categories);
@@ -347,11 +340,9 @@ static void vfio_ap_class_init(ObjectClass *klass, const 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
 }
 
 static const TypeInfo vfio_ap_info = {
diff --git a/hw/vfio/ccw.c b/hw/vfio/ccw.c
index 2251facb356..c66f42a13c2 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>
@@ -647,10 +646,8 @@ 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_LINK("iommufd", VFIOCCWDevice, vdev.iommufd,
                      TYPE_IOMMUFD_BACKEND, IOMMUFDBackend *),
-#endif
     DEFINE_PROP_CCW_LOADPARM("loadparm", CcwDevice, loadparm),
 };
 
@@ -679,12 +676,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, const void *data)
 {
@@ -692,9 +687,7 @@ static void vfio_ccw_class_init(ObjectClass *klass, const 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
     dc->vmsd = &vfio_ccw_vmstate;
     dc->desc = "VFIO-based subchannel assignment";
     set_bit(DEVICE_CATEGORY_MISC, dc->categories);
@@ -713,11 +706,9 @@ static void vfio_ccw_class_init(ObjectClass *klass, const 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
     object_class_property_set_description(klass, /* 9.2 */
                                           "loadparm",
                                           "Define which devices that can be used for booting");
diff --git a/hw/vfio/pci.c b/hw/vfio/pci.c
index 94c174a773f..df617f1fe46 100644
--- a/hw/vfio/pci.c
+++ b/hw/vfio/pci.c
@@ -19,7 +19,6 @@
  */
 
 #include "qemu/osdep.h"
-#include CONFIG_DEVICES /* CONFIG_IOMMUFD */
 #include <linux/vfio.h>
 #include <sys/ioctl.h>
 
@@ -3471,9 +3470,7 @@ static void vfio_pci_realize(PCIDevice *pdev, Error **errp)
               ~vdev->host.slot || ~vdev->host.function)) {
             error_setg(errp, "No provided host device");
             error_append_hint(errp, "Use -device vfio-pci,host=DDDD:BB:DD.F "
-#ifdef CONFIG_IOMMUFD
                               "or -device vfio-pci,fd=DEVICE_FD "
-#endif
                               "or -device vfio-pci,sysfsdev=PATH_TO_DEVICE\n");
             return;
         }
@@ -3816,22 +3813,18 @@ static const Property vfio_pci_properties[] = {
                                    qdev_prop_nv_gpudirect_clique, uint8_t),
     DEFINE_PROP_OFF_AUTO_PCIBAR("x-msix-relocation", VFIOPCIDevice, msix_relo,
                                 OFF_AUTO_PCIBAR_OFF),
-#ifdef CONFIG_IOMMUFD
     DEFINE_PROP_LINK("iommufd", VFIOPCIDevice, vbasedev.iommufd,
                      TYPE_IOMMUFD_BACKEND, IOMMUFDBackend *),
-#endif
     DEFINE_PROP_BOOL("skip-vsc-check", VFIOPCIDevice, skip_vsc_check, true),
     DEFINE_PROP_UINT16("x-vpasid-cap-offset", VFIOPCIDevice,
                        vpasid_cap_offset, 0),
 };
 
-#ifdef CONFIG_IOMMUFD
 static void vfio_pci_set_fd(Object *obj, const char *str, Error **errp)
 {
     VFIOPCIDevice *vdev = VFIO_PCI_DEVICE(obj);
     vfio_device_set_fd(&vdev->vbasedev, str, errp);
 }
-#endif
 
 static void vfio_pci_class_init(ObjectClass *klass, const void *data)
 {
@@ -3840,9 +3833,7 @@ static void vfio_pci_class_init(ObjectClass *klass, const void *data)
 
     device_class_set_legacy_reset(dc, vfio_pci_reset);
     device_class_set_props(dc, vfio_pci_properties);
-#ifdef CONFIG_IOMMUFD
     object_class_property_add_str(klass, "fd", NULL, vfio_pci_set_fd);
-#endif
     dc->vmsd = &vfio_cpr_pci_vmstate;
     dc->desc = "VFIO-based PCI device assignment";
     pdc->realize = vfio_pci_realize;
@@ -3944,11 +3935,9 @@ static void vfio_pci_class_init(ObjectClass *klass, const void *data)
                                           "vf-token",
                                           "Specify UUID VF token. Required for VF when PF is owned "
                                           "by another VFIO driver");
-#ifdef CONFIG_IOMMUFD
     object_class_property_set_description(klass, /* 9.0 */
                                           "iommufd",
                                           "Set host IOMMUFD backend device");
-#endif
     object_class_property_set_description(klass, /* 9.1 */
                                           "x-device-dirty-page-tracking",
                                           "Disable device dirty page tracking and use "
-- 
2.47.3



^ permalink raw reply related	[flat|nested] 20+ messages in thread

* [PATCH v4 5/8] hw/vfio/pci.c: eradicate CONFIG_KVM
  2026-03-17 19:42 [PATCH v4 0/8] hw/vfio: single-binary Pierrick Bouvier
                   ` (3 preceding siblings ...)
  2026-03-17 19:42 ` [PATCH v4 4/8] hw/vfio: eradicate CONFIG_IOMMU from sources Pierrick Bouvier
@ 2026-03-17 19:42 ` Pierrick Bouvier
  2026-03-17 19:42 ` [PATCH v4 6/8] hw/vfio/ap.c: use full path for target specific header Pierrick Bouvier
                   ` (4 subsequent siblings)
  9 siblings, 0 replies; 20+ messages in thread
From: Pierrick Bouvier @ 2026-03-17 19:42 UTC (permalink / raw)
  To: qemu-devel
  Cc: Pierrick Bouvier, Cédric Le Goater, Richard Henderson,
	eric.auger, qemu-ppc, Paolo Bonzini, philmd

We just need to add kvm_enabled() guard when calling concerned
functions, but no need to extract those kvm functions since they are not
using any kvm specific types that would not be visible at compilation
time.

Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Signed-off-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
---
 hw/vfio/pci.c | 28 ++++++++++------------------
 1 file changed, 10 insertions(+), 18 deletions(-)

diff --git a/hw/vfio/pci.c b/hw/vfio/pci.c
index df617f1fe46..811e5001de5 100644
--- a/hw/vfio/pci.c
+++ b/hw/vfio/pci.c
@@ -152,7 +152,6 @@ void vfio_pci_intx_eoi(VFIODevice *vbasedev)
 
 static bool vfio_intx_enable_kvm(VFIOPCIDevice *vdev, Error **errp)
 {
-#ifdef CONFIG_KVM
     PCIDevice *pdev = PCI_DEVICE(vdev);
     int irq_fd = event_notifier_get_fd(&vdev->intx.interrupt);
 
@@ -206,14 +205,10 @@ fail:
     qemu_set_fd_handler(irq_fd, vfio_intx_interrupt, NULL, vdev);
     vfio_device_irq_unmask(&vdev->vbasedev, VFIO_PCI_INTX_IRQ_INDEX);
     return false;
-#else
-    return true;
-#endif
 }
 
 static bool vfio_cpr_intx_enable_kvm(VFIOPCIDevice *vdev, Error **errp)
 {
-#ifdef CONFIG_KVM
     if (vdev->no_kvm_intx || !kvm_irqfds_enabled() ||
         vdev->intx.route.mode != PCI_INTX_ENABLED ||
         !kvm_resamplefds_enabled()) {
@@ -236,14 +231,10 @@ static bool vfio_cpr_intx_enable_kvm(VFIOPCIDevice *vdev, Error **errp)
     vdev->intx.kvm_accel = true;
     trace_vfio_intx_enable_kvm(vdev->vbasedev.name);
     return true;
-#else
-    return true;
-#endif
 }
 
 static void vfio_intx_disable_kvm(VFIOPCIDevice *vdev)
 {
-#ifdef CONFIG_KVM
     PCIDevice *pdev = PCI_DEVICE(vdev);
 
     if (!vdev->intx.kvm_accel) {
@@ -277,7 +268,6 @@ static void vfio_intx_disable_kvm(VFIOPCIDevice *vdev)
     vfio_device_irq_unmask(&vdev->vbasedev, VFIO_PCI_INTX_IRQ_INDEX);
 
     trace_vfio_intx_disable_kvm(vdev->vbasedev.name);
-#endif
 }
 
 static void vfio_intx_update(VFIOPCIDevice *vdev, PCIINTxRoute *route)
@@ -287,7 +277,9 @@ static void vfio_intx_update(VFIOPCIDevice *vdev, PCIINTxRoute *route)
     trace_vfio_intx_update(vdev->vbasedev.name,
                            vdev->intx.route.irq, route->irq);
 
-    vfio_intx_disable_kvm(vdev);
+    if (kvm_enabled()) {
+        vfio_intx_disable_kvm(vdev);
+    }
 
     vdev->intx.route = *route;
 
@@ -295,7 +287,7 @@ static void vfio_intx_update(VFIOPCIDevice *vdev, PCIINTxRoute *route)
         return;
     }
 
-    if (!vfio_intx_enable_kvm(vdev, &err)) {
+    if (kvm_enabled() && !vfio_intx_enable_kvm(vdev, &err)) {
         warn_reportf_err(err, VFIO_MSG_PREFIX, vdev->vbasedev.name);
     }
 
@@ -350,16 +342,14 @@ static bool vfio_intx_enable(VFIOPCIDevice *vdev, Error **errp)
     vdev->intx.pin = pin - 1; /* Pin A (1) -> irq[0] */
     pci_config_set_interrupt_pin(pdev->config, pin);
 
-#ifdef CONFIG_KVM
     /*
      * Only conditional to avoid generating error messages on platforms
      * where we won't actually use the result anyway.
      */
-    if (kvm_irqfds_enabled() && kvm_resamplefds_enabled()) {
+    if (kvm_enabled() && kvm_irqfds_enabled() && kvm_resamplefds_enabled()) {
         vdev->intx.route = pci_device_route_intx_to_irq(pdev,
                                                         vdev->intx.pin);
     }
-#endif
 
     if (!vfio_notifier_init(vdev, &vdev->intx.interrupt, "intx-interrupt", 0,
                             errp)) {
@@ -370,7 +360,7 @@ static bool vfio_intx_enable(VFIOPCIDevice *vdev, Error **errp)
 
 
     if (cpr_is_incoming()) {
-        if (!vfio_cpr_intx_enable_kvm(vdev, &err)) {
+        if (kvm_enabled() && !vfio_cpr_intx_enable_kvm(vdev, &err)) {
             warn_reportf_err(err, VFIO_MSG_PREFIX, vdev->vbasedev.name);
         }
         goto skip_signaling;
@@ -383,7 +373,7 @@ static bool vfio_intx_enable(VFIOPCIDevice *vdev, Error **errp)
         return false;
     }
 
-    if (!vfio_intx_enable_kvm(vdev, &err)) {
+    if (kvm_enabled() && !vfio_intx_enable_kvm(vdev, &err)) {
         warn_reportf_err(err, VFIO_MSG_PREFIX, vdev->vbasedev.name);
     }
 
@@ -400,7 +390,9 @@ static void vfio_intx_disable(VFIOPCIDevice *vdev)
     int fd;
 
     timer_del(vdev->intx.mmap_timer);
-    vfio_intx_disable_kvm(vdev);
+    if (kvm_enabled()) {
+        vfio_intx_disable_kvm(vdev);
+    }
     vfio_device_irq_disable(&vdev->vbasedev, VFIO_PCI_INTX_IRQ_INDEX);
     vdev->intx.pending = false;
     pci_irq_deassert(pdev);
-- 
2.47.3



^ permalink raw reply related	[flat|nested] 20+ messages in thread

* [PATCH v4 6/8] hw/vfio/ap.c: use full path for target specific header
  2026-03-17 19:42 [PATCH v4 0/8] hw/vfio: single-binary Pierrick Bouvier
                   ` (4 preceding siblings ...)
  2026-03-17 19:42 ` [PATCH v4 5/8] hw/vfio/pci.c: eradicate CONFIG_KVM Pierrick Bouvier
@ 2026-03-17 19:42 ` Pierrick Bouvier
  2026-03-17 19:42 ` [PATCH v4 7/8] hw/vfio/spapr.c: extract vfio_spapr_kvm_attach_tce to hw/vfio/kvm-spapr.c Pierrick Bouvier
                   ` (3 subsequent siblings)
  9 siblings, 0 replies; 20+ messages in thread
From: Pierrick Bouvier @ 2026-03-17 19:42 UTC (permalink / raw)
  To: qemu-devel
  Cc: Pierrick Bouvier, Cédric Le Goater, Richard Henderson,
	eric.auger, qemu-ppc, Paolo Bonzini, philmd

In addition, we fix target/s390x/kvm/kvm_s390x.h cpu-qom include also.

Reviewed-by: Cédric Le Goater <clg@redhat.com>
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Signed-off-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
---
 target/s390x/kvm/kvm_s390x.h | 2 +-
 hw/vfio/ap.c                 | 2 +-
 2 files changed, 2 insertions(+), 2 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 856fa2678cd..3fae9ae9814 100644
--- a/hw/vfio/ap.c
+++ b/hw/vfio/ap.c
@@ -25,7 +25,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/core/qdev-properties.h"
 #include "hw/s390x/ap-bridge.h"
-- 
2.47.3



^ permalink raw reply related	[flat|nested] 20+ messages in thread

* [PATCH v4 7/8] hw/vfio/spapr.c: extract vfio_spapr_kvm_attach_tce to hw/vfio/kvm-spapr.c
  2026-03-17 19:42 [PATCH v4 0/8] hw/vfio: single-binary Pierrick Bouvier
                   ` (5 preceding siblings ...)
  2026-03-17 19:42 ` [PATCH v4 6/8] hw/vfio/ap.c: use full path for target specific header Pierrick Bouvier
@ 2026-03-17 19:42 ` Pierrick Bouvier
  2026-03-18  8:30   ` Cédric Le Goater
  2026-03-17 19:42 ` [PATCH v4 8/8] hw/vfio: all vfio files can now be common files Pierrick Bouvier
                   ` (2 subsequent siblings)
  9 siblings, 1 reply; 20+ messages in thread
From: Pierrick Bouvier @ 2026-03-17 19:42 UTC (permalink / raw)
  To: qemu-devel
  Cc: Pierrick Bouvier, Cédric Le Goater, Richard Henderson,
	eric.auger, qemu-ppc, Paolo Bonzini, philmd

Since this function needs kvm specific types, we need to extract in
another file and link it only for KVM builds.

Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Signed-off-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
---
 hw/vfio/kvm-spapr.h | 12 ++++++++++++
 hw/vfio/kvm-spapr.c | 47 +++++++++++++++++++++++++++++++++++++++++++++
 hw/vfio/kvm-stubs.c |  8 ++++++++
 hw/vfio/spapr.c     | 30 ++++-------------------------
 hw/vfio/meson.build |  1 +
 5 files changed, 72 insertions(+), 26 deletions(-)
 create mode 100644 hw/vfio/kvm-spapr.h
 create mode 100644 hw/vfio/kvm-spapr.c

diff --git a/hw/vfio/kvm-spapr.h b/hw/vfio/kvm-spapr.h
new file mode 100644
index 00000000000..b1f68c686a7
--- /dev/null
+++ b/hw/vfio/kvm-spapr.h
@@ -0,0 +1,12 @@
+/*
+ * VFIO sPAPR KVM specific functions
+ *
+ * SPDX-License-Identifier: GPL-2.0-or-later
+ */
+
+#include "hw/vfio/vfio-container.h"
+#include "qapi/error.h"
+
+bool vfio_spapr_kvm_attach_tce(VFIOContainer *bcontainer,
+                               MemoryRegionSection *section,
+                               Error **errp);
diff --git a/hw/vfio/kvm-spapr.c b/hw/vfio/kvm-spapr.c
new file mode 100644
index 00000000000..ad71c5a85e2
--- /dev/null
+++ b/hw/vfio/kvm-spapr.c
@@ -0,0 +1,47 @@
+/*
+ * VFIO sPAPR KVM specific functions
+ *
+ * SPDX-License-Identifier: GPL-2.0-or-later
+ */
+
+#include "qemu/osdep.h"
+#include <sys/ioctl.h>
+#include <linux/vfio.h>
+#include <linux/kvm.h>
+
+#include "hw/vfio/vfio-container-legacy.h"
+#include "hw/vfio/kvm-spapr.h"
+#include "qapi/error.h"
+#include "trace.h"
+#include "vfio-helpers.h"
+
+bool vfio_spapr_kvm_attach_tce(VFIOContainer *bcontainer,
+                               MemoryRegionSection *section,
+                               Error **errp)
+{
+    VFIOLegacyContainer *container = VFIO_IOMMU_LEGACY(bcontainer);
+    VFIOGroup *group;
+    IOMMUMemoryRegion *iommu_mr = IOMMU_MEMORY_REGION(section->mr);
+    struct kvm_vfio_spapr_tce param;
+    struct kvm_device_attr attr = {
+        .group = KVM_DEV_VFIO_GROUP,
+        .attr = KVM_DEV_VFIO_GROUP_SET_SPAPR_TCE,
+        .addr = (uint64_t)(unsigned long)&param,
+    };
+
+    if (!memory_region_iommu_get_attr(iommu_mr, IOMMU_ATTR_SPAPR_TCE_FD,
+                &param.tablefd)) {
+        QLIST_FOREACH(group, &container->group_list, container_next) {
+            param.groupfd = group->fd;
+            if (ioctl(vfio_kvm_device_fd, KVM_SET_DEVICE_ATTR, &attr)) {
+                error_setg_errno(errp, errno,
+                        "vfio: failed GROUP_SET_SPAPR_TCE for "
+                        "KVM VFIO device %d and group fd %d",
+                        param.tablefd, param.groupfd);
+                return false;
+            }
+            trace_vfio_spapr_group_attach(param.groupfd, param.tablefd);
+        }
+    }
+    return true;
+}
diff --git a/hw/vfio/kvm-stubs.c b/hw/vfio/kvm-stubs.c
index 5a489d1b711..78c51b99155 100644
--- a/hw/vfio/kvm-stubs.c
+++ b/hw/vfio/kvm-stubs.c
@@ -6,6 +6,7 @@
 
 #include "qemu/osdep.h"
 
+#include "hw/vfio/kvm-spapr.h"
 #include "hw/vfio/vfio-device.h"
 #include "qapi/error.h"
 #include "vfio-helpers.h"
@@ -24,3 +25,10 @@ int vfio_kvm_device_del_fd(int fd, Error **errp)
 {
     return 0;
 }
+
+bool vfio_spapr_kvm_attach_tce(VFIOContainer *bcontainer,
+                               MemoryRegionSection *section,
+                               Error **errp)
+{
+    g_assert_not_reached();
+}
diff --git a/hw/vfio/spapr.c b/hw/vfio/spapr.c
index a9f093c3570..42690e4323d 100644
--- a/hw/vfio/spapr.c
+++ b/hw/vfio/spapr.c
@@ -16,6 +16,7 @@
 #include "system/address-spaces.h"
 
 #include "hw/vfio/vfio-container-legacy.h"
+#include "hw/vfio/kvm-spapr.h"
 #include "hw/core/hw-error.h"
 #include "qemu/error-report.h"
 #include "qapi/error.h"
@@ -406,33 +407,10 @@ vfio_spapr_container_add_section_window(VFIOContainer *bcontainer,
     vfio_host_win_add(scontainer, section->offset_within_address_space,
                       section->offset_within_address_space +
                       int128_get64(section->size) - 1, pgsize);
-#ifdef CONFIG_KVM
-    if (kvm_enabled()) {
-        VFIOGroup *group;
-        IOMMUMemoryRegion *iommu_mr = IOMMU_MEMORY_REGION(section->mr);
-        struct kvm_vfio_spapr_tce param;
-        struct kvm_device_attr attr = {
-            .group = KVM_DEV_VFIO_GROUP,
-            .attr = KVM_DEV_VFIO_GROUP_SET_SPAPR_TCE,
-            .addr = (uint64_t)(unsigned long)&param,
-        };
-
-        if (!memory_region_iommu_get_attr(iommu_mr, IOMMU_ATTR_SPAPR_TCE_FD,
-                                          &param.tablefd)) {
-            QLIST_FOREACH(group, &container->group_list, container_next) {
-                param.groupfd = group->fd;
-                if (ioctl(vfio_kvm_device_fd, KVM_SET_DEVICE_ATTR, &attr)) {
-                    error_setg_errno(errp, errno,
-                                     "vfio: failed GROUP_SET_SPAPR_TCE for "
-                                     "KVM VFIO device %d and group fd %d",
-                                     param.tablefd, param.groupfd);
-                    return false;
-                }
-                trace_vfio_spapr_group_attach(param.groupfd, param.tablefd);
-            }
-        }
+    if (kvm_enabled() && !vfio_spapr_kvm_attach_tce(bcontainer, section, errp)) {
+        return false;
     }
-#endif
+
     return true;
 }
 
diff --git a/hw/vfio/meson.build b/hw/vfio/meson.build
index 6c00a7f51bb..bab5f2b7f15 100644
--- a/hw/vfio/meson.build
+++ b/hw/vfio/meson.build
@@ -10,6 +10,7 @@ vfio_ss.add(files(
 vfio_ss.add(when: 'CONFIG_KVM', if_true: files('kvm-helpers.c'))
 stub_ss.add(files('kvm-stubs.c'))
 vfio_ss.add(when: 'CONFIG_PSERIES', if_true: files('spapr.c'))
+vfio_ss.add(when: ['CONFIG_KVM', 'CONFIG_PSERIES'], if_true: files('kvm-spapr.c'))
 vfio_ss.add(when: 'CONFIG_VFIO_PCI', if_true: files(
   'pci-quirks.c',
   'pci.c',
-- 
2.47.3



^ permalink raw reply related	[flat|nested] 20+ messages in thread

* [PATCH v4 8/8] hw/vfio: all vfio files can now be common files
  2026-03-17 19:42 [PATCH v4 0/8] hw/vfio: single-binary Pierrick Bouvier
                   ` (6 preceding siblings ...)
  2026-03-17 19:42 ` [PATCH v4 7/8] hw/vfio/spapr.c: extract vfio_spapr_kvm_attach_tce to hw/vfio/kvm-spapr.c Pierrick Bouvier
@ 2026-03-17 19:42 ` Pierrick Bouvier
  2026-03-18  8:31   ` Cédric Le Goater
  2026-03-18  5:57 ` [PATCH v4 0/8] hw/vfio: single-binary Philippe Mathieu-Daudé
  2026-03-18 17:51 ` Pierrick Bouvier
  9 siblings, 1 reply; 20+ messages in thread
From: Pierrick Bouvier @ 2026-03-17 19:42 UTC (permalink / raw)
  To: qemu-devel
  Cc: Pierrick Bouvier, Cédric Le Goater, Richard Henderson,
	eric.auger, qemu-ppc, Paolo Bonzini, philmd

Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Signed-off-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
---
 hw/vfio/meson.build | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/hw/vfio/meson.build b/hw/vfio/meson.build
index bab5f2b7f15..fa0ea6ecf0e 100644
--- a/hw/vfio/meson.build
+++ b/hw/vfio/meson.build
@@ -20,7 +20,7 @@ vfio_ss.add(when: 'CONFIG_VFIO_AP', if_true: files('ap.c'))
 vfio_ss.add(when: 'CONFIG_VFIO_IGD', if_true: files('igd.c'))
 stub_ss.add(files('igd-stubs.c'))
 
-specific_ss.add_all(when: 'CONFIG_VFIO', if_true: vfio_ss)
+system_ss.add_all(when: 'CONFIG_VFIO', if_true: vfio_ss)
 
 system_ss.add(when: 'CONFIG_VFIO', if_true: files(
   'cpr.c',
-- 
2.47.3



^ permalink raw reply related	[flat|nested] 20+ messages in thread

* Re: [PATCH v4 0/8] hw/vfio: single-binary
  2026-03-17 19:42 [PATCH v4 0/8] hw/vfio: single-binary Pierrick Bouvier
                   ` (7 preceding siblings ...)
  2026-03-17 19:42 ` [PATCH v4 8/8] hw/vfio: all vfio files can now be common files Pierrick Bouvier
@ 2026-03-18  5:57 ` Philippe Mathieu-Daudé
  2026-03-18 17:48   ` Pierrick Bouvier
  2026-03-18 17:51 ` Pierrick Bouvier
  9 siblings, 1 reply; 20+ messages in thread
From: Philippe Mathieu-Daudé @ 2026-03-18  5:57 UTC (permalink / raw)
  To: Pierrick Bouvier, qemu-devel
  Cc: Cédric Le Goater, Richard Henderson, eric.auger, qemu-ppc,
	Paolo Bonzini

On 17/3/26 20:42, Pierrick Bouvier wrote:

> Pierrick Bouvier (8):
>    hw/vfio/listener.c: remove CONFIG_KVM
>    hw/vfio/helpers.c: extract kvm helpers in kvm-helpers.c
>    hw/vfio/pci-quirks.c: remove CONFIG_VFIO_IGD
>    hw/vfio: eradicate CONFIG_IOMMU from sources
>    hw/vfio/pci.c: eradicate CONFIG_KVM
>    hw/vfio/ap.c: use full path for target specific header
>    hw/vfio/spapr.c: extract vfio_spapr_kvm_attach_tce to
>      hw/vfio/kvm-spapr.c
>    hw/vfio: all vfio files can now be common files

Tested-by: Philippe Mathieu-Daudé <philmd@linaro.org>



^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [PATCH v4 3/8] hw/vfio/pci-quirks.c: remove CONFIG_VFIO_IGD
  2026-03-17 19:42 ` [PATCH v4 3/8] hw/vfio/pci-quirks.c: remove CONFIG_VFIO_IGD Pierrick Bouvier
@ 2026-03-18  8:11   ` Cédric Le Goater
  2026-03-18  9:46     ` Philippe Mathieu-Daudé
  2026-03-18 17:37     ` Pierrick Bouvier
  0 siblings, 2 replies; 20+ messages in thread
From: Cédric Le Goater @ 2026-03-18  8:11 UTC (permalink / raw)
  To: Pierrick Bouvier, qemu-devel
  Cc: Richard Henderson, eric.auger, qemu-ppc, Paolo Bonzini, philmd

On 3/17/26 20:42, Pierrick Bouvier wrote:
> Add stubs for needed functions.
> 
> As well, we need to add pixman to qemuutil library dependencies since
> pixman is transitively included from pci.h header, which is needed to be
> able to include prototypes for stubs we declared.
> In file included from include/ui/console.h:4,
>                   from ../hw/vfio/vfio-display.h:12,
>                   from ../hw/vfio/pci.h:25,
>                   from ../hw/vfio/igd-stubs.c:9:
> include/ui/qemu-pixman.h:10:10: fatal error: pixman.h: No such file or directory
>     10 | #include <pixman.h>
>        |          ^~~~~~~~~~
> 
> On OpenBSD, opengl headers are not available in default include path,
> and thus we need to add opengl to list of qemuutil dependencies.
> In file included from /home/root/qemu/include/ui/console.h:9:
> /home/root/qemu/include/ui/surface.h:11:11: fatal error: 'epoxy/gl.h' file not found
> 
> Finally, vfio_pci_hot_reset_info must be forwarded declared on non linux
> platforms:
> In file included from ../hw/vfio/igd-stubs.c:9:
> ../hw/vfio/pci.h:265:44: error: 'struct vfio_pci_hot_reset_info' declared inside parameter list will not be visible outside of this definition or declaration [-Werror]
>    265 |                                     struct vfio_pci_hot_reset_info **info_p);
>        |
> 
> Reviewed-by: Cédric Le Goater <clg@redhat.com>
> Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
> Signed-off-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
> 
> Signed-off-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>

Duplicated Signed-off-by. I can fix when applying.

Thanks,

C.

> ---
>   meson.build          |  2 +-
>   hw/vfio/pci.h        |  2 ++
>   hw/vfio/igd-stubs.c  | 20 ++++++++++++++++++++
>   hw/vfio/pci-quirks.c |  5 -----
>   hw/vfio/meson.build  |  1 +
>   5 files changed, 24 insertions(+), 6 deletions(-)
>   create mode 100644 hw/vfio/igd-stubs.c
> 
> diff --git a/meson.build b/meson.build
> index b2154bb9287..ab726ea1152 100644
> --- a/meson.build
> +++ b/meson.build
> @@ -3781,7 +3781,7 @@ util_ss = util_ss.apply({})
>   libqemuutil = static_library('qemuutil',
>                                build_by_default: false,
>                                sources: util_ss.sources() + stub_ss.sources() + genh,
> -                             dependencies: [util_ss.dependencies(), libm, threads, glib, socket, malloc, rt])
> +                             dependencies: [util_ss.dependencies(), libm, threads, glib, socket, malloc, rt, pixman, opengl])
>   qemuutil = declare_dependency(link_with: libqemuutil,
>                                 sources: genh + version_res,
>                                 dependencies: [event_loop_base])
> diff --git a/hw/vfio/pci.h b/hw/vfio/pci.h
> index d6495d7f297..c3a1f53d350 100644
> --- a/hw/vfio/pci.h
> +++ b/hw/vfio/pci.h
> @@ -258,6 +258,8 @@ bool vfio_probe_igd_config_quirk(VFIOPCIDevice *vdev, Error **errp);
>   
>   extern const PropertyInfo qdev_prop_nv_gpudirect_clique;
>   
> +struct vfio_pci_hot_reset_info;
> +
>   void vfio_pci_pre_reset(VFIOPCIDevice *vdev);
>   void vfio_pci_post_reset(VFIOPCIDevice *vdev);
>   bool vfio_pci_host_match(PCIHostDeviceAddress *addr, const char *name);
> diff --git a/hw/vfio/igd-stubs.c b/hw/vfio/igd-stubs.c
> new file mode 100644
> index 00000000000..f7687d90912
> --- /dev/null
> +++ b/hw/vfio/igd-stubs.c
> @@ -0,0 +1,20 @@
> +/*
> + * IGD device quirks stubs
> + *
> + * SPDX-License-Identifier: GPL-2.0-or-later
> + */
> +
> +#include "qemu/osdep.h"
> +#include "qapi/qmp/qerror.h"
> +#include "pci.h"
> +#include "pci-quirks.h"
> +
> +void vfio_probe_igd_bar0_quirk(VFIOPCIDevice *vdev, int nr)
> +{
> +    return;
> +}
> +
> +bool vfio_probe_igd_config_quirk(VFIOPCIDevice *vdev, Error **errp)
> +{
> +    return true;
> +}
> diff --git a/hw/vfio/pci-quirks.c b/hw/vfio/pci-quirks.c
> index 7b907b9360d..ab864048943 100644
> --- a/hw/vfio/pci-quirks.c
> +++ b/hw/vfio/pci-quirks.c
> @@ -11,7 +11,6 @@
>    */
>   
>   #include "qemu/osdep.h"
> -#include CONFIG_DEVICES
>   #include "exec/memop.h"
>   #include "qemu/units.h"
>   #include "qemu/log.h"
> @@ -1128,11 +1127,9 @@ static void vfio_probe_rtl8168_bar2_quirk(VFIOPCIDevice *vdev, int nr)
>    */
>   bool vfio_config_quirk_setup(VFIOPCIDevice *vdev, Error **errp)
>   {
> -#ifdef CONFIG_VFIO_IGD
>       if (!vfio_probe_igd_config_quirk(vdev, errp)) {
>           return false;
>       }
> -#endif
>       return true;
>   }
>   
> @@ -1179,9 +1176,7 @@ void vfio_bar_quirk_setup(VFIOPCIDevice *vdev, int nr)
>       vfio_probe_nvidia_bar5_quirk(vdev, nr);
>       vfio_probe_nvidia_bar0_quirk(vdev, nr);
>       vfio_probe_rtl8168_bar2_quirk(vdev, nr);
> -#ifdef CONFIG_VFIO_IGD
>       vfio_probe_igd_bar0_quirk(vdev, nr);
> -#endif
>   }
>   
>   void vfio_bar_quirk_exit(VFIOPCIDevice *vdev, int nr)
> diff --git a/hw/vfio/meson.build b/hw/vfio/meson.build
> index f2a7728d3d0..6c00a7f51bb 100644
> --- a/hw/vfio/meson.build
> +++ b/hw/vfio/meson.build
> @@ -17,6 +17,7 @@ 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_AP', if_true: files('ap.c'))
>   vfio_ss.add(when: 'CONFIG_VFIO_IGD', if_true: files('igd.c'))
> +stub_ss.add(files('igd-stubs.c'))
>   
>   specific_ss.add_all(when: 'CONFIG_VFIO', if_true: vfio_ss)
>   



^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [PATCH v4 7/8] hw/vfio/spapr.c: extract vfio_spapr_kvm_attach_tce to hw/vfio/kvm-spapr.c
  2026-03-17 19:42 ` [PATCH v4 7/8] hw/vfio/spapr.c: extract vfio_spapr_kvm_attach_tce to hw/vfio/kvm-spapr.c Pierrick Bouvier
@ 2026-03-18  8:30   ` Cédric Le Goater
  0 siblings, 0 replies; 20+ messages in thread
From: Cédric Le Goater @ 2026-03-18  8:30 UTC (permalink / raw)
  To: Pierrick Bouvier, qemu-devel
  Cc: Richard Henderson, eric.auger, qemu-ppc, Paolo Bonzini, philmd

On 3/17/26 20:42, Pierrick Bouvier wrote:
> Since this function needs kvm specific types, we need to extract in
> another file and link it only for KVM builds.
> 
> Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
> Signed-off-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
> ---
>   hw/vfio/kvm-spapr.h | 12 ++++++++++++
>   hw/vfio/kvm-spapr.c | 47 +++++++++++++++++++++++++++++++++++++++++++++
>   hw/vfio/kvm-stubs.c |  8 ++++++++
>   hw/vfio/spapr.c     | 30 ++++-------------------------

Next step (or prereq step I wonder) would be to move all the pseries
stuff under hw/ppc/spapr_pci_vfio.c.

I will take a look.

C.



>   hw/vfio/meson.build |  1 +
>   5 files changed, 72 insertions(+), 26 deletions(-)
>   create mode 100644 hw/vfio/kvm-spapr.h
>   create mode 100644 hw/vfio/kvm-spapr.c
> 
> diff --git a/hw/vfio/kvm-spapr.h b/hw/vfio/kvm-spapr.h
> new file mode 100644
> index 00000000000..b1f68c686a7
> --- /dev/null
> +++ b/hw/vfio/kvm-spapr.h
> @@ -0,0 +1,12 @@
> +/*
> + * VFIO sPAPR KVM specific functions
> + *
> + * SPDX-License-Identifier: GPL-2.0-or-later
> + */
> +
> +#include "hw/vfio/vfio-container.h"
> +#include "qapi/error.h"
> +
> +bool vfio_spapr_kvm_attach_tce(VFIOContainer *bcontainer,
> +                               MemoryRegionSection *section,
> +                               Error **errp);
> diff --git a/hw/vfio/kvm-spapr.c b/hw/vfio/kvm-spapr.c
> new file mode 100644
> index 00000000000..ad71c5a85e2
> --- /dev/null
> +++ b/hw/vfio/kvm-spapr.c
> @@ -0,0 +1,47 @@
> +/*
> + * VFIO sPAPR KVM specific functions
> + *
> + * SPDX-License-Identifier: GPL-2.0-or-later
> + */
> +
> +#include "qemu/osdep.h"
> +#include <sys/ioctl.h>
> +#include <linux/vfio.h>
> +#include <linux/kvm.h>
> +
> +#include "hw/vfio/vfio-container-legacy.h"
> +#include "hw/vfio/kvm-spapr.h"
> +#include "qapi/error.h"
> +#include "trace.h"
> +#include "vfio-helpers.h"
> +
> +bool vfio_spapr_kvm_attach_tce(VFIOContainer *bcontainer,
> +                               MemoryRegionSection *section,
> +                               Error **errp)
> +{
> +    VFIOLegacyContainer *container = VFIO_IOMMU_LEGACY(bcontainer);
> +    VFIOGroup *group;
> +    IOMMUMemoryRegion *iommu_mr = IOMMU_MEMORY_REGION(section->mr);
> +    struct kvm_vfio_spapr_tce param;
> +    struct kvm_device_attr attr = {
> +        .group = KVM_DEV_VFIO_GROUP,
> +        .attr = KVM_DEV_VFIO_GROUP_SET_SPAPR_TCE,
> +        .addr = (uint64_t)(unsigned long)&param,
> +    };
> +
> +    if (!memory_region_iommu_get_attr(iommu_mr, IOMMU_ATTR_SPAPR_TCE_FD,
> +                &param.tablefd)) {
> +        QLIST_FOREACH(group, &container->group_list, container_next) {
> +            param.groupfd = group->fd;
> +            if (ioctl(vfio_kvm_device_fd, KVM_SET_DEVICE_ATTR, &attr)) {
> +                error_setg_errno(errp, errno,
> +                        "vfio: failed GROUP_SET_SPAPR_TCE for "
> +                        "KVM VFIO device %d and group fd %d",
> +                        param.tablefd, param.groupfd);
> +                return false;
> +            }
> +            trace_vfio_spapr_group_attach(param.groupfd, param.tablefd);
> +        }
> +    }
> +    return true;
> +}
> diff --git a/hw/vfio/kvm-stubs.c b/hw/vfio/kvm-stubs.c
> index 5a489d1b711..78c51b99155 100644
> --- a/hw/vfio/kvm-stubs.c
> +++ b/hw/vfio/kvm-stubs.c
> @@ -6,6 +6,7 @@
>   
>   #include "qemu/osdep.h"
>   
> +#include "hw/vfio/kvm-spapr.h"
>   #include "hw/vfio/vfio-device.h"
>   #include "qapi/error.h"
>   #include "vfio-helpers.h"
> @@ -24,3 +25,10 @@ int vfio_kvm_device_del_fd(int fd, Error **errp)
>   {
>       return 0;
>   }
> +
> +bool vfio_spapr_kvm_attach_tce(VFIOContainer *bcontainer,
> +                               MemoryRegionSection *section,
> +                               Error **errp)
> +{
> +    g_assert_not_reached();
> +}
> diff --git a/hw/vfio/spapr.c b/hw/vfio/spapr.c
> index a9f093c3570..42690e4323d 100644
> --- a/hw/vfio/spapr.c
> +++ b/hw/vfio/spapr.c
> @@ -16,6 +16,7 @@
>   #include "system/address-spaces.h"
>   
>   #include "hw/vfio/vfio-container-legacy.h"
> +#include "hw/vfio/kvm-spapr.h"
>   #include "hw/core/hw-error.h"
>   #include "qemu/error-report.h"
>   #include "qapi/error.h"
> @@ -406,33 +407,10 @@ vfio_spapr_container_add_section_window(VFIOContainer *bcontainer,
>       vfio_host_win_add(scontainer, section->offset_within_address_space,
>                         section->offset_within_address_space +
>                         int128_get64(section->size) - 1, pgsize);
> -#ifdef CONFIG_KVM
> -    if (kvm_enabled()) {
> -        VFIOGroup *group;
> -        IOMMUMemoryRegion *iommu_mr = IOMMU_MEMORY_REGION(section->mr);
> -        struct kvm_vfio_spapr_tce param;
> -        struct kvm_device_attr attr = {
> -            .group = KVM_DEV_VFIO_GROUP,
> -            .attr = KVM_DEV_VFIO_GROUP_SET_SPAPR_TCE,
> -            .addr = (uint64_t)(unsigned long)&param,
> -        };
> -
> -        if (!memory_region_iommu_get_attr(iommu_mr, IOMMU_ATTR_SPAPR_TCE_FD,
> -                                          &param.tablefd)) {
> -            QLIST_FOREACH(group, &container->group_list, container_next) {
> -                param.groupfd = group->fd;
> -                if (ioctl(vfio_kvm_device_fd, KVM_SET_DEVICE_ATTR, &attr)) {
> -                    error_setg_errno(errp, errno,
> -                                     "vfio: failed GROUP_SET_SPAPR_TCE for "
> -                                     "KVM VFIO device %d and group fd %d",
> -                                     param.tablefd, param.groupfd);
> -                    return false;
> -                }
> -                trace_vfio_spapr_group_attach(param.groupfd, param.tablefd);
> -            }
> -        }
> +    if (kvm_enabled() && !vfio_spapr_kvm_attach_tce(bcontainer, section, errp)) {
> +        return false;
>       }
> -#endif
> +
>       return true;
>   }
>   
> diff --git a/hw/vfio/meson.build b/hw/vfio/meson.build
> index 6c00a7f51bb..bab5f2b7f15 100644
> --- a/hw/vfio/meson.build
> +++ b/hw/vfio/meson.build
> @@ -10,6 +10,7 @@ vfio_ss.add(files(
>   vfio_ss.add(when: 'CONFIG_KVM', if_true: files('kvm-helpers.c'))
>   stub_ss.add(files('kvm-stubs.c'))
>   vfio_ss.add(when: 'CONFIG_PSERIES', if_true: files('spapr.c'))
> +vfio_ss.add(when: ['CONFIG_KVM', 'CONFIG_PSERIES'], if_true: files('kvm-spapr.c'))
>   vfio_ss.add(when: 'CONFIG_VFIO_PCI', if_true: files(
>     'pci-quirks.c',
>     'pci.c',



^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [PATCH v4 8/8] hw/vfio: all vfio files can now be common files
  2026-03-17 19:42 ` [PATCH v4 8/8] hw/vfio: all vfio files can now be common files Pierrick Bouvier
@ 2026-03-18  8:31   ` Cédric Le Goater
  0 siblings, 0 replies; 20+ messages in thread
From: Cédric Le Goater @ 2026-03-18  8:31 UTC (permalink / raw)
  To: Pierrick Bouvier, qemu-devel
  Cc: Richard Henderson, eric.auger, qemu-ppc, Paolo Bonzini, philmd

On 3/17/26 20:42, Pierrick Bouvier wrote:
> Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
> Signed-off-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
> ---
>   hw/vfio/meson.build | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/hw/vfio/meson.build b/hw/vfio/meson.build
> index bab5f2b7f15..fa0ea6ecf0e 100644
> --- a/hw/vfio/meson.build
> +++ b/hw/vfio/meson.build
> @@ -20,7 +20,7 @@ vfio_ss.add(when: 'CONFIG_VFIO_AP', if_true: files('ap.c'))
>   vfio_ss.add(when: 'CONFIG_VFIO_IGD', if_true: files('igd.c'))
>   stub_ss.add(files('igd-stubs.c'))
>   
> -specific_ss.add_all(when: 'CONFIG_VFIO', if_true: vfio_ss)
> +system_ss.add_all(when: 'CONFIG_VFIO', if_true: vfio_ss)
>   
>   system_ss.add(when: 'CONFIG_VFIO', if_true: files(
>     'cpr.c',


Reviewed-by: Cédric Le Goater <clg@redhat.com>

Thanks,

C.



^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [PATCH v4 3/8] hw/vfio/pci-quirks.c: remove CONFIG_VFIO_IGD
  2026-03-18  8:11   ` Cédric Le Goater
@ 2026-03-18  9:46     ` Philippe Mathieu-Daudé
  2026-03-18 17:39       ` Pierrick Bouvier
  2026-03-18 17:37     ` Pierrick Bouvier
  1 sibling, 1 reply; 20+ messages in thread
From: Philippe Mathieu-Daudé @ 2026-03-18  9:46 UTC (permalink / raw)
  To: Cédric Le Goater, Pierrick Bouvier, qemu-devel
  Cc: Richard Henderson, eric.auger, qemu-ppc, Paolo Bonzini

On 18/3/26 09:11, Cédric Le Goater wrote:
> On 3/17/26 20:42, Pierrick Bouvier wrote:
>> Add stubs for needed functions.
>>

--->

>> As well, we need to add pixman to qemuutil library dependencies since
>> pixman is transitively included from pci.h header, which is needed to be
>> able to include prototypes for stubs we declared.
>> In file included from include/ui/console.h:4,
>>                   from ../hw/vfio/vfio-display.h:12,
>>                   from ../hw/vfio/pci.h:25,
>>                   from ../hw/vfio/igd-stubs.c:9:
>> include/ui/qemu-pixman.h:10:10: fatal error: pixman.h: No such file or 
>> directory
>>     10 | #include <pixman.h>
>>        |          ^~~~~~~~~~
>>
>> On OpenBSD, opengl headers are not available in default include path,
>> and thus we need to add opengl to list of qemuutil dependencies.
>> In file included from /home/root/qemu/include/ui/console.h:9:
>> /home/root/qemu/include/ui/surface.h:11:11: fatal error: 'epoxy/gl.h' 
>> file not found
>>
>> Finally, 

<---

>> vfio_pci_hot_reset_info must be forwarded declared on non linux
>> platforms:
>> In file included from ../hw/vfio/igd-stubs.c:9:
>> ../hw/vfio/pci.h:265:44: error: 'struct vfio_pci_hot_reset_info' 
>> declared inside parameter list will not be visible outside of this 
>> definition or declaration [-Werror]
>>    265 |                                     struct 
>> vfio_pci_hot_reset_info **info_p);
>>        |
>>
>> Reviewed-by: Cédric Le Goater <clg@redhat.com>
>> Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
>> Signed-off-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
>>
>> Signed-off-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
> 
> Duplicated Signed-off-by. I can fix when applying.

Actually you can also cut description marked betwwen --->
and <--- because already mentioned in future commit 988499515da:
https://lore.kernel.org/qemu-devel/20260317190250.70506-3-philmd@linaro.org/
which removes [*] below (should disappear on rebase).

(Sorry for that hiccups, I was expecting Pierrick series to
be posted after my PR was merged).

Regards,

Phil.

> 
> Thanks,
> 
> C.
> 
>> ---
>>   meson.build          |  2 +-
>>   hw/vfio/pci.h        |  2 ++
>>   hw/vfio/igd-stubs.c  | 20 ++++++++++++++++++++
>>   hw/vfio/pci-quirks.c |  5 -----
>>   hw/vfio/meson.build  |  1 +
>>   5 files changed, 24 insertions(+), 6 deletions(-)
>>   create mode 100644 hw/vfio/igd-stubs.c
>>
>> diff --git a/meson.build b/meson.build
>> index b2154bb9287..ab726ea1152 100644
>> --- a/meson.build
>> +++ b/meson.build
>> @@ -3781,7 +3781,7 @@ util_ss = util_ss.apply({})
>>   libqemuutil = static_library('qemuutil',
>>                                build_by_default: false,
>>                                sources: util_ss.sources() + 
>> stub_ss.sources() + genh,
>> -                             dependencies: [util_ss.dependencies(), 
>> libm, threads, glib, socket, malloc, rt])
>> +                             dependencies: [util_ss.dependencies(), 
>> libm, threads, glib, socket, malloc, rt, pixman, opengl])

[*]

>>   qemuutil = declare_dependency(link_with: libqemuutil,
>>                                 sources: genh + version_res,
>>                                 dependencies: [event_loop_base])
>> diff --git a/hw/vfio/pci.h b/hw/vfio/pci.h
>> index d6495d7f297..c3a1f53d350 100644
>> --- a/hw/vfio/pci.h
>> +++ b/hw/vfio/pci.h
>> @@ -258,6 +258,8 @@ bool vfio_probe_igd_config_quirk(VFIOPCIDevice 
>> *vdev, Error **errp);
>>   extern const PropertyInfo qdev_prop_nv_gpudirect_clique;
>> +struct vfio_pci_hot_reset_info;
>> +
>>   void vfio_pci_pre_reset(VFIOPCIDevice *vdev);
>>   void vfio_pci_post_reset(VFIOPCIDevice *vdev);
>>   bool vfio_pci_host_match(PCIHostDeviceAddress *addr, const char *name);
>> diff --git a/hw/vfio/igd-stubs.c b/hw/vfio/igd-stubs.c
>> new file mode 100644
>> index 00000000000..f7687d90912
>> --- /dev/null
>> +++ b/hw/vfio/igd-stubs.c
>> @@ -0,0 +1,20 @@
>> +/*
>> + * IGD device quirks stubs
>> + *
>> + * SPDX-License-Identifier: GPL-2.0-or-later
>> + */
>> +
>> +#include "qemu/osdep.h"
>> +#include "qapi/qmp/qerror.h"
>> +#include "pci.h"
>> +#include "pci-quirks.h"
>> +
>> +void vfio_probe_igd_bar0_quirk(VFIOPCIDevice *vdev, int nr)
>> +{
>> +    return;
>> +}
>> +
>> +bool vfio_probe_igd_config_quirk(VFIOPCIDevice *vdev, Error **errp)
>> +{
>> +    return true;
>> +}
>> diff --git a/hw/vfio/pci-quirks.c b/hw/vfio/pci-quirks.c
>> index 7b907b9360d..ab864048943 100644
>> --- a/hw/vfio/pci-quirks.c
>> +++ b/hw/vfio/pci-quirks.c
>> @@ -11,7 +11,6 @@
>>    */
>>   #include "qemu/osdep.h"
>> -#include CONFIG_DEVICES
>>   #include "exec/memop.h"
>>   #include "qemu/units.h"
>>   #include "qemu/log.h"
>> @@ -1128,11 +1127,9 @@ static void 
>> vfio_probe_rtl8168_bar2_quirk(VFIOPCIDevice *vdev, int nr)
>>    */
>>   bool vfio_config_quirk_setup(VFIOPCIDevice *vdev, Error **errp)
>>   {
>> -#ifdef CONFIG_VFIO_IGD
>>       if (!vfio_probe_igd_config_quirk(vdev, errp)) {
>>           return false;
>>       }
>> -#endif
>>       return true;
>>   }
>> @@ -1179,9 +1176,7 @@ void vfio_bar_quirk_setup(VFIOPCIDevice *vdev, 
>> int nr)
>>       vfio_probe_nvidia_bar5_quirk(vdev, nr);
>>       vfio_probe_nvidia_bar0_quirk(vdev, nr);
>>       vfio_probe_rtl8168_bar2_quirk(vdev, nr);
>> -#ifdef CONFIG_VFIO_IGD
>>       vfio_probe_igd_bar0_quirk(vdev, nr);
>> -#endif
>>   }
>>   void vfio_bar_quirk_exit(VFIOPCIDevice *vdev, int nr)
>> diff --git a/hw/vfio/meson.build b/hw/vfio/meson.build
>> index f2a7728d3d0..6c00a7f51bb 100644
>> --- a/hw/vfio/meson.build
>> +++ b/hw/vfio/meson.build
>> @@ -17,6 +17,7 @@ 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_AP', if_true: files('ap.c'))
>>   vfio_ss.add(when: 'CONFIG_VFIO_IGD', if_true: files('igd.c'))
>> +stub_ss.add(files('igd-stubs.c'))
>>   specific_ss.add_all(when: 'CONFIG_VFIO', if_true: vfio_ss)
> 



^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [PATCH v4 3/8] hw/vfio/pci-quirks.c: remove CONFIG_VFIO_IGD
  2026-03-18  8:11   ` Cédric Le Goater
  2026-03-18  9:46     ` Philippe Mathieu-Daudé
@ 2026-03-18 17:37     ` Pierrick Bouvier
  1 sibling, 0 replies; 20+ messages in thread
From: Pierrick Bouvier @ 2026-03-18 17:37 UTC (permalink / raw)
  To: Cédric Le Goater, qemu-devel
  Cc: Richard Henderson, eric.auger, qemu-ppc, Paolo Bonzini, philmd

On 3/18/26 1:11 AM, Cédric Le Goater wrote:
> On 3/17/26 20:42, Pierrick Bouvier wrote:
>> Add stubs for needed functions.
>>
>> As well, we need to add pixman to qemuutil library dependencies since
>> pixman is transitively included from pci.h header, which is needed to be
>> able to include prototypes for stubs we declared.
>> In file included from include/ui/console.h:4,
>>                    from ../hw/vfio/vfio-display.h:12,
>>                    from ../hw/vfio/pci.h:25,
>>                    from ../hw/vfio/igd-stubs.c:9:
>> include/ui/qemu-pixman.h:10:10: fatal error: pixman.h: No such file or directory
>>      10 | #include <pixman.h>
>>         |          ^~~~~~~~~~
>>
>> On OpenBSD, opengl headers are not available in default include path,
>> and thus we need to add opengl to list of qemuutil dependencies.
>> In file included from /home/root/qemu/include/ui/console.h:9:
>> /home/root/qemu/include/ui/surface.h:11:11: fatal error: 'epoxy/gl.h' file not found
>>
>> Finally, vfio_pci_hot_reset_info must be forwarded declared on non linux
>> platforms:
>> In file included from ../hw/vfio/igd-stubs.c:9:
>> ../hw/vfio/pci.h:265:44: error: 'struct vfio_pci_hot_reset_info' declared inside parameter list will not be visible outside of this definition or declaration [-Werror]
>>     265 |                                     struct vfio_pci_hot_reset_info **info_p);
>>         |
>>
>> Reviewed-by: Cédric Le Goater <clg@redhat.com>
>> Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
>> Signed-off-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
>>
>> Signed-off-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
> 
> Duplicated Signed-off-by. I can fix when applying.
>

Oops, that's a rebase mistake. thanks!

> Thanks,
> 
> C.
>


^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [PATCH v4 3/8] hw/vfio/pci-quirks.c: remove CONFIG_VFIO_IGD
  2026-03-18  9:46     ` Philippe Mathieu-Daudé
@ 2026-03-18 17:39       ` Pierrick Bouvier
  0 siblings, 0 replies; 20+ messages in thread
From: Pierrick Bouvier @ 2026-03-18 17:39 UTC (permalink / raw)
  To: Philippe Mathieu-Daudé, Cédric Le Goater, qemu-devel
  Cc: Richard Henderson, eric.auger, qemu-ppc, Paolo Bonzini

On 3/18/26 2:46 AM, Philippe Mathieu-Daudé wrote:
> On 18/3/26 09:11, Cédric Le Goater wrote:
>> On 3/17/26 20:42, Pierrick Bouvier wrote:
>>> Add stubs for needed functions.
>>>
> 
> --->
> 
>>> As well, we need to add pixman to qemuutil library dependencies since
>>> pixman is transitively included from pci.h header, which is needed to be
>>> able to include prototypes for stubs we declared.
>>> In file included from include/ui/console.h:4,
>>>                    from ../hw/vfio/vfio-display.h:12,
>>>                    from ../hw/vfio/pci.h:25,
>>>                    from ../hw/vfio/igd-stubs.c:9:
>>> include/ui/qemu-pixman.h:10:10: fatal error: pixman.h: No such file or
>>> directory
>>>      10 | #include <pixman.h>
>>>         |          ^~~~~~~~~~
>>>
>>> On OpenBSD, opengl headers are not available in default include path,
>>> and thus we need to add opengl to list of qemuutil dependencies.
>>> In file included from /home/root/qemu/include/ui/console.h:9:
>>> /home/root/qemu/include/ui/surface.h:11:11: fatal error: 'epoxy/gl.h'
>>> file not found
>>>
>>> Finally,
> 
> <---
> 
>>> vfio_pci_hot_reset_info must be forwarded declared on non linux
>>> platforms:
>>> In file included from ../hw/vfio/igd-stubs.c:9:
>>> ../hw/vfio/pci.h:265:44: error: 'struct vfio_pci_hot_reset_info'
>>> declared inside parameter list will not be visible outside of this
>>> definition or declaration [-Werror]
>>>     265 |                                     struct
>>> vfio_pci_hot_reset_info **info_p);
>>>         |
>>>
>>> Reviewed-by: Cédric Le Goater <clg@redhat.com>
>>> Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
>>> Signed-off-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
>>>
>>> Signed-off-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
>>
>> Duplicated Signed-off-by. I can fix when applying.
> 
> Actually you can also cut description marked betwwen --->
> and <--- because already mentioned in future commit 988499515da:
> https://lore.kernel.org/qemu-devel/20260317190250.70506-3-philmd@linaro.org/
> which removes [*] below (should disappear on rebase).
> 
> (Sorry for that hiccups, I was expecting Pierrick series to
> be posted after my PR was merged).
>

No problem, I'll change it and fix the extra signed-off by, so Cedric 
can have a clean v5 to apply.

Thanks!

> Regards,
> 
> Phil.
> 
>>
>> Thanks,
>>
>> C.
>>
>>> ---
>>>    meson.build          |  2 +-
>>>    hw/vfio/pci.h        |  2 ++
>>>    hw/vfio/igd-stubs.c  | 20 ++++++++++++++++++++
>>>    hw/vfio/pci-quirks.c |  5 -----
>>>    hw/vfio/meson.build  |  1 +
>>>    5 files changed, 24 insertions(+), 6 deletions(-)
>>>    create mode 100644 hw/vfio/igd-stubs.c
>>>


^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [PATCH v4 0/8] hw/vfio: single-binary
  2026-03-18  5:57 ` [PATCH v4 0/8] hw/vfio: single-binary Philippe Mathieu-Daudé
@ 2026-03-18 17:48   ` Pierrick Bouvier
  2026-03-19  7:39     ` Philippe Mathieu-Daudé
  0 siblings, 1 reply; 20+ messages in thread
From: Pierrick Bouvier @ 2026-03-18 17:48 UTC (permalink / raw)
  To: Philippe Mathieu-Daudé, qemu-devel
  Cc: Cédric Le Goater, Richard Henderson, eric.auger, qemu-ppc,
	Paolo Bonzini

On 3/17/26 10:57 PM, Philippe Mathieu-Daudé wrote:
> On 17/3/26 20:42, Pierrick Bouvier wrote:
> 
>> Pierrick Bouvier (8):
>>     hw/vfio/listener.c: remove CONFIG_KVM
>>     hw/vfio/helpers.c: extract kvm helpers in kvm-helpers.c
>>     hw/vfio/pci-quirks.c: remove CONFIG_VFIO_IGD
>>     hw/vfio: eradicate CONFIG_IOMMU from sources
>>     hw/vfio/pci.c: eradicate CONFIG_KVM
>>     hw/vfio/ap.c: use full path for target specific header
>>     hw/vfio/spapr.c: extract vfio_spapr_kvm_attach_tce to
>>       hw/vfio/kvm-spapr.c
>>     hw/vfio: all vfio files can now be common files
> 
> Tested-by: Philippe Mathieu-Daudé <philmd@linaro.org>
> 

For some reason, b4 trailers does not apply this. I added it manually on 
latest patch of series.

Regards,
Pierrick


^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [PATCH v4 0/8] hw/vfio: single-binary
  2026-03-17 19:42 [PATCH v4 0/8] hw/vfio: single-binary Pierrick Bouvier
                   ` (8 preceding siblings ...)
  2026-03-18  5:57 ` [PATCH v4 0/8] hw/vfio: single-binary Philippe Mathieu-Daudé
@ 2026-03-18 17:51 ` Pierrick Bouvier
  9 siblings, 0 replies; 20+ messages in thread
From: Pierrick Bouvier @ 2026-03-18 17:51 UTC (permalink / raw)
  To: qemu-devel
  Cc: Cédric Le Goater, Richard Henderson, eric.auger, qemu-ppc,
	Paolo Bonzini, philmd

On 3/17/26 12:42 PM, Pierrick Bouvier wrote:
> This series makes changes to hw/vfio to compile files only once.
> Changes are pretty straightforward and are mostly extraction of kvm/other config
> specific functions to proper files.
> This is the last hw/* subsystem that needs to be changed for single-binary.
> 
> v4
> --
> 
> - rewrite commit description for "hw/vfio: eradicate CONFIG_IOMMU from sources"
> 
> v2 (sent as v3)
> ---------------
> 
> - use global stub_ss (fix some missing dependencies in this case)
> - move kvm_enabled() guard check on function calls
> - s/Vfio spapr kvm/VFIO sPAPR KVM/
> 
> Pierrick Bouvier (8):
>    hw/vfio/listener.c: remove CONFIG_KVM
>    hw/vfio/helpers.c: extract kvm helpers in kvm-helpers.c
>    hw/vfio/pci-quirks.c: remove CONFIG_VFIO_IGD
>    hw/vfio: eradicate CONFIG_IOMMU from sources
>    hw/vfio/pci.c: eradicate CONFIG_KVM
>    hw/vfio/ap.c: use full path for target specific header
>    hw/vfio/spapr.c: extract vfio_spapr_kvm_attach_tce to
>      hw/vfio/kvm-spapr.c
>    hw/vfio: all vfio files can now be common files
> 
>   meson.build                  |   2 +-
>   hw/vfio/kvm-spapr.h          |  12 +++
>   hw/vfio/pci.h                |   2 +
>   target/s390x/kvm/kvm_s390x.h |   2 +-
>   hw/vfio/ap.c                 |  11 +-
>   hw/vfio/ccw.c                |   9 --
>   hw/vfio/helpers.c            | 172 -------------------------------
>   hw/vfio/igd-stubs.c          |  20 ++++
>   hw/vfio/kvm-helpers.c        | 192 +++++++++++++++++++++++++++++++++++
>   hw/vfio/kvm-spapr.c          |  47 +++++++++
>   hw/vfio/kvm-stubs.c          |  34 +++++++
>   hw/vfio/listener.c           |   4 -
>   hw/vfio/pci-quirks.c         |   5 -
>   hw/vfio/pci.c                |  39 ++-----
>   hw/vfio/spapr.c              |  30 +-----
>   hw/vfio/meson.build          |   6 +-
>   16 files changed, 329 insertions(+), 258 deletions(-)
>   create mode 100644 hw/vfio/kvm-spapr.h
>   create mode 100644 hw/vfio/igd-stubs.c
>   create mode 100644 hw/vfio/kvm-helpers.c
>   create mode 100644 hw/vfio/kvm-spapr.c
>   create mode 100644 hw/vfio/kvm-stubs.c
> 

Sent v5, with commit description fix and rebase on top of master:
https://lore.kernel.org/qemu-devel/20260318174733.1717643-1-pierrick.bouvier@linaro.org/T/#t

@Cédric, this should give you a clean series to apply when the tree will 
reopen.

Thanks,
Pierrick


^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [PATCH v4 0/8] hw/vfio: single-binary
  2026-03-18 17:48   ` Pierrick Bouvier
@ 2026-03-19  7:39     ` Philippe Mathieu-Daudé
  2026-03-19 16:43       ` Pierrick Bouvier
  0 siblings, 1 reply; 20+ messages in thread
From: Philippe Mathieu-Daudé @ 2026-03-19  7:39 UTC (permalink / raw)
  To: Pierrick Bouvier, qemu-devel
  Cc: Cédric Le Goater, Richard Henderson, eric.auger, qemu-ppc,
	Paolo Bonzini

On 18/3/26 18:48, Pierrick Bouvier wrote:
> On 3/17/26 10:57 PM, Philippe Mathieu-Daudé wrote:
>> On 17/3/26 20:42, Pierrick Bouvier wrote:
>>
>>> Pierrick Bouvier (8):
>>>     hw/vfio/listener.c: remove CONFIG_KVM
>>>     hw/vfio/helpers.c: extract kvm helpers in kvm-helpers.c
>>>     hw/vfio/pci-quirks.c: remove CONFIG_VFIO_IGD
>>>     hw/vfio: eradicate CONFIG_IOMMU from sources
>>>     hw/vfio/pci.c: eradicate CONFIG_KVM
>>>     hw/vfio/ap.c: use full path for target specific header
>>>     hw/vfio/spapr.c: extract vfio_spapr_kvm_attach_tce to
>>>       hw/vfio/kvm-spapr.c
>>>     hw/vfio: all vfio files can now be common files
>>
>> Tested-by: Philippe Mathieu-Daudé <philmd@linaro.org>
>>
> 
> For some reason, b4 trailers does not apply this. I added it manually on 
> latest patch of series.

Sorry for the inconvenience.

Maybe I should have prefixed with "Series:"?

Also there is the '-t' option:

   -t, --apply-cover-trailers
      Apply trailers sent to the cover letter to all patches

> Regards,
> Pierrick



^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [PATCH v4 0/8] hw/vfio: single-binary
  2026-03-19  7:39     ` Philippe Mathieu-Daudé
@ 2026-03-19 16:43       ` Pierrick Bouvier
  0 siblings, 0 replies; 20+ messages in thread
From: Pierrick Bouvier @ 2026-03-19 16:43 UTC (permalink / raw)
  To: Philippe Mathieu-Daudé, qemu-devel
  Cc: Cédric Le Goater, Richard Henderson, eric.auger, qemu-ppc,
	Paolo Bonzini

On 3/19/26 12:39 AM, Philippe Mathieu-Daudé wrote:
> On 18/3/26 18:48, Pierrick Bouvier wrote:
>> On 3/17/26 10:57 PM, Philippe Mathieu-Daudé wrote:
>>> On 17/3/26 20:42, Pierrick Bouvier wrote:
>>>
>>>> Pierrick Bouvier (8):
>>>>      hw/vfio/listener.c: remove CONFIG_KVM
>>>>      hw/vfio/helpers.c: extract kvm helpers in kvm-helpers.c
>>>>      hw/vfio/pci-quirks.c: remove CONFIG_VFIO_IGD
>>>>      hw/vfio: eradicate CONFIG_IOMMU from sources
>>>>      hw/vfio/pci.c: eradicate CONFIG_KVM
>>>>      hw/vfio/ap.c: use full path for target specific header
>>>>      hw/vfio/spapr.c: extract vfio_spapr_kvm_attach_tce to
>>>>        hw/vfio/kvm-spapr.c
>>>>      hw/vfio: all vfio files can now be common files
>>>
>>> Tested-by: Philippe Mathieu-Daudé <philmd@linaro.org>
>>>
>>
>> For some reason, b4 trailers does not apply this. I added it manually on
>> latest patch of series.
> 
> Sorry for the inconvenience.
> 
> Maybe I should have prefixed with "Series:"?
> 
> Also there is the '-t' option:
> 
>     -t, --apply-cover-trailers
>        Apply trailers sent to the cover letter to all patches
>

Unfortunately, this is available only with b4 shazam, and not b4 
trailers that I use.

>> Regards,
>> Pierrick
> 


^ permalink raw reply	[flat|nested] 20+ messages in thread

end of thread, other threads:[~2026-03-19 16:44 UTC | newest]

Thread overview: 20+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-03-17 19:42 [PATCH v4 0/8] hw/vfio: single-binary Pierrick Bouvier
2026-03-17 19:42 ` [PATCH v4 1/8] hw/vfio/listener.c: remove CONFIG_KVM Pierrick Bouvier
2026-03-17 19:42 ` [PATCH v4 2/8] hw/vfio/helpers.c: extract kvm helpers in kvm-helpers.c Pierrick Bouvier
2026-03-17 19:42 ` [PATCH v4 3/8] hw/vfio/pci-quirks.c: remove CONFIG_VFIO_IGD Pierrick Bouvier
2026-03-18  8:11   ` Cédric Le Goater
2026-03-18  9:46     ` Philippe Mathieu-Daudé
2026-03-18 17:39       ` Pierrick Bouvier
2026-03-18 17:37     ` Pierrick Bouvier
2026-03-17 19:42 ` [PATCH v4 4/8] hw/vfio: eradicate CONFIG_IOMMU from sources Pierrick Bouvier
2026-03-17 19:42 ` [PATCH v4 5/8] hw/vfio/pci.c: eradicate CONFIG_KVM Pierrick Bouvier
2026-03-17 19:42 ` [PATCH v4 6/8] hw/vfio/ap.c: use full path for target specific header Pierrick Bouvier
2026-03-17 19:42 ` [PATCH v4 7/8] hw/vfio/spapr.c: extract vfio_spapr_kvm_attach_tce to hw/vfio/kvm-spapr.c Pierrick Bouvier
2026-03-18  8:30   ` Cédric Le Goater
2026-03-17 19:42 ` [PATCH v4 8/8] hw/vfio: all vfio files can now be common files Pierrick Bouvier
2026-03-18  8:31   ` Cédric Le Goater
2026-03-18  5:57 ` [PATCH v4 0/8] hw/vfio: single-binary Philippe Mathieu-Daudé
2026-03-18 17:48   ` Pierrick Bouvier
2026-03-19  7:39     ` Philippe Mathieu-Daudé
2026-03-19 16:43       ` Pierrick Bouvier
2026-03-18 17:51 ` Pierrick Bouvier

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox