aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorThanos Makatos <thanos.makatos@nutanix.com>2021-03-01 11:19:50 +0000
committerGitHub <noreply@github.com>2021-03-01 11:19:50 +0000
commitf1057091f5eb2b7a91a2423503aea1c340f16831 (patch)
tree85af251cd6342123eaaa3cdf2d77b5e32f2fcac4 /lib
parentbb0ea196f62bfad9f4ef89ab20824a16644c6b0e (diff)
downloadlibvfio-user-f1057091f5eb2b7a91a2423503aea1c340f16831.zip
libvfio-user-f1057091f5eb2b7a91a2423503aea1c340f16831.tar.gz
libvfio-user-f1057091f5eb2b7a91a2423503aea1c340f16831.tar.bz2
don't call user's unmap_dma callback when removing DMA region (#370)
Plus unit tests. Signed-off-by: Thanos Makatos <thanos.makatos@nutanix.com> Reported-by: Changpeng Liu <changpeng.liu@intel.com> Reviewed-by: John Levon <john.levon@nutanix.com>
Diffstat (limited to 'lib')
-rw-r--r--lib/libvfio-user.c13
1 files changed, 5 insertions, 8 deletions
diff --git a/lib/libvfio-user.c b/lib/libvfio-user.c
index 07412c8..77c9f0c 100644
--- a/lib/libvfio-user.c
+++ b/lib/libvfio-user.c
@@ -488,7 +488,7 @@ handle_dma_map_or_unmap(vfu_ctx_t *vfu_ctx, uint32_t size, bool map,
size_t fdi;
assert(vfu_ctx != NULL);
- assert(fds != NULL);
+ assert(fds != NULL); /* TODO assert valid only for map */
if (vfu_ctx->dma == NULL) {
return 0;
@@ -533,6 +533,10 @@ handle_dma_map_or_unmap(vfu_ctx_t *vfu_ctx, uint32_t size, bool map,
strerror(-ret));
break;
}
+ if (vfu_ctx->map_dma != NULL) {
+ vfu_ctx->map_dma(vfu_ctx, dma_regions[i].addr,
+ dma_regions[i].size, dma_regions[i].prot);
+ }
ret = 0;
vfu_log(vfu_ctx, LOG_DEBUG,
"added DMA region %#lx-%#lx offset=%#lx fd=%d prot=%#x",
@@ -557,13 +561,6 @@ handle_dma_map_or_unmap(vfu_ctx_t *vfu_ctx, uint32_t size, bool map,
dma_regions[i].addr,
dma_regions[i].addr + dma_regions[i].size - 1);
}
- if (ret < 0) {
- return ret;
- }
- if (vfu_ctx->map_dma != NULL) {
- vfu_ctx->map_dma(vfu_ctx, dma_regions[i].addr, dma_regions[i].size,
- dma_regions[i].prot);
- }
}
return ret;
}