On 3/26/25 08:50, Cédric Le Goater wrote:
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 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 have taken care to preserve all existing copyright notices in the
file headers. I have added one on behalf of my current employer for
newly created files. However, original authors may wish to include
their own notices as well. If so, please respond to the patch, and I
will update the patch in the next spin or before applying.
Here is a (short) list requiring your attention :
* include/hw/vfio/vfio-migration.h
* hw/vfio/vfio-migration-internal.h
Kirti Wankhede and Avihai Horon, NVIDIA
* hw/vfio/vfio-iommufd.h
Joao Martins and Yi Liu, Oracle and Intel
* include/hw/vfio/vfio-region.h
* hw/vfio/region.c
Eric Auger, may be we could reduce the list ?
* hw/vfio/vfio-cpr.h
Steve Sistare, Oracle
I think the remaining new files are correctly covered but I am human,
so please review and let me know.
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.
What next in terms of cleanups :
- container.c is quite messy
- the pci* files need some love too (add vfio- prefix ?)
- improve overall documentation, structs and routines documentation
too would be great
- isolate all the low level routines (kvm ioctls) into helpers.c
to improve build ?
- improve build to reduce the number of files built per target
- continue the never ending quest of adding 'Error **' parameters,
Look for migration_file_set_error, in MemoryListener handlers :
vfio_listener_region_add
vfio_listener_log_global_stop
vfio_listener_log_sync
and in callback routines for IOMMU notifiers :
vfio_iommu_map_notify
vfio_iommu_map_dirty_notify
memory_region_iommu_replay() would be a start.
- remove vfio-platform (start of QEMU 10.2 cycle ~ September 2025)
Thanks,
C.
Changes in v2:
- Dropped vfio_migration_set_error()
https://lore.kernel.org/qemu-devel/20250324123315.637827-1-...@redhat.com/
- Dropped R-b trailers on patches which were modified too much
(context changes are ok)
- Improved commit logs of patches adding new files
- Fixed top comment in header files
- Used a 'vfio_migration_' prefix instead of 'vfio_mig_'
- Made vfio_migration_add_bytes_transferred() internal
- Added extra patch for vfio_device_state_is_running/precopy()
- Moved vfio_reset_handler() in device.c
- Moved "dirty tracking" related services into container-base.c and
improved naming
- Introduced listener.* files instead of dirty-tracking.*
- Introduced vfio_listener_un/register() routines
I pushed the changes I made to v2 to this branch:
https://github.com/legoater/qemu/commits/vfio-10.1
I've added manually Avihai's R-bs which didn't reach lore for some
reason. Please check.
v3 should be after QEMU 10.0 is released, possibly next week.
Thanks,
C.