aboutsummaryrefslogtreecommitdiff
path: root/test
AgeCommit message (Collapse)AuthorFilesLines
2022-05-17tests: add checks to confirm test environment (#688)Jag Raman2-3/+8
test-lspci.sh: some test platforms don't include the lspci command, as such skip this test if lspci is not found test-linkage.sh: specify the source and build root paths of the subproject instead of the root paths of the master project Signed-off-by: Jagannathan Raman <jag.raman@oracle.com> Reviewed-by: John Levon <john.levon@nutanix.com>
2022-05-12run scan-build in CI (#680)John Levon1-1/+1
Yet another static analyzer pass, this one is used by SPDK, and as it did detect some minor issues, it's worth running. Signed-off-by: John Levon <john.levon@nutanix.com> Reviewed-by: Thanos Makatos <thanos.makatos@nutanix.com>
2022-05-09build: delete CMake build rulesDaniel P. Berrangé2-67/+1
Now that Meson is functional, support for building with CMake is removed so that there is only one build system to maintain. Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
2022-05-09build: introduce Meson build file rulesDaniel P. Berrangé2-0/+170
The Meson build system used by many other virt projects (QEMU, libvirt and others) is easier to understand & maintain rules for than cmake, guiding towards best practice. Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
2022-05-09test: pass in location of libvfio-user.so libraryDaniel P. Berrangé1-0/+2
The test currently hardwires a location based on where cmake creates binaries. Pass in an explicit location via LIBVFIO_SO_DIR env variable, to override this hardwired default. Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
2022-05-09test: optionally pass in 'client' and 'server' pathDaniel P. Berrangé1-2/+8
Rather than assuming the location of the client and server binaries, allowing passing in explicit paths. Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
2022-05-09test: optionally pass in 'lspci' pathDaniel P. Berrangé1-1/+5
Rather than assuming the location of the lspci binary, allowing passing in an explicit path. Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
2022-04-28test library linkage (#665)John Levon2-0/+56
Add a cheesy test for identifying functions in the public header that are not exported. Signed-off-by: John Levon <john.levon@nutanix.com> Reviewed-by: Thanos Makatos <thanos.makatos@nutanix.com>
2022-04-28lib: export dma_sg_size symbol in library (#664)Daniel Berrangé2-0/+10
The dma_sg_size() method is listed in libvfio-user.h but the symbol is marked private in the ELF library. Signed-off-by: Daniel P. Berrangé <berrange@redhat.com> Reviewed-by: John Levon <john.levon@nutanix.com> Reviewed-by: Thanos Makatos <thanos.makatos@nutanix.com>
2022-04-21support AFL++ fuzzing (#623)John Levon3-1/+6
To support fuzzing with AFL++, add a "pipe" transport that reads from stdin and outputs to stdout: this is the most convenient way of doing fuzzing. Add some docs on how to run a fuzzing session. 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>
2022-04-19use struct iovec for grouping buffer and length (#658)Thanos Makatos1-7/+7
This make it tidier and easier to pass to function the buffer and length, instead of passing the whole msg. Signed-off-by: Thanos Makatos <thanos.makatos@nutanix.com> Reviewed-by: John Levon <john.levon@nutanix.com>
2022-03-24use --exit-on-first-error=yes with valgrind (#655)John Levon1-1/+1
Catch valgrind issues earlier with less noise. Signed-off-by: John Levon <john.levon@nutanix.com> Reviewed-by: Thanos Makatos <thanos.makatos@nutanix.com>
2022-02-18test/py: simplify errno handling (#645)John Levon15-109/+102
We explicitly identify the quiesce EBUSY case for msg(), letting us simplify the handling of expected errno. Signed-off-by: John Levon <john.levon@nutanix.com> Reviewed-by: Swapnil Ingle <swapnil.ingle@nutanix.com>
2022-02-14test/py: don't stop logging twice (#644)John Levon1-5/+0
We were accidentally calling VFIO_USER_DIRTY_PAGES twice. Signed-off-by: John Levon <john.levon@nutanix.com> Reviewed-by: Thanos Makatos <thanos.makatos@nutanix.com>
2022-02-04ignore writes to RO MSI-X registers (#642)Thanos Makatos2-2/+74
Signed-off-by: Thanos Makatos <thanos.makatos@nutanix.com> Reviewed-by: John Levon <john.levon@nutanix.com>
2021-12-09allow DMA funcs to be called in quiesced state (#635)Thanos Makatos3-11/+168
Signed-off-by: Thanos Makatos <thanos.makatos@nutanix.com> Reviewed-by: John Levon <john.levon@nutanix.com>
2021-12-02test more region access validation code (#634)John Levon1-1/+25
Add a little more coverage of our validation, and correct a small typo. Signed-off-by: John Levon <john.levon@nutanix.com> Reviewed-by: Thanos Makatos <thanos.makatos@nutanix.com>
2021-11-30introduce device quiesce callback (#609)Thanos Makatos22-281/+1048
Signed-off-by: Thanos Makatos <thanos.makatos@nutanix.com> Reviewed-by: John Leon <john.levon@nutanix.com>
2021-11-24verify region is mapped before acquiring dirty bitmap (#627)John Levon3-47/+61
DMA regions not mapped by the server are not dirty tracked (the client must track changes via handling VFIO_USER_DMA_WRITE), but we weren't correctly enforcing this, which could segfault when ->dirty_bitmap was NULL. Found via AFL++. Signed-off-by: John Levon <john.levon@nutanix.com> Reviewed-by: Thanos Makatos <thanos.makatos@nutanix.com>
2021-11-24check ->argsz for VFIO_USER_DIRTY_PAGES (#628)John Levon1-0/+12
We weren't checking for a too-large ->argsz for this command. Signed-off-by: John Levon <john.levon@nutanix.com> Reviewed-by: Thanos Makatos <thanos.makatos@nutanix.com>
2021-11-24fix dma unmap validation (#626)John Levon1-2/+21
There were two issues with unmap request validation when the dirty bitmap flag was set: - we weren't checking ->argsz against the maximum transfer size, allowing a client to trigger unbounded allocations - we needed to check for overflow when calculating the requested message out size Found via AFL++. Signed-off-by: John Levon <john.levon@nutanix.com> Reviewed-by: Thanos Makatos <thanos.makatos@nutanix.com>
2021-11-24is_valid_region_access(): account for wrap-around (#624)John Levon2-0/+21
AFL++ found this, though we already knew about it, so fix it by comparing against a saturating addition. This was the only instance of client-controlled potential overflow I noticed. 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>
2021-11-12don't assert in dev_get_caps() (#621)John Levon1-0/+30
As clients control ->client_max_fds, we should return an error, not assert, if we can't represent a region's mmap_areas. Found via AFL++. Signed-off-by: John Levon <john.levon@nutanix.com> Reviewed-by: Swapnil Ingle <swapnil.ingle@nutanix.com>
2021-11-11Fix reply of VFIO_USER_DEVICE_GET_REGION_INFO (#619)Swapnil Ingle1-2/+6
* Fix reply of VFIO_USER_DEVICE_GET_REGION_INFO Set VFIO_REGION_INFO_FLAG_CAPS flag only if caps are part of the reply. Signed-off-by: Swapnil Ingle <swapnil.ingle@nutanix.com> Reviewed-by: John Levon <john.levon@nutanix.com>
2021-11-11enable options in Valgrind that improve tracking uninit values (#617)Thanos Makatos1-1/+1
These extra options make tracking uninitilized values easier. They make Valgrind run slower so we need to increase the timeouts in the CI. Signed-off-by: Thanos Makatos <thanos.makatos@nutanix.com> Reviewed-by: John Levon <john.levon@nutanix.com>
2021-10-22run python code through flake8 (#613)John Levon20-201/+446
Aside from general style goodness, this found a couple of accidental re-definitions, so it's worth taking the pain now. Also, only run rstlint as part of pre-push. Signed-off-by: John Levon <john.levon@nutanix.com> Reviewed-by: Swapnil Ingle <swapnil.ingle@nutanix.com>
2021-10-05make migration state callback optionally asynchronous (#608)Thanos Makatos2-6/+165
Some devices need the migration state callback to be asynchronous. The simplest way to implement this is to require from the callback to return -1 and set errno to EBUSY, not process any other new messages (vfu_ctx_run returns -1 and sets errno to EBUSY), and provide a way to the user to complete migration (vfu_migr_done). Signed-off-by: Thanos Makatos <thanos.makatos@nutanix.com> Reviewed-by: John Levon <john.levon@nutanix.com> Reviewed-by: Swapnil Ingle <swapnil.ingle@nutanix.com>
2021-09-28disable VFIO_USER_DEVICE_GET_REGION_IO_FDS on invalid region (#607)John Levon1-1/+1
If a region is not set up, asking for its iofds should fail with EINVAL. Co-authored-by: John Levon <john.levon@nutanix.com> Signed-off-by: John Levon <john.levon@nutanix.com> Reviewed-by: Thanos Makatos <thanos.makatos@nutanix.com>
2021-09-28fix issue with get_region_io_fds when fd = -1 (#606)John Levon1-2/+21
An unmappable region should still allow io fds, as they are orthogonal. Co-authored-by: John Levon <john.levon@nutanix.com> Signed-off-by: John Levon <john.levon@nutanix.com> Reviewed-by: Thanos Makatos <thanos.makatos@nutanix.com>
2021-09-08initial ioeventfd support (#601)JAKelly102-1/+392
Provide initial support for handling VFIO_USER_DEVICE_GET_REGION_IO_FDS, along with a new vfu_create_ioeventfd() API. Reviewed-by: John Levon <john.levon@nutanix.com>
2021-08-27Add support for VFIO_DMA_UNMAP_FLAG_ALL flag (#600)Swapnil Ingle2-1/+35
* 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>
2021-08-26Fix err path of handle_dma_unmap() (#597)Swapnil Ingle2-0/+88
* initial dma_unmap test Signed-off-by: John Levon <john.levon@nutanix.com> Signed-off-by: Swapnil Ingle <swapnil.ingle@nutanix.com> * Fix err path of handle_dma_unmap() Set msg->out_size before successful return. Otherwise in case of error reply path we may endup setting iovecs[1].iov_len with invalid iovecs[1].iov_base in tran_sock_reply() Signed-off-by: Swapnil Ingle <swapnil.ingle@nutanix.com> Reviewed-by: John Levon <john.levon@nutanix.com>
2021-08-20pytests for vfu_dma_{map, unmap}_sg (#596)Swapnil Ingle4-92/+145
* pytests for vfu_dma_{map, unmap}_sg Signed-off-by: Swapnil Ingle <swapnil.ingle@nutanix.com> Reviewed-by: John Levon <john.levon@nutanix.com>
2021-08-19dma: cleanup dma_{map,unmap}_sg (#591)Swapnil Ingle1-10/+50
* dma: cleanup dma_{map,unmap}_sg Instead of using index to traverse sg and iovec, better to use it as pointers. It's more readable and less prone from coding mistakes. Also adding unit tests for the same. Signed-off-by: Swapnil Ingle <swapnil.ingle@nutanix.com> Reviewed-by: John Levon <john.levon@nutanix.com>
2021-07-14check for valid vfu_setup_region() flags (#579)John Levon1-0/+11
Complain about a region that isn't readable *or* writable, or any unknown flags. Signed-off-by: John Levon <john.levon@nutanix.com> Reviewed-by: Thanos Makatos <thanos.makatos@nutanix.com>
2021-07-14check vfu_run_ctx() in python tests (#582)John Levon1-6/+9
Verify that the return value from vfu_run_ctx() is what we're expecting, rather than just driving on in case of error. Signed-off-by: John Levon <john.levon@nutanix.com> Reviewed-by: Thanos Makatos <thanos.makatos@nutanix.com>
2021-07-13add VFU_REGION_FLAG_ALWAYS_CB to receive callback always (#583)Jag Raman2-0/+36
2021-06-30return process request count in vfu_run_ctx() (#574)John Levon1-13/+0
Consumers such as SPDK would like to know if any actual work was done. Modify the API to support this. Also, clean up some stale mocking we no longer use. Signed-off-by: John Levon <john.levon@nutanix.com> Reviewed-by: Thanos Makatos <thanos.makatos@nutanix.com>
2021-06-18superficially handle Device Control 2 and Link Control 2 (#568)Thanos Makatos2-0/+30
* superficially handle Device Control 2 and Link Control 2 Signed-off-by: Thanos Makatos <thanos.makatos@nutanix.com> Reviewed-by: John Levon <john.levon@nutanix.com>
2021-06-10dma: Fix returned sg array (#564)Swapnil Ingle1-11/+39
_dma_addr_sg_split() is supposed to return back sg's if the requested dma addr spans across regions. Also adding unit tests to cover these case. Signed-off-by: Swapnil Ingle <swapnil.ingle@nutanix.com> Reviewed-by: Thanos Makatos <thanos.makatos@nutanix.com>
2021-06-10python tests: add msg() utility function (#562)John Levon9-271/+98
Most tests need to send a request, process it, then retrieve the reply. Add a utility function to avoid lots of tedious boilerplate. Signed-off-by: John Levon <john.levon@nutanix.com> Reviewed-by: Thanos Makatos <thanos.makatos@nutanix.com>
2021-06-09clear dirty pages bitmap after getting dirty pages but keep mapped segments ↵Thanos Makatos3-21/+95
dirty (#551) Signed-off-by: Thanos Makatos <thanos.makatos@nutanix.com> Reviewed-by: John Levon <john.levon@nutanix.com>
2021-06-09test_device_set_irqs: fix bool test (#561)John Levon1-0/+2
We were accidentally hitting the wrong error condition for one of these tests, and hence not properly covering the intended failure path. Signed-off-by: John Levon <john.levon@nutanix.com> Reviewed-by: Thanos Makatos <thanos.makatos@nutanix.com>
2021-06-09drop mappable flag from DMA map (#553)Thanos Makatos3-7/+2
The flags field belongs to VFIO and it's not a good idea to reuse as new VFIO flags can break things. Instead, we derive whether or not a region is mappable if a file descriptor is passed. Signed-off-by: Thanos Makatos <thanos.makatos@nutanix.com> Reviewed-by: Swapnil Ingle <swapnil.ingle@nutanix.com> Reviewed-by: John Levon <john.levon@nutanix.com>
2021-06-02replace max_msg_size with max_data_xfer_size (#541)John Levon2-5/+19
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>
2021-06-02clean up migration register definitions (#550)John Levon1-1/+2
We should explicitly define the expected migration register contents for API users who aren't using the callbacks. Clean up some related lint. Signed-off-by: John Levon <john.levon@nutanix.com> Reviewed-by: Thanos Makatos <thanos.makatos@nutanix.com>
2021-06-01limit max DMA region size (#545)John Levon2-0/+105
Since the dirty bitmap in message replies is allocated based upon the maximum size of an individual region, add a limit (somewhat arbitrarily 8TiB, which is a bitmap size of 256MiB). Add a couple of basic tests on the two DMA limits. Signed-off-by: John Levon <john.levon@nutanix.com> Reviewed-by: Thanos Makatos <thanos.makatos@nutanix.com>
2021-06-01fixes for VFIO_USER_DIRTY_PAGES (#537)John Levon6-123/+474
- we should only accept one range, not multiple ones - clearly define and implement argsz behaviour - we need to check if migration is configured - add proper test coverage; move existing testing to python Signed-off-by: John Levon <john.levon@nutanix.com> Reviewed-by: Thanos Makatos <thanos.makatos@nutanix.com>
2021-05-28don't return non-zero caps for zero-sized regions (#543)Thanos Makatos1-0/+78
Signed-off-by: Thanos Makatos <thanos.makatos@nutanix.com> Reviewed-by: John Levon <john.levon@nutanix.com>
2021-05-28restore argsz for DMA map/unmap (#523)Thanos Makatos1-34/+44
use DMA map/unmap format similar to VFIO's Using a DMA map/unmap format similar to VFIO's (vfio_iommu_type1_dma_map / vfio_iommu_type1_dma_unmap) makes it easier to adapt to future changes. Consequently we also honor the passed argsz. Signed-off-by: Thanos Makatos <thanos.makatos@nutanix.com> Reviewed-by: John Levon <john.levon@nutanitx.com>