@@ -1413,20 +1413,10 @@ typedef struct VFIODirtyRangesListener {
MemoryListener listener;
} VFIODirtyRangesListener;
-static void vfio_dirty_tracking_update(MemoryListener *listener,
- MemoryRegionSection *section)
+static void vfio_dirty_tracking_update(hwaddr iova, hwaddr end,
+ VFIODirtyRanges *range)
{
- VFIODirtyRangesListener *dirty = container_of(listener,
- VFIODirtyRangesListener,
- listener);
- VFIODirtyRanges *range = &dirty->ranges;
- hwaddr iova, end, *min, *max;
-
- if (!vfio_listener_valid_section(section, "tracking_update") ||
- !vfio_get_section_iova_range(dirty->container, section,
- &iova, &end, NULL)) {
- return;
- }
+ hwaddr *min, *max;
/*
* The address space passed to the dirty tracker is reduced to two ranges:
@@ -1450,12 +1440,28 @@ static void vfio_dirty_tracking_update(MemoryListener *listener,
}
trace_vfio_device_dirty_tracking_update(iova, end, *min, *max);
- return;
+}
+
+static void vfio_listener_dirty_tracking_update(MemoryListener *listener,
+ MemoryRegionSection *section)
+{
+ VFIODirtyRangesListener *dirty = container_of(listener,
+ VFIODirtyRangesListener,
+ listener);
+ hwaddr iova, end;
+
+ if (!vfio_listener_valid_section(section, "tracking_update") ||
+ !vfio_get_section_iova_range(dirty->container, section,
+ &iova, &end, NULL)) {
+ return;
+ }
+
+ vfio_dirty_tracking_update(iova, end, &dirty->ranges);
}
static const MemoryListener vfio_dirty_tracking_listener = {
.name = "vfio-tracking",
- .region_add = vfio_dirty_tracking_update,
+ .region_add = vfio_listener_dirty_tracking_update,
};
static void vfio_dirty_tracking_init(VFIOContainer *container,
Separate the changes that updates the ranges from the listener, to make it reusable in preparation to expand its use to vIOMMU support. Signed-off-by: Joao Martins <joao.m.martins@oracle.com> --- hw/vfio/common.c | 36 +++++++++++++++++++++--------------- 1 file changed, 21 insertions(+), 15 deletions(-)