aboutsummaryrefslogtreecommitdiff
path: root/lib/libvfio-user.c
diff options
context:
space:
mode:
authorThanos Makatos <thanos.makatos@nutanix.com>2021-06-09 11:15:34 +0100
committerGitHub <noreply@github.com>2021-06-09 11:15:34 +0100
commit1abe697341061a6c16e4a5d28b20b5efa7035a81 (patch)
treed034333d573cf5228a03cb9466540a822a60ee20 /lib/libvfio-user.c
parent57684de8240fce4a277301a86a803842338762af (diff)
downloadlibvfio-user-1abe697341061a6c16e4a5d28b20b5efa7035a81.zip
libvfio-user-1abe697341061a6c16e4a5d28b20b5efa7035a81.tar.gz
libvfio-user-1abe697341061a6c16e4a5d28b20b5efa7035a81.tar.bz2
drop mappable flag from DMA map (#553)
The flags field belongs to VFIO and it's not a good idea to reuse as new VFIO flags can break things. Instead, we derive whether or not a region is mappable if a file descriptor is passed. Signed-off-by: Thanos Makatos <thanos.makatos@nutanix.com> Reviewed-by: Swapnil Ingle <swapnil.ingle@nutanix.com> Reviewed-by: John Levon <john.levon@nutanix.com>
Diffstat (limited to 'lib/libvfio-user.c')
-rw-r--r--lib/libvfio-user.c13
1 files changed, 7 insertions, 6 deletions
diff --git a/lib/libvfio-user.c b/lib/libvfio-user.c
index 62f906a..40eb010 100644
--- a/lib/libvfio-user.c
+++ b/lib/libvfio-user.c
@@ -508,16 +508,17 @@ handle_dma_map(vfu_ctx_t *vfu_ctx, vfu_msg_t *msg,
dma_map->flags &= ~VFIO_USER_F_DMA_REGION_WRITE;
}
- if (dma_map->flags == VFIO_USER_F_DMA_REGION_MAPPABLE) {
+ if (dma_map->flags != 0) {
+ vfu_log(vfu_ctx, LOG_ERR, "bad flags=%#x", dma_map->flags);
+ return ERROR_INT(EINVAL);
+ }
+
+ if (msg->nr_in_fds > 0) {
fd = consume_fd(msg->in_fds, msg->nr_in_fds, 0);
if (fd < 0) {
- vfu_log(vfu_ctx, LOG_ERR,
- "failed to add DMA region %s: mappable but fd not provided",
- rstr);
+ vfu_log(vfu_ctx, LOG_ERR, "failed to add DMA region %s: %m", rstr);
return -1;
}
- } else if (dma_map->flags != 0) {
- vfu_log(vfu_ctx, LOG_ERR, "bad flags=%#x", dma_map->flags);
}
ret = dma_controller_add_region(vfu_ctx->dma, (void *)dma_map->addr,