diff options
author | John Levon <john.levon@nutanix.com> | 2021-09-28 17:24:54 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-09-28 17:24:54 +0100 |
commit | 2789a978b9e710ccb17bc4f7de884743abd63297 (patch) | |
tree | c3a7cee9115360da7146953bd1a8a7b55f049ff3 /test/py | |
parent | 2cc236ee84ed70a6df421e5352994ac4eb03de21 (diff) | |
download | libvfio-user-2789a978b9e710ccb17bc4f7de884743abd63297.zip libvfio-user-2789a978b9e710ccb17bc4f7de884743abd63297.tar.gz libvfio-user-2789a978b9e710ccb17bc4f7de884743abd63297.tar.bz2 |
fix issue with get_region_io_fds when fd = -1 (#606)
An unmappable region should still allow io fds, as they are orthogonal.
Co-authored-by: John Levon <john.levon@nutanix.com>
Signed-off-by: John Levon <john.levon@nutanix.com>
Reviewed-by: Thanos Makatos <thanos.makatos@nutanix.com>
Diffstat (limited to 'test/py')
-rw-r--r-- | test/py/test_device_get_region_io_fds.py | 23 |
1 files changed, 21 insertions, 2 deletions
diff --git a/test/py/test_device_get_region_io_fds.py b/test/py/test_device_get_region_io_fds.py index ab29dbb..63e3236 100644 --- a/test/py/test_device_get_region_io_fds.py +++ b/test/py/test_device_get_region_io_fds.py @@ -66,6 +66,10 @@ def test_device_get_region_io_fds_setup(): mmap_areas=mmap_areas, fd=f.fileno(), offset=0x8000) assert ret == 0 + ret = vfu_setup_region(ctx, index=VFU_PCI_DEV_BAR5_REGION_IDX, size=0x8000, + flags=(VFU_REGION_FLAG_RW), offset=0x8000) + assert ret == 0 + ret = vfu_realize_ctx(ctx) assert ret == 0 @@ -115,7 +119,7 @@ def test_device_get_region_io_fds_buffer_too_large(): msg(ctx, sock, VFIO_USER_DEVICE_GET_REGION_IO_FDS, payload, expect = errno.EINVAL) -def test_device_get_region_io_fds_no_regions(): +def test_device_get_region_io_fds_no_fds(): payload = vfio_user_region_io_fds_request(argsz = 512, flags = 0, index = VFU_PCI_DEV_BAR1_REGION_IDX, count = 0) @@ -136,7 +140,22 @@ def test_device_get_region_io_fds_no_regions_setup(): index = VFU_PCI_DEV_BAR3_REGION_IDX, count = 0) ret = msg(ctx, sock, VFIO_USER_DEVICE_GET_REGION_IO_FDS, payload, - expect=errno.EINVAL) + expect = 0) + +def test_device_get_region_io_fds_region_no_mmap(): + + payload = vfio_user_region_io_fds_request(argsz = 512, flags = 0, + index = VFU_PCI_DEV_BAR5_REGION_IDX, count = 0) + + ret = msg(ctx, sock, VFIO_USER_DEVICE_GET_REGION_IO_FDS, payload, + expect = 0) + + reply, ret = vfio_user_region_io_fds_reply.pop_from_buffer(ret) + + assert reply.argsz == len(vfio_user_region_io_fds_reply()) + assert reply.count == 0 + assert reply.flags == 0 + assert reply.index == VFU_PCI_DEV_BAR5_REGION_IDX def test_device_get_region_io_fds_region_out_of_range(): |