diff options
author | Swapnil Ingle <swapnil.ingle@nutanix.com> | 2021-08-27 13:18:53 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-08-27 13:18:53 +0200 |
commit | 080e664ed5e79dcf5ae5a36521cab0ddb7ebc5f0 (patch) | |
tree | 5d920a8a71aa57f088aba9a6f881c71121866f69 /test/py | |
parent | 2ed612697e8fde14e9995cc1ac4dd5143ae8e0b7 (diff) | |
download | libvfio-user-080e664ed5e79dcf5ae5a36521cab0ddb7ebc5f0.zip libvfio-user-080e664ed5e79dcf5ae5a36521cab0ddb7ebc5f0.tar.gz libvfio-user-080e664ed5e79dcf5ae5a36521cab0ddb7ebc5f0.tar.bz2 |
Add support for VFIO_DMA_UNMAP_FLAG_ALL flag (#600)
* Add support for VFIO_DMA_UNMAP_FLAG_ALL flag
Signed-off-by: Swapnil Ingle <swapnil.ingle@nutanix.com>
Reviewed-by: John Levon <john.levon@nutanix.com>
Diffstat (limited to 'test/py')
-rw-r--r-- | test/py/libvfio_user.py | 2 | ||||
-rw-r--r-- | test/py/test_dma_unmap.py | 34 |
2 files changed, 35 insertions, 1 deletions
diff --git a/test/py/libvfio_user.py b/test/py/libvfio_user.py index c7e3765..bf3e9cd 100644 --- a/test/py/libvfio_user.py +++ b/test/py/libvfio_user.py @@ -97,6 +97,8 @@ VFIO_IRQ_SET_ACTION_MASK = (1 << 3) VFIO_IRQ_SET_ACTION_UNMASK = (1 << 4) VFIO_IRQ_SET_ACTION_TRIGGER = (1 << 5) +VFIO_DMA_UNMAP_FLAG_ALL = (1 << 1) + # libvfio-user defines VFU_TRANS_SOCK = 0 diff --git a/test/py/test_dma_unmap.py b/test/py/test_dma_unmap.py index 0200c43..f070ede 100644 --- a/test/py/test_dma_unmap.py +++ b/test/py/test_dma_unmap.py @@ -65,7 +65,7 @@ def test_dma_unmap_bad_argsz(): def test_dma_unmap_invalid_flags(): payload = vfio_user_dma_unmap(argsz=len(vfio_user_dma_unmap()), - flags=0x2323, addr=0x1000, size=4096) + flags=0x4, addr=0x1000, size=4096) msg(ctx, sock, VFIO_USER_DMA_UNMAP, payload, expect=errno.ENOTSUP) def test_dma_unmap(): @@ -74,6 +74,38 @@ def test_dma_unmap(): flags=0, addr=0x1000, size=4096) msg(ctx, sock, VFIO_USER_DMA_UNMAP, payload) +def test_dma_unmap_all(): + + for i in range(0, MAX_DMA_REGIONS): + payload = vfio_user_dma_map(argsz=len(vfio_user_dma_map()), + flags=(VFIO_USER_F_DMA_REGION_READ | + VFIO_USER_F_DMA_REGION_WRITE), + offset=0, addr=0x1000 * i, size=4096) + + msg(ctx, sock, VFIO_USER_DMA_MAP, payload) + + payload = vfio_user_dma_unmap(argsz=len(vfio_user_dma_unmap()), + flags=VFIO_DMA_UNMAP_FLAG_ALL, addr=0, size=0) + + msg(ctx, sock, VFIO_USER_DMA_UNMAP, payload) + +def test_dma_unmap_all_invalid_addr(): + + payload = vfio_user_dma_unmap(argsz=len(vfio_user_dma_unmap()), + flags=VFIO_DMA_UNMAP_FLAG_ALL, addr=0x10000, size=4096) + + msg(ctx, sock, VFIO_USER_DMA_UNMAP, payload, expect=errno.EINVAL) + +def test_dma_unmap_all_invalid_flags(): + + payload = vfio_user_dma_unmap(argsz=len(vfio_user_dma_unmap()), + flags=(VFIO_DMA_UNMAP_FLAG_ALL | VFIO_DMA_UNMAP_FLAG_GET_DIRTY_BITMAP), + addr=0, size=0) + + msg(ctx, sock, VFIO_USER_DMA_UNMAP, payload, expect=errno.EINVAL) + def test_dma_unmap_cleanup(): disconnect_client(ctx, sock) vfu_destroy_ctx(ctx) + +# ex: set tabstop=4 shiftwidth=4 softtabstop=4 expandtab |