aboutsummaryrefslogtreecommitdiff
path: root/test/mocks.h
AgeCommit message (Collapse)AuthorFilesLines
2021-05-20migration: various dirty page tracking fixes (#457)Thanos Makatos1-0/+5
- document how to use a vfio-user device with libvirt - document how to use SPDK's nvmf/vfio-user target with libvirt - replace vfio_bitmap with vfio_user_bitmap and vfio_iommu_type1_dirty_bitmap_get with vfio_user_bitmap_range - fix bug for calculating number of pages needed for dirty page bitmap - align number of bytes for dirty page bitmap to QWORD - add debug messages around dirty page tracking - only support flags=0 when doing DMA unmap - set device state to running after reset - allow region read/write even if device is in stopped state - allow transitioning from stopped/stop-and-copy state to running state - fix unit tests Signed-off-by: Thanos Makatos <thanos.makatos@nutanix.com> Reviewed-by: John Levon <john.levon@nutanix.com>
2021-03-31rework DMA callbacks (#396)John Levon1-7/+5
This fixes a number of issues with how DMA is handled, based on some changes by Thanos Makatos: - rename callbacks to register/unregister, as there is not necessarily any mapping - provide the (large) page-aligned mapped start and size, the page size used, as well as the protection flags: some API users need these - for convenience, provide the virtual address separately that corresponds to the mapped region - we should only require a DMA controller to use vfu_addr_to_sg(), not an unregister callback - the callbacks should return errno not -errno - region removal was incorrectly updating the region array - various other cleanups and clarifications Signed-off-by: John Levon <john.levon@nutanix.com> Reviewed-by: Thanos Makatos <thanos.makatos@nutanix.com>
2021-03-25re-work unit test mocking (#400)John Levon1-12/+2
Instead of trying to use the linker's --wrap, which just led to more problems when we want to call the real function, we'll add two defines, MOCK_DEFINE() and MOCK_DECLARE(), that behave differently when building the unit tests, such that all wrapped functions are picked up from test/mocks.c instead, regardless of compilation unit. Signed-off-by: John Levon <john.levon@nutanix.com> Reviewed-by: Thanos Makatos <thanos.makatos@nutanix.com>
2021-03-23add -Wmissing-declarations (#399)John Levon1-42/+6
This is used by SPDK, and it's generally useful. This also uncovered some issues in the test mocking. Signed-off-by: John Levon <john.levon@nutanix.com> Reviewed-by: Swapnil Ingle <swapnil.ingle@nutanix.com>
2021-03-04don't munmap(2) unmapped DMA region (#384)Thanos Makatos1-0/+3
Plus always notify user when DMA region is removed. Signed-off-by: Thanos Makatos <thanos.makatos@nutanix.com> Reviewed-by: John Levon <john.levon@nutanix.com>
2021-03-01don't call user's unmap_dma callback when removing DMA region (#370)Thanos Makatos1-0/+5
Plus unit tests. Signed-off-by: Thanos Makatos <thanos.makatos@nutanix.com> Reported-by: Changpeng Liu <changpeng.liu@intel.com> Reviewed-by: John Levon <john.levon@nutanix.com>
2021-02-18unit test exec_command and friends w.r.t. migration device state (#346)Thanos Makatos1-0/+8
Signed-off-by: Thanos Makatos <thanos.makatos@nutanix.com> Reviewed-by: Swapnil Ingle <swapnil.ingle@nutanix.com>
2021-02-18drop -Wno-implicit-function-declaration from unit tests (#349)Thanos Makatos1-0/+28
This might cause undefined program behavior. Signed-off-by: Thanos Makatos <thanos.makatos@nutanix.com> Reviewed-by: John Levon <john.levon@nutanix.com>
2021-02-17add unit tests for handle dirty pages w/o DMA (#348)Thanos Makatos1-0/+6
Signed-off-by: Thanos Makatos <thanos.makatos@nutanix.com> Reviewed-by: Swapnil Ingle <swapnil.ingle@nutanix.com>
2020-11-27add unit tests for DMA regions without file descriptorThanos Makatos1-0/+39
Signed-off-by: Thanos Makatos <thanos.makatos@nutanix.com>