aboutsummaryrefslogtreecommitdiff
path: root/test/py
diff options
context:
space:
mode:
authorJohn Levon <john.levon@nutanix.com>2023-10-02 14:06:38 +0100
committerGitHub <noreply@github.com>2023-10-02 14:06:38 +0100
commit8d38e8c57923f736ffc8215b7b237c76d240e3b4 (patch)
treefda7ef5d3223c51c391bd6b14915476a90de4416 /test/py
parent7da33b5aaef3e1bafe530138451e53cda541a504 (diff)
downloadlibvfio-user-8d38e8c57923f736ffc8215b7b237c76d240e3b4.zip
libvfio-user-8d38e8c57923f736ffc8215b7b237c76d240e3b4.tar.gz
libvfio-user-8d38e8c57923f736ffc8215b7b237c76d240e3b4.tar.bz2
fix VFIO_USER_DEVICE_GET_REGION_IO_FDS allocation (#785)
clang-tidy static analysis identified a zero-sized allocation in the case that no ioregionfds had been configured. Fix this issue and add a test for it. 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_shadow_ioeventfd.py28
1 files changed, 28 insertions, 0 deletions
diff --git a/test/py/test_shadow_ioeventfd.py b/test/py/test_shadow_ioeventfd.py
index 1375769..3830b88 100644
--- a/test/py/test_shadow_ioeventfd.py
+++ b/test/py/test_shadow_ioeventfd.py
@@ -33,6 +33,34 @@ import mmap
import errno
+def test_shadow_ioeventfd_none():
+ """Test VFIO_USER_DEVICE_GET_REGION_IO_FDS when none are set up."""
+
+ # server setup
+ ctx = vfu_create_ctx(flags=LIBVFIO_USER_FLAG_ATTACH_NB)
+ assert ctx is not None
+ ret = vfu_setup_region(ctx, index=VFU_PCI_DEV_BAR0_REGION_IDX, size=0x1000,
+ flags=VFU_REGION_FLAG_RW)
+ assert ret == 0
+
+ ret = vfu_realize_ctx(ctx)
+ assert ret == 0
+
+ # client
+ client = connect_client(ctx)
+ payload = vfio_user_region_io_fds_request(
+ argsz=len(vfio_user_region_io_fds_reply()) +
+ len(vfio_user_sub_region_ioeventfd()), flags=0,
+ index=VFU_PCI_DEV_BAR0_REGION_IDX, count=0)
+ newfds, ret = msg_fds(ctx, client.sock, VFIO_USER_DEVICE_GET_REGION_IO_FDS,
+ payload, expect=0)
+ assert len(newfds) == 0
+ reply, ret = vfio_user_region_io_fds_reply.pop_from_buffer(ret)
+ assert reply.count == 0
+
+ vfu_destroy_ctx(ctx)
+
+
def test_shadow_ioeventfd():
"""Configure a shadow ioeventfd, have the client trigger it, confirm that
the server receives the notification and can see the value."""