diff options
author | Jag Raman <jraman567@gmail.com> | 2021-07-13 12:18:33 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-07-13 17:18:33 +0100 |
commit | e0c15dfd087f8093ee6aab697e9ac2a252ab42bb (patch) | |
tree | f853f527ae541c03b16055cc1efc5c53e3382ec2 /test/py | |
parent | f44091db918d54211cb43683b091c61a6177d450 (diff) | |
download | libvfio-user-e0c15dfd087f8093ee6aab697e9ac2a252ab42bb.zip libvfio-user-e0c15dfd087f8093ee6aab697e9ac2a252ab42bb.tar.gz libvfio-user-e0c15dfd087f8093ee6aab697e9ac2a252ab42bb.tar.bz2 |
add VFU_REGION_FLAG_ALWAYS_CB to receive callback always (#583)
Diffstat (limited to 'test/py')
-rw-r--r-- | test/py/libvfio_user.py | 1 | ||||
-rw-r--r-- | test/py/test_setup_region.py | 35 |
2 files changed, 36 insertions, 0 deletions
diff --git a/test/py/libvfio_user.py b/test/py/libvfio_user.py index 70986fa..ff5c1cd 100644 --- a/test/py/libvfio_user.py +++ b/test/py/libvfio_user.py @@ -156,6 +156,7 @@ VFU_REGION_FLAG_READ = 1 VFU_REGION_FLAG_WRITE = 2 VFU_REGION_FLAG_RW = (VFU_REGION_FLAG_READ | VFU_REGION_FLAG_WRITE) VFU_REGION_FLAG_MEM = 4 +VFU_REGION_FLAG_ALWAYS_CB = 8 VFIO_USER_F_DMA_REGION_READ = (1 << 0) VFIO_USER_F_DMA_REGION_WRITE = (1 << 1) diff --git a/test/py/test_setup_region.py b/test/py/test_setup_region.py index 0bf120d..c42100f 100644 --- a/test/py/test_setup_region.py +++ b/test/py/test_setup_region.py @@ -114,5 +114,40 @@ def test_setup_region_bad_migr(): assert ret == -1 assert c.get_errno() == errno.EINVAL +def test_setup_region_cfg_always_cb_nocb(): + ret = vfu_setup_region(ctx, index=VFU_PCI_DEV_CFG_REGION_IDX, + size=PCI_CFG_SPACE_EXP_SIZE, cb=None, + flags=(VFU_REGION_FLAG_RW | + VFU_REGION_FLAG_ALWAYS_CB)) + assert ret == -1 + assert c.get_errno() == errno.EINVAL + +@vfu_region_access_cb_t +def pci_cfg_region_cb(ctx, buf, count, offset, is_write): + if not is_write: + for i in range(count): + buf[i] = 0xcc + + return count + +def test_setup_region_cfg_always_cb(): + global ctx + + ret = vfu_setup_region(ctx, index=VFU_PCI_DEV_CFG_REGION_IDX, + size=PCI_CFG_SPACE_EXP_SIZE, cb=pci_cfg_region_cb, + flags=(VFU_REGION_FLAG_RW | + VFU_REGION_FLAG_ALWAYS_CB)) + assert ret == 0 + + ret = vfu_realize_ctx(ctx) + assert ret == 0 + + sock = connect_client(ctx) + + payload = read_region(ctx, sock, VFU_PCI_DEV_CFG_REGION_IDX, offset=0, count=2) + assert payload == b'\xcc\xcc' + + disconnect_client(ctx, sock) + def test_setup_region_cleanup(): vfu_destroy_ctx(ctx) |