>-----Original Message----- >From: Cédric Le Goater <c...@redhat.com> >Subject: Re: [PATCH for-10.1 24/32] vfio: Introduce new files for dirty >tracking >definitions and declarations > >On 3/20/25 10:52, Duan, Zhenzhong wrote: >> >> >>> -----Original Message----- >>> From: Cédric Le Goater <c...@redhat.com> >>> Subject: [PATCH for-10.1 24/32] vfio: Introduce new files for dirty tracking >>> definitions and declarations >>> >>> File "common.c" has been emptied of most of its definitions by the >>> previous changes and the only definitions left are related to dirty >>> tracking. Rename it to "dirty-tracking.c" and introduce its associated >>> "dirty-tracking.h" header file for the declarations. >>> >>> Cleanup a little the includes while at it. >>> >>> Signed-off-by: Cédric Le Goater <c...@redhat.com> >>> --- >>> hw/vfio/dirty-tracking.h | 22 ++++++++++++++++++++++ >>> include/hw/vfio/vfio-common.h | 10 ---------- >>> hw/vfio/container.c | 1 + >>> hw/vfio/{common.c => dirty-tracking.c} | 5 +---- >>> hw/vfio/iommufd.c | 1 + >>> hw/vfio/meson.build | 2 +- >>> hw/vfio/trace-events | 2 +- >>> 7 files changed, 27 insertions(+), 16 deletions(-) >>> create mode 100644 hw/vfio/dirty-tracking.h >>> rename hw/vfio/{common.c => dirty-tracking.c} (99%) >>> >>> diff --git a/hw/vfio/dirty-tracking.h b/hw/vfio/dirty-tracking.h >>> new file mode 100644 >>> index >>> >0000000000000000000000000000000000000000..4b83dc54ab50dabfff040d7cc3 >>> db27b80bfe2d3a >>> --- /dev/null >>> +++ b/hw/vfio/dirty-tracking.h >>> @@ -0,0 +1,22 @@ >>> +/* >>> + * VFIO dirty page tracking routines >>> + * >>> + * Copyright Red Hat, Inc. 2025 >>> + * >>> + * SPDX-License-Identifier: GPL-2.0-or-later >>> + */ >>> + >>> +#ifndef HW_VFIO_DIRTY_TRACKING_H >>> +#define HW_VFIO_DIRTY_TRACKING_H >>> + >>> +extern const MemoryListener vfio_memory_listener; >>> + >>> +bool vfio_devices_all_dirty_tracking_started(const VFIOContainerBase >>> *bcontainer); >>> +bool vfio_devices_all_device_dirty_tracking(const VFIOContainerBase >>> *bcontainer); >>> +int vfio_devices_query_dirty_bitmap(const VFIOContainerBase *bcontainer, >>> + VFIOBitmap *vbmap, hwaddr iova, hwaddr >>> size, >>> + Error **errp); >>> +int vfio_get_dirty_bitmap(const VFIOContainerBase *bcontainer, uint64_t >iova, >>> + uint64_t size, ram_addr_t ram_addr, Error >>> **errp); >>> + >>> +#endif /* HW_VFIO_DIRTY_TRACKING_H */ >>> diff --git a/include/hw/vfio/vfio-common.h b/include/hw/vfio/vfio-common.h >>> index >>> >184a422916f62259158e8759efc473a5efb2b2f7..cc20110d9de8ac173b67e6e878 >>> d4d61818497426 100644 >>> --- a/include/hw/vfio/vfio-common.h >>> +++ b/include/hw/vfio/vfio-common.h >>> @@ -130,7 +130,6 @@ VFIODevice *vfio_get_vfio_device(Object *obj); >>> >>> typedef QLIST_HEAD(VFIODeviceList, VFIODevice) VFIODeviceList; >>> extern VFIODeviceList vfio_device_list; >>> -extern const MemoryListener vfio_memory_listener; >>> >>> #ifdef CONFIG_LINUX >>> int vfio_get_region_info(VFIODevice *vbasedev, int index, >>> @@ -140,15 +139,6 @@ int vfio_get_dev_region_info(VFIODevice *vbasedev, >>> uint32_t type, >>> bool vfio_has_region_cap(VFIODevice *vbasedev, int region, uint16_t >cap_type); >>> #endif >>> >>> -bool vfio_devices_all_dirty_tracking_started( >>> - const VFIOContainerBase *bcontainer); >>> -bool >>> -vfio_devices_all_device_dirty_tracking(const VFIOContainerBase >*bcontainer); >>> -int vfio_devices_query_dirty_bitmap(const VFIOContainerBase *bcontainer, >>> - VFIOBitmap *vbmap, hwaddr iova, hwaddr size, Error **errp); >>> -int vfio_get_dirty_bitmap(const VFIOContainerBase *bcontainer, uint64_t >iova, >>> - uint64_t size, ram_addr_t ram_addr, Error >>> **errp); >>> - >>> /* Returns 0 on success, or a negative errno. */ >>> bool vfio_device_get_name(VFIODevice *vbasedev, Error **errp); >>> void vfio_device_set_fd(VFIODevice *vbasedev, const char *str, Error >>> **errp); >>> diff --git a/hw/vfio/container.c b/hw/vfio/container.c >>> index >>> >4e41a7476549a0c5e464e499d059db5aca6e3470..e88dfe12edd6dee469c06ee2e >>> 46ab9c8b5019ae7 100644 >>> --- a/hw/vfio/container.c >>> +++ b/hw/vfio/container.c >>> @@ -35,6 +35,7 @@ >>> #include "hw/vfio/vfio-container.h" >>> #include "helpers.h" >>> #include "cpr.h" >>> +#include "dirty-tracking.h" >>> >>> #define TYPE_HOST_IOMMU_DEVICE_LEGACY_VFIO >>> TYPE_HOST_IOMMU_DEVICE "-legacy-vfio" >>> >>> diff --git a/hw/vfio/common.c b/hw/vfio/dirty-tracking.c >>> similarity index 99% >>> rename from hw/vfio/common.c >>> rename to hw/vfio/dirty-tracking.c >>> index >>> >ed2f2ed8839caaf40fabb0cbbcaa1df2c5b70d67..441f9d9a08c06a88dda44ef143d >>> cee5f0a89a900 100644 >>> --- a/hw/vfio/common.c >>> +++ b/hw/vfio/dirty-tracking.c >>> @@ -20,14 +20,10 @@ >>> >>> #include "qemu/osdep.h" >>> #include <sys/ioctl.h> >>> -#ifdef CONFIG_KVM >>> -#include <linux/kvm.h> >>> -#endif >> >> It looks this change unrelated to this patch? >> >>> #include <linux/vfio.h> >>> >>> #include "hw/vfio/vfio-common.h" >>> #include "hw/vfio/pci.h" >>> -#include "exec/address-spaces.h" >> >> Same here. > >yes and no. Commit log says : > > Cleanup a little the includes while at it. > >but if you prefer we can address the include proliferation in a patch >of its own ?
No need, this is fine already. Previously I thought better to move into '[PATCH for-10.1 13/32] vfio: Move VFIOAddressSpace helpers into container-base.c', but I'm wrong, it's just purely useless code. Thanks Zhenzhong