@@ -38,6 +38,7 @@
#include "sysemu/reset.h"
#include "trace.h"
#include "qapi/error.h"
+#include "migration/migration.h"
VFIOGroupList vfio_group_list =
QLIST_HEAD_INITIALIZER(vfio_group_list);
@@ -796,9 +797,43 @@ static void vfio_listener_region_del(MemoryListener *listener,
}
}
+static void vfio_listerner_log_sync(MemoryListener *listener,
+ MemoryRegionSection *section)
+{
+ uint64_t start_addr, size, pfn_count;
+ VFIOGroup *group;
+ VFIODevice *vbasedev;
+
+ if (memory_region_is_ram_device(section->mr)) {
+ return;
+ }
+
+ QLIST_FOREACH(group, &vfio_group_list, next) {
+ QLIST_FOREACH(vbasedev, &group->device_list, next) {
+ if (vbasedev->device_state & VFIO_DEVICE_STATE_SAVING) {
+ continue;
+ } else {
+ return;
+ }
+ }
+ }
+
+ start_addr = TARGET_PAGE_ALIGN(section->offset_within_address_space);
+ size = int128_get64(section->size);
+ pfn_count = size >> TARGET_PAGE_BITS;
+
+ QLIST_FOREACH(group, &vfio_group_list, next) {
+ QLIST_FOREACH(vbasedev, &group->device_list, next) {
+ vfio_get_dirty_page_list(vbasedev, start_addr >> TARGET_PAGE_BITS,
+ pfn_count, TARGET_PAGE_SIZE);
+ }
+ }
+}
+
static const MemoryListener vfio_memory_listener = {
.region_add = vfio_listener_region_add,
.region_del = vfio_listener_region_del,
+ .log_sync = vfio_listerner_log_sync,
};
static void vfio_listener_release(VFIOContainer *container)