aboutsummaryrefslogtreecommitdiff
AgeCommit message (Collapse)AuthorFilesLines
2021-05-26spec: allow transitioning from stopped/stop-and-copy to running state (#516)Thanos Makatos1-2/+2
In cfe9901 we changed the code to allow transitioning from stopped/stop-and-copy to running state but forgot to udpate the spec. Signed-off-by: Thanos Makatos <thanos.makatos@nutanix.com> Reviewed-by: John Levon <john.levon@nutanix.com>
2021-05-26don't support multiple DMA regions per map/unmap (#520)Thanos Makatos5-272/+128
We're dropping this behavior from the spec. Signed-off-by: Thanos Makatos <thanos.makatos@nutanix.com> Reviewed-by: John Levon <john.levon@nutanix.com>
2021-05-25cleanup some python tests (#482)John Levon4-128/+183
As suggested by Thanos, replace hard-coded struct.pack() with ctypes.Structure objects so it's much clearer what the data being constructed is. Replace some hard-coded unpacking with code based on ctypes::from_buffer_copy(), but in a form that allows us to "pop" a structure from a longer buffer. Signed-off-by: John Levon <john.levon@nutanix.com> Reviewed-by: Thanos Makatos <thanos.makatos@nutanix.com>
2021-05-25don't treat DMA segment as absolute when determining dirty page bit (#519)Thanos Makatos1-28/+2
New DMA regions don't get their pages tracked if dirty page logging has already been started, this patch fixes this bug. Signed-off-by: Thanos Makatos <thanos.makatos@nutanix.com> Reviewed-by: John Levon <john.levon@nutanix.com>
2021-05-25log dirty pages for new DMA regions as well (#518)Thanos Makatos1-26/+48
New DMA regions don't get their pages tracked if dirty page logging has already been started, this patch fixes this bug. Signed-off-by: Thanos Makatos <thanos.makatos@nutanix.com> Reviewed-by: John Levon <john.levon@nutanix.com>
2021-05-25more spec updates (#491)John Levon7-956/+881
update spec to v0.9.1 Changes include: - reply message includes the command number - split out message definitions into request/reply sections, and skip the repeated standard header definitions - lots of markup fixes - re-organization for clarity - further documentation of argsz - remove VFIO_USER_VM_INTERRUPT until we have a working implementation - dirty page tracking is optional - fix implementations to match the spec Signed-off-by: John Levon <john.levon@nutanix.com> Reviewed-by: Thanos Makatos <thanos.makatos@nutanix.com>
2021-05-25add a gcov target (#498)John Levon4-26/+34
"make gcov" is sufficient to run the tests in DEBUG mode and generate gcov output for each .c file in lib/, to give us some idea of our coverage. Signed-off-by: John Levon <john.levon@nutanix.com> Reviewed-by: Swapnil Ingle <swapnil.ingle@nutanix.com>
2021-05-25python tests: add vfu_irq_trigger() (#475)John Levon2-0/+92
Signed-off-by: John Levon <john.levon@nutanix.com> Reviewed-by: Thanos Makatos <thanos.makatos@nutanix.com>
2021-05-25Handle support of PCI FLR capability (#517)Swapnil Ingle4-6/+58
* Handle support of PCI FLR capability If device supports FLR cap then call vfu_reset_cb_t when FLR is initiated by client. Signed-off-by: Swapnil Ingle <swapnil.ingle@nutanix.com> Reviewed-by: John Levon <john.levon@nutanix.com> Reviewed-by: Thanos Makatos <thanos.makatos@nutanix.com>
2021-05-25python tests: add vfu_setup_region() tests (#474)John Levon3-107/+130
Signed-off-by: John Levon <john.levon@nutanix.com> Reviewed-by: Thanos Makatos <thanos.makatos@nutanix.com>
2021-05-24python tests: add VFIO_USER_DEVICE_SET_IRQS (#473)John Levon4-225/+377
Signed-off-by: John Levon <john.levon@nutanix.com> Reviewed-by: Thanos Makatos <thanos.makatos@nutanix.com>
2021-05-24fix region offset handling (#485)John Levon10-98/+86
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>
2021-05-21gpio-pci-idio-16: default to keep running (#470)John Levon1-7/+18
Default the gpio device server sample such that it stays running, so that we can do basic sanity testing of client re-connect. Signed-off-by: John Levon <john.levon@nutanix.com> Reviewed-by: Swapnil Ingle <swapnil.ingle@nutanix.com>
2021-05-20migration: various dirty page tracking fixes (#457)Thanos Makatos12-114/+416
- 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-05-20python tests: add VFIO_USER_DEVICE_GET_REGION_INFO (#471)John Levon4-186/+319
Signed-off-by: John Levon <john.levon@nutanix.com> Reviewed-by: Thanos Makatos <thanos.makatos@nutanix.com>
2021-05-20validate_irq_subindex: skip check of vfu_ctx pointer (#499)John Levon1-4/+2
Signed-off-by: John Levon <john.levon@nutanix.com> Reviewed-by: Swapnil Ingle <swapnil.ingle@nutanix.com>
2021-05-20use cmake3 if available (#503)John Levon1-6/+4
Currently, on systems with both cmake and cmake3, we require cmake even if cmake3 is the only cmake version available (and SPDK encodes this silly requirement). Use and prefer "cmake3" if available. Signed-off-by: John Levon <john.levon@nutanix.com> Reviewed-by: Swapnil Ingle <swapnil.ingle@nutanix.com>
2021-05-17fix DMA unmap dirty page bitmap section (#492)Thanos Makatos1-29/+38
fix DMA unmap dirty page bitmap section Signed-off-by: Thanos Makatos <thanos.makatos@nutanix.com> Reviewed-by: John Levon <john.levon@nutanix.com>
2021-05-15python tests: add VFIO_USER_DEVICE_GET_INFO (#454)John Levon5-40/+94
Signed-off-by: John Levon <john.levon@nutanix.com> Reviewed-by: Thanos Makatos <thanos.makatos@nutanix.com>
2021-05-15move PCI capability testing to Python (#453)John Levon7-440/+758
This also adds a couple of additional tests (as well as more fully testing the region access path). Signed-off-by: John Levon <john.levon@nutanix.com> Reviewed-by: Swapnil Ingle <swapnil.ingle@nutanix.com>
2021-05-14Fix dma read write count (#497)Swapnil Ingle3-5/+5
* spec: Fixed DMA_READ/WRITE data count DMA region size is maxed to uint64_t. Updated DMA_READ/WRITE data count to be defined as uint64_t. * Fix vfu_dma_read/write() as per spec changes Signed-off-by: Swapnil Ingle <swapnil.ingle@nutanix.com> Reviewed-by: John Levon <john.levon@nutanix.com>
2021-05-14enforce linear, squashed history in master branch (#496)John Levon1-2/+2
Due to the CI infrastructure, the logical unit of "keeping the master branch green" is individual PRs (tests can't be run on intra-PR commits). Therefore, we need to enforce that PRs are squashed to a single commit when pushing to master, which also helps keep a clean, meaningful history. Signed-off-by: John Levon <john.levon@nutanix.com> Reviewed-by: Swapnil Ingle <swapnil.ingle@nutanix.com>
2021-05-14dma: Use correct len type (#479)Swapnil Ingle4-8/+29
* dma: Use correct len type vfio_iommu_type1_dirty_bitmap_get.size is of type __u64 dma_controller_dirty_page_get() receives it as int, instead it should be u64 Also added UT to test overflow of length passed to dma_controller_dirty_page_get Fixes: #477 Signed-off-by: Swapnil Ingle <swapnil.ingle@nutanix.com> Reviewed-by: John Levon <john.levon@nutanix.com>
2021-05-14Revert "Merge pull request #493 from swapnili/use-linux-vfio-header"John Levon3-1308/+61
This reverts commit 250aedb026ba557fc4fae6ff301b3b1dfd953c7e, reversing changes made to 71f8b30557d3635336aec06c084188370ed5e248.
2021-05-14Merge pull request #493 from swapnili/use-linux-vfio-headerSwapnil Ingle3-61/+1308
Use linux vfio header
2021-05-11Use defines from linux-headers/linux/vfio.hSwapnil Ingle2-61/+1
Instead of having local copy use the defines from linux-headers/linux/vfio.h. Same as how Qemu does. Signed-off-by: Swapnil Ingle <swapnil.ingle@nutanix.com>
2021-05-11Copy in v5.8 uapi/linux/vfio.hSwapnil Ingle1-0/+1307
Signed-off-by: Swapnil Ingle <swapnil.ingle@nutanix.com>
2021-05-11some specification updates (#465)John Levon6-80/+84
Make a few specification updates after review by Stefan Hajnoczi. Signed-off-by: John Levon <john.levon@nutanix.com> Reviewed-by: Thanos Makatos <thanos.makatos@nutanix.com>
2021-05-11samples/server: correct double mmap() (#483)John Levon1-5/+0
We were accidentally mapping bar0 twice. Signed-off-by: John Levon <john.levon@nutanix.com> Reviewed-by: Thanos Makatos <thanos.makatos@nutanix.com>
2021-05-10python tests: add vfu_create_ctx(), vfu_realize_ctx() (#448)John Levon4-132/+292
Signed-off-by: John Levon <john.levon@nutanix.com> Reviewed-by: Thanos Makatos <thanos.makatos@nutanix.com>
2021-05-10start python-based testing framework (#447)John Levon7-8/+421
Trying to do our unit/functional testing with C is very tedious, and cmocka especially is a continual pain point. This commit introduces a Python-based testing infrastructure, and adds an initial set of functional tests for client negotiation. The tests work under Valgrind for leak/bad access detection of the C code, but not under ASAN, which lacks any meaningful shared-library support. We should be able to replace all of current C-based unit tests with this, reverting samples/ back to demo code only. Signed-off-by: John Levon <john.levon@nutanix.com> Reviewed-by: Thanos Makatos <thanos.makatos@nutanix.com>
2021-05-10fix dma unregister callback during region removal (#464)John Levon4-14/+28
There are two issues with the unregister callback: - we were requiring the callback to be set when removing a region, but it's only required if a consumer wants to map regions - when we removed all regions (for example, on a reset), we weren't triggering the callback Signed-off-by: John Levon <john.levon@nutanix.com> swapnil code review add assert Reviewed-by: Swapnil Ingle <swapnil.ingle@nutanix.com>
2021-05-07don't close outgoing message fds (#472)John Levon1-6/+0
We made a silly mistake in free_msg(): the file descriptors we send out in message replies should never be closed. Signed-off-by: John Levon <john.levon@nutanix.com> Reviewed-by: Swapnil Ingle <swapnil.ingle@nutanix.com>
2021-05-04stop using struct vfio_device_info (#456)John Levon5-14/+25
This struct from vfio.h has grown larger in newer Linux versions; this breaks older clients, as now the server would require the larger size. Replace with our own definition. Signed-off-by: John Levon <john.levon@nutanix.com> Reviewed-by: Thanos Makatos <thanos.makatos@nutanix.com>
2021-05-04refactor message handling path (#376)John Levon8-1187/+1142
Capture message handling inside a new vfu_msg_t private structure and pass that around to the handlers. This provides no functional change, but greatly simplifies and cleans up that path, especially around fd and iovec handling. As part of fixing up the unit tests, start using global variables to reduce the amount of boiler-plate. Signed-off-by: John Levon <john.levon@nutanix.com> Reviewed-by: Thanos Makatos <thanos.makatos@nutanix.com>
2021-05-04fix ubuntu-18 CI (#462)John Levon1-0/+1
We now need to apt update the ubuntu-18 image first. Signed-off-by: John Levon <john.levon@nutanix.com> Reviewed-by: Swapnil Ingle <swapnil.ingle@nutanix.com>
2021-05-04README: fix a small typo (#455)John Levon1-1/+1
Signed-off-by: John Levon <john.levon@nutanix.com> Reviewed-by: Thanos Makatos <thanos.makatos@nutanix.com>
2021-04-23correct PM capability definition (#452)John Levon2-12/+33
the static size assert for the PMCS register was checking the wrong struct; however, the struct was nonetheless 4 bytes long, due to uint bitfields. This accidentally meant the containing struct pmcap was the correct size (the alignment attribute makes no difference). After fixing struct pmcs, we'll include the additional two bytes defined in the PCI PM specification, Section 3.2. These are "optional", but as elsewhere, we'll require them when adding the capability. Signed-off-by: John Levon <john.levon@nutanix.com> Reviewed-by: Thanos Makatos <thanos.makatos@nutanix.com>
2021-04-23handle_region_access(): fix error-path log message (#451)John Levon1-2/+2
This was an error handling message that was missed when converting from -errno to -1 return style. Signed-off-by: John Levon <john.levon@nutanix.com> Reviewed-by: Swapnil Ingle <swapnil.ingle@nutanix.com>
2021-04-23cap_write_pm(): remove assert() (#450)John Levon1-2/+2
Replace client-triggerable assert() with a log message. Signed-off-by: John Levon <john.levon@nutanix.com> Reviewed-by: Swapnil Ingle <swapnil.ingle@nutanix.com>
2021-04-23reduce VFU_MAX_CAPS (#449)John Levon1-3/+3
Our current value of VFU_MAX_CAPS leads to a vfu_ctx_t that is way too large. Reduce the value such that the vfu_ctx_t is under 8KB. Fixes #446. Signed-off-by: John Levon <john.levon@nutanix.com> Reviewed-by: Swapnil Ingle <swapnil.ingle@nutanix.com>
2021-04-19vfu_realize_ctx(): fix default PCI config space region (#445)John Levon2-7/+17
Fix check for an un-configured PCI config space region (the previous method was not accounting for the initialized ->fd). Signed-off-by: John Levon <john.levon@nutanix.com> Reviewed-by: Thanos Makatos <thanos.makatos@nutanix.com>
2021-04-15remove stale comment (#443)John Levon1-2/+0
Missed this FIXME when removing use of __u* types previously. Signed-off-by: John Levon <john.levon@nutanix.com> Reviewed-by: Swapnil Ingle <swapnil.ingle@nutanix.com>
2021-04-15remove vfu_get_region_info() (#444)John Levon3-14/+3
This is only used internally, and not really useful. Signed-off-by: John Levon <john.levon@nutanix.com> Reviewed-by: Swapnil Ingle <swapnil.ingle@nutanix.com>
2021-04-15vfu_ctx_create(): validate flags argument (#442)John Levon3-6/+17
In addition, return ENOTSUP for unknown device types, and add some unit tests. Signed-off-by: John Levon <john.levon@nutanix.com> Reviewed-by: Thanos Makatos <thanos.makatos@nutanix.com>
2021-04-14libvfio-user.c: use ERROR_INT() (#433)John Levon5-120/+116
Reviewed-by: Thanos Makatos <thanos.makatos@nutanix.com>
2021-04-14hard-code migration region index (#441)John Levon4-63/+38
Now we are confident we are OK with a hard-coded VFU_PCI_DEV_MIGR_REGION_IDX value, there's no need for us to track .migr_reg any more, either in the client or internally. Signed-off-by: John Levon <john.levon@nutanix.com> Reviewed-by: Thanos Makatos <thanos.makatos@nutanix.com>
2021-04-14migration: use ERROR_INT() (#432)John Levon4-31/+35
Signed-off-by: John Levon <john.levon@nutanix.com> Reviewed-by: Thanos Makatos <thanos.makatos@nutanix.com>
2021-04-13tran_sock: use ERROR_INT() (#431)John Levon8-158/+145
Signed-off-by: John Levon <john.levon@nutanix.com> Reviewed-by: Thanos Makatos <thanos.makatos@nutanix.com>
2021-04-13pci: use ERROR_INT() (#430)John Levon4-31/+38
Signed-off-by: John Levon <john.levon@nutanix.com> Reviewed-by: Thanos Makatos <thanos.makatos@nutanix.com>