diff options
author | Swapnil Ingle <swapnil.ingle@nutanix.com> | 2020-10-01 05:55:34 -0400 |
---|---|---|
committer | Swapnil Ingle <swapnil.ingle@nutanix.com> | 2020-10-01 05:55:34 -0400 |
commit | b115b6a87dd8e0c5277dde2fceb5b2a862c3484b (patch) | |
tree | d2ff9bb3ad368da8b557c2eef6def796967e33cb /samples | |
parent | 895ac8246d416a58e7f4b910088adabd8ec3acc7 (diff) | |
download | libvfio-user-b115b6a87dd8e0c5277dde2fceb5b2a862c3484b.zip libvfio-user-b115b6a87dd8e0c5277dde2fceb5b2a862c3484b.tar.gz libvfio-user-b115b6a87dd8e0c5277dde2fceb5b2a862c3484b.tar.bz2 |
add test for VFIO_USER_DEVICE_GET_REGION_INFO
Signed-off-by: Swapnil Ingle <swapnil.ingle@nutanix.com>
Diffstat (limited to 'samples')
-rw-r--r-- | samples/server.c | 26 |
1 files changed, 25 insertions, 1 deletions
diff --git a/samples/server.c b/samples/server.c index deb986b..4af0edc 100644 --- a/samples/server.c +++ b/samples/server.c @@ -97,6 +97,11 @@ unmap_dma(void *pvt __attribute__((unused)), { } +unsigned long map_area(void *pvt, unsigned long off, unsigned long len) +{ + assert(false); +} + int main(int argc, char *argv[]) { int ret; @@ -104,6 +109,9 @@ int main(int argc, char *argv[]) char opt; struct sigaction act = {.sa_handler = _sa_handler}; struct server_data server_data; + int nr_sparse_areas = 2, size = 1024, i; + struct lm_sparse_mmap_areas *sparse_areas; + lm_ctx_t *lm_ctx; while ((opt = getopt(argc, argv, "v")) != -1) { @@ -125,6 +133,18 @@ int main(int argc, char *argv[]) err(EXIT_FAILURE, "BAR1"); } + sparse_areas = calloc(1, sizeof(*sparse_areas) + + (nr_sparse_areas * sizeof(struct lm_mmap_area))); + if (sparse_areas == NULL) { + err(EXIT_FAILURE, "MMAP sparse areas ENOMEM"); + goto out; + } + sparse_areas->nr_mmap_areas = nr_sparse_areas; + for (i = 0; i < nr_sparse_areas; i++) { + sparse_areas->areas[i].start += size; + sparse_areas->areas[i].size = size; + } + lm_dev_info_t dev_info = { .trans = LM_TRANS_SOCK, .log = verbose ? _log : NULL, @@ -138,7 +158,9 @@ int main(int argc, char *argv[]) .reg_info[LM_DEV_BAR1_REG_IDX] = { .flags = LM_REG_FLAG_RW, .size = sysconf(_SC_PAGESIZE), - .fn = &bar1_access + .fn = &bar1_access, + .mmap_areas = sparse_areas, + .map = map_area }, .irq_count[LM_DEV_INTX_IRQ_IDX] = 1, }, @@ -175,6 +197,8 @@ int main(int argc, char *argv[]) } out: lm_ctx_destroy(lm_ctx); + free(server_data.bar1); + free(sparse_areas); return ret; } |