diff options
author | John Levon <john.levon@nutanix.com> | 2021-06-02 16:08:14 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-06-02 16:08:14 +0100 |
commit | 57684de8240fce4a277301a86a803842338762af (patch) | |
tree | ea1066e2ae4de34bd7b77f9fb7a26af40848b52f /test/py | |
parent | b8234a75d9ec2c95cb889c0cef27927f34ad9cbc (diff) | |
download | libvfio-user-57684de8240fce4a277301a86a803842338762af.zip libvfio-user-57684de8240fce4a277301a86a803842338762af.tar.gz libvfio-user-57684de8240fce4a277301a86a803842338762af.tar.bz2 |
replace max_msg_size with max_data_xfer_size (#541)
The previously specified max_msg_size had one major issue: it implied a (way too
small) limit on the size of dirty bitmaps that could be requested by a client,
and as a result a hard limit on memory region size. It seemed awkward to attempt
to split up an unmap request instead.
Instead, let most requests and replies be limited by their "natural" limits; for
example, the number of booleans in VFIO_USER_SET_IRQS is limited by MSI-X count.
For the requests that solicit or provide data - that is, VFIO_USER_DMA_READ/WRITE
and VFIO_USER_REGION_READ/WRITE - we negotiate a new max_data_xfer_size value.
These are much easier to split up into separate requests at the client side
so should not present an implementation problem. For our server, chunking is
implemented in vfu_dma_read/vfu_dma_write().
Signed-off-by: John Levon <john.levon@nutanix.com>
Reviewed-by: Swapnil Ingle <swapnil.ingle@nutanix.com>
Reviewed-by: Thanos Makatos <thanos.makatos@nutanix.com>
Diffstat (limited to 'test/py')
-rw-r--r-- | test/py/libvfio_user.py | 7 | ||||
-rw-r--r-- | test/py/test_negotiate.py | 17 |
2 files changed, 19 insertions, 5 deletions
diff --git a/test/py/libvfio_user.py b/test/py/libvfio_user.py index b1ebd4b..bdb812a 100644 --- a/test/py/libvfio_user.py +++ b/test/py/libvfio_user.py @@ -106,10 +106,13 @@ VFIO_USER_CLIENT_MAX_FDS_LIMIT = 1024 SERVER_MAX_FDS = 8 -SERVER_MAX_MSG_SIZE = 65536 +ONE_TB = (1024 * 1024 * 1024 * 1024) + +VFIO_USER_DEFAULT_MAX_DATA_XFER_SIZE = (1024 * 1024) +SERVER_MAX_DATA_XFER_SIZE = VFIO_USER_DEFAULT_MAX_DATA_XFER_SIZE +SERVER_MAX_MSG_SIZE = SERVER_MAX_DATA_XFER_SIZE + 16 + 16 MAX_DMA_REGIONS = 16 -ONE_TB = (1024 * 1024 * 1024 * 1024) MAX_DMA_SIZE = (8 * ONE_TB) # enum vfio_user_command diff --git a/test/py/test_negotiate.py b/test/py/test_negotiate.py index e05b450..a3f2a8a 100644 --- a/test/py/test_negotiate.py +++ b/test/py/test_negotiate.py @@ -66,6 +66,15 @@ def test_short_write(): vfu_attach_ctx(ctx, expect=errno.EINVAL) get_reply(sock, expect=errno.EINVAL) +def test_long_write(): + sock = connect_sock() + hdr = vfio_user_header(VFIO_USER_VERSION, size=SERVER_MAX_MSG_SIZE + 1) + sock.send(hdr) + + ret = vfu_attach_ctx(ctx, expect=errno.EINVAL) + assert ret == -1 + assert c.get_errno() == errno.EINVAL + def test_bad_command(): sock = connect_sock() @@ -152,7 +161,7 @@ def test_valid_negotiate_no_json(): assert minor == LIBVFIO_USER_MINOR json = parse_json(json_str) assert json.capabilities.max_msg_fds == SERVER_MAX_FDS - assert json.capabilities.max_msg_size == SERVER_MAX_MSG_SIZE + assert json.capabilities.max_data_xfer_size == SERVER_MAX_DATA_XFER_SIZE # FIXME: migration object checks disconnect_client(ctx, sock) @@ -164,8 +173,10 @@ def test_valid_negotiate_empty_json(): vfu_run_ctx(ctx) def test_valid_negotiate_json(): - client_version_json(json=bytes('{ "capabilities": { "max_msg_fds": %s } }' % - VFIO_USER_CLIENT_MAX_FDS_LIMIT, "utf-8")) + client_version_json(json=bytes( + '{ "capabilities": { "max_msg_fds": %s, "max_data_xfer_size": %u } }' % + (VFIO_USER_CLIENT_MAX_FDS_LIMIT, VFIO_USER_DEFAULT_MAX_DATA_XFER_SIZE), + "utf-8")) # notice client closed connection vfu_run_ctx(ctx) |