aboutsummaryrefslogtreecommitdiff
path: root/test/py/test_device_get_region_info.py
diff options
context:
space:
mode:
authorJohn Levon <john.levon@nutanix.com>2021-05-24 10:42:42 +0100
committerGitHub <noreply@github.com>2021-05-24 10:42:42 +0100
commitbf3938dec68e1c820063db4f63aa2355c5703e4b (patch)
treeddb63a16a166d52ee8f5506f649faee79ada2240 /test/py/test_device_get_region_info.py
parent300f87e1b02e979da8cec444249f09ea0ef167a0 (diff)
downloadlibvfio-user-bf3938dec68e1c820063db4f63aa2355c5703e4b.zip
libvfio-user-bf3938dec68e1c820063db4f63aa2355c5703e4b.tar.gz
libvfio-user-bf3938dec68e1c820063db4f63aa2355c5703e4b.tar.bz2
fix region offset handling (#485)
The specification states that the region offset given in the region info should be used as the "offset" when mmap()ing the region from the client side. However, the library instead implemented a fixed offset scheme similar to that of vfio - and no clients actually set up the file like that. Instead, let servers define their own offsets, and pass them through to clients as is. It's up to the server to decide how its backing file or files is organized. Signed-off-by: John Levon <john.levon@nutanix.com> Reviewed-by: Thanos Makatos <thanos.makatos@nutanix.com>
Diffstat (limited to 'test/py/test_device_get_region_info.py')
-rw-r--r--test/py/test_device_get_region_info.py12
1 files changed, 7 insertions, 5 deletions
diff --git a/test/py/test_device_get_region_info.py b/test/py/test_device_get_region_info.py
index 101a561..742e689 100644
--- a/test/py/test_device_get_region_info.py
+++ b/test/py/test_device_get_region_info.py
@@ -50,9 +50,9 @@ def test_device_get_region_info_setup():
mmap_areas = [ (0x2000, 0x1000), (0x4000, 0x2000) ]
- ret = vfu_setup_region(ctx, index=VFU_PCI_DEV_BAR2_REGION_IDX, size=0x10000,
+ ret = vfu_setup_region(ctx, index=VFU_PCI_DEV_BAR2_REGION_IDX, size=0x8000,
flags=(VFU_REGION_FLAG_RW | VFU_REGION_FLAG_MEM),
- mmap_areas=mmap_areas, fd=f.fileno())
+ mmap_areas=mmap_areas, fd=f.fileno(), offset=0x8000)
assert ret == 0
f = tempfile.TemporaryFile()
@@ -118,7 +118,7 @@ def test_device_get_region_info_larger_argsz():
assert info.index == VFU_PCI_DEV_BAR1_REGION_IDX
assert info.cap_off == 0
assert info.size == 4096
- assert info.offset == vfu_region_to_offset(VFU_PCI_DEV_BAR1_REGION_IDX)
+ assert info.offset == 0
def test_device_get_region_info_small_argsz_caps():
global sock
@@ -139,8 +139,8 @@ def test_device_get_region_info_small_argsz_caps():
VFIO_REGION_INFO_FLAG_CAPS)
assert info.index == VFU_PCI_DEV_BAR2_REGION_IDX
assert info.cap_off == 0
- assert info.size == 0x10000
- assert info.offset == vfu_region_to_offset(VFU_PCI_DEV_BAR2_REGION_IDX)
+ assert info.size == 0x8000
+ assert info.offset == 0x8000
# skip reading the SCM_RIGHTS
disconnect_client(ctx, sock)
@@ -165,6 +165,8 @@ def test_device_get_region_info_caps():
assert info.argsz == 80
assert info.cap_off == 32
+ assert info.size == 0x8000
+ assert info.offset == 0x8000
assert cap.id == VFIO_REGION_INFO_CAP_SPARSE_MMAP
assert cap.version == 1