diff options
author | Thanos Makatos <thanos.makatos@nutanix.com> | 2021-05-20 17:10:51 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-05-20 17:10:51 +0100 |
commit | cfe9901919943f14961e1da1c4a823336ff79555 (patch) | |
tree | 2b5d8915bbbea8d239684e3334c9926fb910fc2c /lib/dma.c | |
parent | 947941de95bf2c3f723b37151d67fb129fd01841 (diff) | |
download | libvfio-user-cfe9901919943f14961e1da1c4a823336ff79555.zip libvfio-user-cfe9901919943f14961e1da1c4a823336ff79555.tar.gz libvfio-user-cfe9901919943f14961e1da1c4a823336ff79555.tar.bz2 |
migration: various dirty page tracking fixes (#457)
- document how to use a vfio-user device with libvirt
- document how to use SPDK's nvmf/vfio-user target with libvirt
- replace vfio_bitmap with vfio_user_bitmap and vfio_iommu_type1_dirty_bitmap_get with vfio_user_bitmap_range
- fix bug for calculating number of pages needed for dirty page bitmap
- align number of bytes for dirty page bitmap to QWORD
- add debug messages around dirty page tracking
- only support flags=0 when doing DMA unmap
- set device state to running after reset
- allow region read/write even if device is in stopped state
- allow transitioning from stopped/stop-and-copy state to running state
- fix unit tests
Signed-off-by: Thanos Makatos <thanos.makatos@nutanix.com>
Reviewed-by: John Levon <john.levon@nutanix.com>
Diffstat (limited to 'lib/dma.c')
-rw-r--r-- | lib/dma.c | 6 |
1 files changed, 5 insertions, 1 deletions
@@ -423,7 +423,7 @@ get_bitmap_size(size_t region_size, size_t pgsize) return ERROR_INT(EINVAL); } size_t nr_pages = (region_size / pgsize) + (region_size % pgsize != 0); - return (nr_pages / CHAR_BIT) + (nr_pages % CHAR_BIT != 0); + return ROUND_UP(nr_pages, sizeof(uint64_t) * CHAR_BIT) / CHAR_BIT; } int dma_controller_dirty_page_logging_start(dma_controller_t *dma, size_t pgsize) @@ -511,11 +511,13 @@ dma_controller_dirty_page_get(dma_controller_t *dma, vfu_dma_addr_t addr, } if (pgsize != dma->dirty_pgsize) { + vfu_log(dma->vfu_ctx, LOG_ERR, "bad page size %ld", pgsize); return ERROR_INT(EINVAL); } bitmap_size = get_bitmap_size(len, pgsize); if (bitmap_size < 0) { + vfu_log(dma->vfu_ctx, LOG_ERR, "failed to get bitmap size"); return bitmap_size; } @@ -524,6 +526,8 @@ dma_controller_dirty_page_get(dma_controller_t *dma, vfu_dma_addr_t addr, * expects to receive. */ if (size != (size_t)bitmap_size) { + vfu_log(dma->vfu_ctx, LOG_ERR, "bad bitmap size %ld != %ld", size, + bitmap_size); return ERROR_INT(EINVAL); } |