aboutsummaryrefslogtreecommitdiff
path: root/samples/client.c
AgeCommit message (Collapse)AuthorFilesLines
2023-09-15rename get_bitmap_sizeWilliam Henderson1-2/+2
Signed-off-by: William Henderson <william.henderson@nutanix.com>
2023-09-15respond to Thanos's reviewWilliam Henderson1-26/+25
Signed-off-by: William Henderson <william.henderson@nutanix.com>
2023-09-15respond to Swapnil's reviewWilliam Henderson1-26/+22
Signed-off-by: William Henderson <william.henderson@nutanix.com>
2023-09-15fix: argsz semantics in samplesWilliam Henderson1-2/+2
Signed-off-by: William Henderson <william.henderson@nutanix.com>
2023-09-15fix: minor changes to samples according to John's reviewWilliam Henderson1-7/+7
Signed-off-by: William Henderson <william.henderson@nutanix.com>
2023-09-15reintroduce mmap_sparse_areas in client.cWilliam Henderson1-6/+40
Signed-off-by: William Henderson <william.henderson@nutanix.com>
2023-09-15fix: minor fixes from Swapnil's reviewWilliam Henderson1-1/+5
Signed-off-by: William Henderson <william.henderson@nutanix.com>
2023-09-15fix: update sample to correctly start destination serverWilliam Henderson1-1/+6
Signed-off-by: William Henderson <william.henderson@nutanix.com>
2023-09-15fix: obvious use-after-freeWilliam Henderson1-1/+3
Signed-off-by: William Henderson <william.henderson@nutanix.com>
2023-09-15fix: conflict with kernel definitions in samplesWilliam Henderson1-7/+7
Signed-off-by: William Henderson <william.henderson@nutanix.com>
2023-09-15feat: implement DMA logging in client/server sampleWilliam Henderson1-30/+45
Signed-off-by: William Henderson <william.henderson@nutanix.com>
2023-09-15fix: changes to samples according to commentsWilliam Henderson1-69/+54
Signed-off-by: William Henderson <william.henderson@nutanix.com>
2023-09-15fix: work with changes to implementationWilliam Henderson1-8/+9
Signed-off-by: William Henderson <william.henderson@nutanix.com>
2023-09-15update samples to use migration v2William Henderson1-142/+167
Signed-off-by: William Henderson <william.henderson@nutanix.com>
2022-11-16check spelling (#720)John Levon1-1/+1
Use misspell-fixer if available, and correct the small number of errors it found. Rather than trying to install into the CI, run it directly from a github action. 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-10-04fix compilation for i386 and ppc64 (#709)Thanos Makatos1-27/+50
Signed-off-by: Thanos Makatos <thanos.makatos@nutanix.com> Reviewed-by: John Levon <john.levon@nutanix.com> Reported-by: Eduardo Lima <eblima@gmail.com>
2022-05-27re-work SGL API (#675)John Levon1-1/+1
Harmonize and rename the vfu_*sg() APIs to better reflect their functionality: in our case, there is no mapping happening as part of these calls, they are merely housekeeping for range splitting, dirty tracking, and so on. Signed-off-by: John Levon <john.levon@nutanix.com> Reviewed-by: Thanos Makatos <thanos.makatos@nutanix.com>
2022-05-23libvfio-user.h: sync VFIO_DEVICE_STATE_XXXX definitions with upstream (#690)Jag Raman1-5/+5
Rename VFIO_DEVICE_STATE_XXXX defines as VFIO_DEVICE_STATE_V1_XXXX. Upstream renamed these variable to be of the XXXX_V1_XXXX format and switched an enum for VFIO_DEVICE_STATE_XXXX. Signed-off-by: Jagannathan Raman <jag.raman@oracle.com> Reviewed-by: John Levon <john.levon@nutanix.com> Reviewed-by: Thanos Makatos <thanos.makatos@nutanix.com>
2022-05-13samples/client.c: fix implicit casting of const char pointers (#682)Jag Raman1-2/+2
samples/client.c implicitly casts const char * to char * in a couple of places - as such discards the const qualifier. QEMU complains about this as it builds with -Werror=discarded-qualifiers This patch declares irq_to_str as an array of const char pointers. It also casts a "migrate_to() -> _argv" member explicitly Also adds '-Wwrite-strings' build flag to catch similar issues in the future 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-11/+11
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-09drop usage of MD5_*() (#667)John Levon1-28/+16
These functions from openssl are deprecated, and hence break builds with openssl 3.0, which now has a compiler warning for them. We only use them to check buffer contents; replace them with CRC code from DPDK instead, and entirely drop use of openssl. 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-12-22fix coverity issues (#636)John Levon1-0/+2
Fix three remaining low priority coverity issues; they do not represent bugs. Signed-off-by: John Levon <john.levon@nutanix.com> Reviewed-by: Swapnil Ingle <swapnil.ingle@nutanix.com>
2021-11-11enable options in Valgrind that improve tracking uninit values (#617)Thanos Makatos1-3/+3
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-20fix coverity warnings (#611)John Levon1-9/+14
Fix a few coverity-identified issues. Signed-off-by: John Levon <john.levon@nutanix.com> Reviewed-by: Swapnil Ingle <swapnil.ingle@nutanix.com>
2021-08-27Add support for VFIO_DMA_UNMAP_FLAG_ALL flag (#600)Swapnil Ingle1-0/+13
* 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-06-09drop mappable flag from DMA map (#553)Thanos Makatos1-1/+1
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 Levon1-41/+69
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-11/+11
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-01samples/client: free bitmap data (#547)John Levon1-0/+2
Signed-off-by: John Levon <john.levon@nutanix.com> Reviewed-by: Thanos Makatos <thanos.makatos@nutanix.com>
2021-06-01samples/client: check for reply cmd value (#546)John Levon1-5/+2
With recent spec updates, we are now returning the cmd value in the reply header, so the client can verify it. 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 Levon1-47/+39
- 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-28restore argsz for DMA map/unmap (#523)Thanos Makatos1-19/+18
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>
2021-05-26don't support multiple DMA regions per map/unmap (#520)Thanos Makatos1-17/+16
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-24fix region offset handling (#485)John Levon1-3/+5
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-20migration: various dirty page tracking fixes (#457)Thanos Makatos1-10/+16
- 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-11some specification updates (#465)John Levon1-1/+1
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-04stop using struct vfio_device_info (#456)John Levon1-3/+3
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 Levon1-1/+1
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-04-14libvfio-user.c: use ERROR_INT() (#433)John Levon1-6/+1
Reviewed-by: Thanos Makatos <thanos.makatos@nutanix.com>
2021-04-14hard-code migration region index (#441)John Levon1-44/+28
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-13tran_sock: use ERROR_INT() (#431)John Levon1-62/+40
Signed-off-by: John Levon <john.levon@nutanix.com> Reviewed-by: Thanos Makatos <thanos.makatos@nutanix.com>
2021-04-13drop use of __u* types (#438)John Levon1-5/+5
As we are now pure userspace, there is no need for us to use non-standard integer types. This leaves the copied defines from Linux's vfio.h alone, however. Signed-off-by: John Levon <john.levon@nutanix.com> Reviewed-by: Thanos Makatos <thanos.makatos@nutanix.com>
2021-04-07clean up newlines in logs (#423)John Levon1-3/+3
vfu_log() and err() should not take newlines. Signed-off-by: John Levon <john.levon@nutanix.com> Reviewed-by: Thanos Makatos <thanos.makatos@nutanix.com>
2021-04-06samples client/server: log more consistently (#420)John Levon1-19/+24
Prefix logs with client/server; run the tests verbosely. Signed-off-by: John Levon <john.levon@nutanix.com> Reviewed-by: Thanos Makatos <thanos.makatos@nutanix.com>
2021-03-23globally define _GNU_SOURCE (#401)John Levon1-1/+0
This avoids any issues with multiple definitions when passing CFLAGS in. Signed-off-by: John Levon <john.levon@nutanix.com> Reviewed-by: Swapnil Ingle <swapnil.ingle@nutanix.com>
2021-03-09remove vfu_irq_message() (#389)John Levon1-44/+15
This sends a message to a vfio-user client to trigger an IRQ, instead of writing to an eventfd. However, this isn't necessary on the cases we care about, where eventfds *are* available. Furthermore, this isn't something an API user should need to know about: if we ever care, the better way to do this is to make vfu_irq_trigger() automatically use a message if an eventfd isn't available. Signed-off-by: John Levon <john.levon@nutanix.com> Reviewed-by: Thanos Makatos <thanos.makatos@nutanix.com>
2021-02-18use sizeof() consistently (#351)John Levon1-36/+36
The most common way we have written this is as "sizeof()"; use this form consistently. Signed-off-by: John Levon <john.levon@nutanix.com> Reviewed-by: Thanos Makatos <thanos.makatos@nutanix.com>
2021-02-10expose migration region (#305)Thanos Makatos1-15/+12
This patch exposes the fact that live migration is implemented as a special device region. Hiding this from the user doesn't offer much benefit since it only takes just a little bit of extra code for the user to handle it as a region. We do keep the migration callback functionality since this feature substantially simplifies supporting live migration from the device implementation's perspective. Signed-off-by: Thanos Makatos <thanos.makatos@nutanix.com> Co-authored-by: John Levon <john.levon@nutanix.com>
2021-02-09samples/client: fix confusion over region_info argsz (#318)John Levon1-2/+2
get_device_region_info() was accidentally using the region size as the region info argsz. Signed-off-by: John Levon <john.levon@nutanix.com> Reviewed-by: Thanos Makatos <thanos.makatos@nutanix.com>
2021-02-05use tran_sock_*() namespace (#308)John Levon1-53/+55
Rename (again!) all internal tran_sock APIs so it's very clear which cases are directly using them, perhaps when they shouldn't. Signed-off-by: John Levon <john.levon@nutanix.com> Reviewed-by: Thanos Makatos <thanos.makatos@nutanix.com>