On Mon, Aug 16, 2021 at 09:42:49AM -0700, Elena Ufimtseva wrote: > @@ -1356,7 +1365,11 @@ static int vfio_get_dirty_bitmap(VFIOContainer *container, uint64_t iova, > goto err_out; > } > > - ret = ioctl(container->fd, VFIO_IOMMU_DIRTY_PAGES, dbitmap); > + if (container->proxy != NULL) { > + ret = vfio_user_dirty_bitmap(container->proxy, dbitmap, range); > + } else { > + ret = ioctl(container->fd, VFIO_IOMMU_DIRTY_PAGES, dbitmap); > + } > if (ret) { > error_report("Failed to get dirty bitmap for iova: 0x%"PRIx64 > " size: 0x%"PRIx64" err: %d", (uint64_t)range->iova, This error_report() relies on errno. vfio_user_region_write() doesn't set errno. > diff --git a/hw/vfio/migration.c b/hw/vfio/migration.c > index 82f654afb6..89926a3b01 100644 > --- a/hw/vfio/migration.c > +++ b/hw/vfio/migration.c > @@ -27,6 +27,7 @@ > #include "pci.h" > #include "trace.h" > #include "hw/hw.h" > +#include "user.h" > > /* > * Flags to be used as unique delimiters for VFIO devices in the migration > @@ -49,10 +50,18 @@ static int64_t bytes_transferred; > static inline int vfio_mig_access(VFIODevice *vbasedev, void *val, int count, > off_t off, bool iswrite) > { > + VFIORegion *region = &vbasedev->migration->region; > int ret; > > - ret = iswrite ? pwrite(vbasedev->fd, val, count, off) : > - pread(vbasedev->fd, val, count, off); > + if (vbasedev->proxy != NULL) { > + ret = iswrite ? > + vfio_user_region_write(vbasedev, region->nr, off, count, val) : > + vfio_user_region_read(vbasedev, region->nr, off, count, val); > + } else { > + off += region->fd_offset; > + ret = iswrite ? pwrite(vbasedev->fd, val, count, off) : > + pread(vbasedev->fd, val, count, off); > + } > if (ret < count) { > error_report("vfio_mig_%s %d byte %s: failed at offset 0x%" > HWADDR_PRIx", err: %s", iswrite ? "write" : "read", count, Another errno user. I haven't exhaustively audited all the code for these issues. Please take a look.