aboutsummaryrefslogtreecommitdiff
path: root/samples/server.c
diff options
context:
space:
mode:
authorThanos Makatos <thanos.makatos@nutanix.com>2020-12-14 15:50:37 +0000
committerGitHub <noreply@github.com>2020-12-14 15:50:37 +0000
commitf240c889171ab22e7b8b0b460792b0df94c335c1 (patch)
treec0a60b0dbd7f32ffac3b8caf8d1bbcfa8bfed491 /samples/server.c
parentd7157efb22c9fc06f85e40f0e6b6c5e16dc5e8e2 (diff)
downloadlibvfio-user-f240c889171ab22e7b8b0b460792b0df94c335c1.zip
libvfio-user-f240c889171ab22e7b8b0b460792b0df94c335c1.tar.gz
libvfio-user-f240c889171ab22e7b8b0b460792b0df94c335c1.tar.bz2
return region capabilities a la VFIO (#187)
This patch returns region capabilities the same way VFIO does: if argsz is not large enough then it returns only region info and sets argsz to what it should be in order to fit the capabilities, the client then retries with a large enough argsz. The protocol specification has been updated as well. Plus unit tests. Signed-off-by: Thanos Makatos <thanos.makatos@nutanix.com>
Diffstat (limited to 'samples/server.c')
-rw-r--r--samples/server.c14
1 files changed, 10 insertions, 4 deletions
diff --git a/samples/server.c b/samples/server.c
index 9180591..a1bedac 100644
--- a/samples/server.c
+++ b/samples/server.c
@@ -123,6 +123,8 @@ bar1_access(UNUSED void *pvt, UNUSED char * const buf, UNUSED size_t count,
{
assert(false);
+ /* FIXME assert that only the 2nd page is accessed */
+
return -ENOTSUP;
}
@@ -434,13 +436,17 @@ int main(int argc, char *argv[])
err(EXIT_FAILURE, "failed to setup BAR0 region");
}
+ /*
+ * Setup BAR1 to be 3 pages in size where only the first and the last pages
+ * are mappable.
+ */
struct iovec mmap_areas[] = {
- { .iov_base = (void*)0x400, .iov_len = 0x400 },
- { .iov_base = (void*)0x2000, .iov_len = 0x400 }
+ { .iov_base = (void*)0, .iov_len = 0x1000 },
+ { .iov_base = (void*)0x2000, .iov_len = 0x1000 }
};
ret = vfu_setup_region(vfu_ctx, VFU_PCI_DEV_BAR1_REGION_IDX,
- sysconf(_SC_PAGESIZE), &bar1_access,
- VFU_REGION_FLAG_RW, mmap_areas, 2, map_area);
+ 0x3000, &bar1_access, VFU_REGION_FLAG_RW,
+ mmap_areas, 3, map_area);
if (ret < 0) {
err(EXIT_FAILURE, "failed to setup BAR1 region");
}