mbox series

[for-10.1,00/32] vfio: Spring cleanup

Message ID 20250318095415.670319-1-clg@redhat.com (mailing list archive)
Headers show
Series vfio: Spring cleanup | expand

Message

Cédric Le Goater March 18, 2025, 9:53 a.m. UTC
Hello,

Several large extensions were merged in VFIO recently: migration
support with dirty tracking, support for different host IOMMU backend
devices, multifd support, etc. This adds up to the previous
extensions: vfio-platform, AP, CCW. The result is that VFIO is now a
subsystem of over +16,000 lines of code :

  QEMU 2.0  :   3988 total
  QEMU 2.12 :   9336 total
  QEMU 6.2  :  12715 total
  QEMU 8.2  :  13690 total
  QEMU 9.2  :  15680 total
  QEMU 10.0 :  16607 total

Organization is weak, naming inconsistent, the vfio-common.h header
file and common.c are quite messy. It's time to address the technical
debt before adding new features.

This proposal reorganizes some of the VFIO files to isolate features,
introduces new files and renames services to better reflect the
namespace they belong to. This is code reshuffling and there are no
intentional functional changes. If more could be done, please propose !
Timing seems right.

I hope we can merge this when the QEMU 10.1 cycle starts and then
address the two large series waiting : live update and vfio-user.

Thanks,

C. 

Cédric Le Goater (32):
  vfio: Move vfio_mig_active() into migration.c
  vfio: Rename vfio_reset_bytes_transferred()
  vfio: Introduce a new header file for external migration services
  vfio: Make vfio_un/block_multiple_devices_migration() static
  vfio: Make vfio_viommu_preset() static
  vfio: Introduce a new header file for internal migration services
  vfio: Introduce a new header file for VFIOdisplay declarations
  vfio: Move VFIOHostDMAWindow definition into spapr.c
  vfio: Introduce a new header file for VFIOIOMMUFD declarations
  vfio: Introduce new files for VFIORegion definitions and declarations
  vfio: Introduce a new header file for VFIOcontainer declarations
  vfio: Make vfio_group_list static
  vfio: Move VFIOAddressSpace helpers into container-base.c
  vfio: Move Host IOMMU type declarations into their respective files
  vfio: Introduce a new header file for helper services
  vfio: Move vfio_get_info_dma_avail() into helpers.c
  vfio: Move vfio_kvm_device_add/del_fd() to helpers.c
  vfio: Move vfio_get_device_info() to helpers.c
  vfio: Introduce a new file for VFIODevice definitions
  vfio: Introduce new files for CPR definitions and declarations
  vfio: Move vfio_kvm_device_fd() into helpers.c
  vfio: Move vfio_device_list into device.c
  vfio: Move vfio_de/attach_device() into device.c
  vfio: Introduce new files for dirty tracking definitions and
    declarations
  vfio: Move vfio_set_migration_error() into migration.c
  vfio: Rename vfio-common.h to vfio-device.h
  vfio: Rename VFIODevice related services
  vfio: Make vfio_devices_query_dirty_bitmap() static
  vfio: Rename VFIOContainer related services
  vfio: Rename VFIO dirty tracking services
  vfio: Introduce vfio_dirty_tracking_un/register() routines
  vfio: Rename RAM discard related services

 hw/vfio/cpr.h                          |  15 +
 hw/vfio/dirty-tracking.h               |  19 +
 hw/vfio/display.h                      |  42 ++
 hw/vfio/helpers.h                      |  35 ++
 hw/vfio/iommufd.h                      |  29 +
 hw/vfio/migration-multifd.h            |   2 +-
 hw/vfio/migration.h                    |  73 +++
 hw/vfio/pci.h                          |   3 +-
 include/hw/s390x/vfio-ccw.h            |   2 +-
 include/hw/vfio/vfio-common.h          | 346 ------------
 include/hw/vfio/vfio-container-base.h  |   5 +
 include/hw/vfio/vfio-container.h       |  35 ++
 include/hw/vfio/vfio-device.h          | 148 ++++++
 include/hw/vfio/vfio-migration.h       |  17 +
 include/hw/vfio/vfio-platform.h        |   4 +-
 include/hw/vfio/vfio-region.h          |  47 ++
 backends/iommufd.c                     |   2 +-
 hw/core/sysbus-fdt.c                   |   1 +
 hw/ppc/spapr_pci_vfio.c                |   6 +-
 hw/s390x/s390-pci-vfio.c               |   3 +-
 hw/vfio/ap.c                           |  10 +-
 hw/vfio/ccw.c                          |  20 +-
 hw/vfio/container-base.c               |  69 +++
 hw/vfio/container.c                    | 123 ++---
 hw/vfio/cpr.c                          |   3 +-
 hw/vfio/device.c                       | 371 +++++++++++++
 hw/vfio/{common.c => dirty-tracking.c} | 382 ++------------
 hw/vfio/display.c                      |   4 +-
 hw/vfio/helpers.c                      | 702 +++----------------------
 hw/vfio/igd.c                          |   8 +-
 hw/vfio/iommufd.c                      |  25 +-
 hw/vfio/migration-multifd.c            |   4 +-
 hw/vfio/migration.c                    | 112 +++-
 hw/vfio/pci-quirks.c                   |   1 +
 hw/vfio/pci.c                          |  51 +-
 hw/vfio/platform.c                     |  11 +-
 hw/vfio/region.c                       | 396 ++++++++++++++
 hw/vfio/spapr.c                        |  10 +-
 migration/target.c                     |   4 +-
 hw/vfio/meson.build                    |   8 +-
 hw/vfio/trace-events                   |  36 +-
 41 files changed, 1711 insertions(+), 1473 deletions(-)
 create mode 100644 hw/vfio/cpr.h
 create mode 100644 hw/vfio/dirty-tracking.h
 create mode 100644 hw/vfio/display.h
 create mode 100644 hw/vfio/helpers.h
 create mode 100644 hw/vfio/iommufd.h
 create mode 100644 hw/vfio/migration.h
 delete mode 100644 include/hw/vfio/vfio-common.h
 create mode 100644 include/hw/vfio/vfio-container.h
 create mode 100644 include/hw/vfio/vfio-device.h
 create mode 100644 include/hw/vfio/vfio-migration.h
 create mode 100644 include/hw/vfio/vfio-region.h
 create mode 100644 hw/vfio/device.c
 rename hw/vfio/{common.c => dirty-tracking.c} (81%)
 create mode 100644 hw/vfio/region.c