aboutsummaryrefslogtreecommitdiff
AgeCommit message (Collapse)AuthorFilesLines
2021-01-27fix obsolete reference to muser (#268)Thanos Makatos1-2/+2
Signed-off-by: Thanos Makatos <thanos.makatos@nutanix.com>
2021-01-27implement fake guest thread in client/server live migration sample (#264)Thanos Makatos3-21/+130
* add fake guest thread in migration sample This patch adds a thread that pretends to be the guest VM (while the client itself is the VMM) in the live migration sample. Our goal is to have the fake guest modifying device state while live migration is ongoing and when live migration has finished the device state should be correct in the destination server. Currently this doesn't work because the server blindly applies device state when resuming, which is wrong because some device state must be applied to specific offsets. To fix this we have to include the offset and length (along with BAR1 data) in the migration stream. Signed-off-by: Thanos Makatos <thanos.makatos@nutanix.com>
2021-01-26store BAR1 in pre-copy and BAR0 in stop-and-copy (#256)Thanos Makatos1-6/+17
Signed-off-by: Thanos Makatos <thanos.makatos@nutanix.com>
2021-01-26cache pending_bytes (#246)Thanos Makatos1-6/+7
In VFIO, pending_bytes can be re-read and each time it's read the device can return a new value (even higher than the previous one). Rather than exposing the vfio-user device implementation to such complicated semantics, we cache pending_bytes and handle repeated calls to it ourselves. Even if pending_bytes does change in the device, the client will either way read it as a part of the current migration iteration. Signed-off-by: Thanos Makatos <thanos.makatos@nutanix.com>
2021-01-26don't return wrong data_offset in resuming state (#253)Thanos Makatos1-16/+12
Signed-off-by: Thanos Makatos <thanos.makatos@nutanix.com>
2021-01-26drop data_size and migr_data (#245)Thanos Makatos1-20/+14
We don't need data_size, it only complicates things. We don't use migr_data at all. Signed-off-by: Thanos Makatos <thanos.makatos@nutanix.com>
2021-01-26minor comments and assertions (#258)Thanos Makatos1-1/+3
Signed-off-by: Thanos Makatos <thanos.makatos@nutanix.com>
2021-01-26reset migration iteration state whenever VFIO device migration state changes ↵Thanos Makatos1-0/+1
(#254) Signed-off-by: Thanos Makatos <thanos.makatos@nutanix.com>
2021-01-26use names for migration states when logging (#250)Thanos Makatos3-27/+126
Plus migration states array fixes and unit tests. Signed-off-by: Thanos Makatos <thanos.makatos@nutanix.com>
2021-01-26don't remain in wrong migration iteration state after data have been ↵Thanos Makatos1-0/+8
prepared (#257) Signed-off-by: Thanos Makatos <thanos.makatos@nutanix.com>
2021-01-26introduce function for transitioning vfio-user migration iteration states (#263)Thanos Makatos1-2/+10
This makes it easier to tell where we change the migration iteration state. In the future we might also perform additional validations.
2021-01-25add pre-copy phase in live migration example (#247)Thanos Makatos4-118/+270
This patch adds a simplistic pre-copy phase in the live migration sample. The end goal is have a separate thread in the client to modify device state while the device is in the pre-copy phase. This will be done in later patches. BAR1 is saved during the pre-copy phase and BAR0 is saved during the stop-and-copy phase. This is purely for convenience. There are quite a few assumptions and FIXMEs, even in the client code. We plan to address them in future patches. Signed-off-by: Thanos Makatos <thanos.makatos@nutanix.com>
2021-01-25don't assume specific message ID when negotiating (#248)Thanos Makatos2-8/+7
Signed-off-by: Thanos Makatos <thanos.makatos@nutanix.com>
2021-01-25use unique message IDs in client sample (#255)Thanos Makatos1-10/+11
This makes debugging a little bit easier. Signed-off-by: Thanos Makatos <thanos.makatos@nutanix.com>
2021-01-25print errno string instead of errno value (#251)Thanos Makatos1-2/+2
Signed-off-by: Thanos Makatos <thanos.makatos@nutanix.com>
2021-01-25explain migration workflow when saving state (#252)Thanos Makatos1-0/+14
Signed-off-by: Thanos Makatos <thanos.makatos@nutanix.com>
2021-01-25minor comments (#249)Thanos Makatos1-1/+9
Signed-off-by: Thanos Makatos <thanos.makatos@nutanix.com>
2021-01-25rename _migr_state_transition_is_valid to ↵Thanos Makatos1-2/+2
vfio_migr_state_transition_is_valid for clarity (#260) Signed-off-by: Thanos Makatos <thanos.makatos@nutanix.com>
2021-01-25minor comments (#262)Thanos Makatos1-1/+9
Signed-off-by: Thanos Makatos <thanos.makatos@nutanix.com>
2021-01-25don't swallow errors when writing data_size (#261)Thanos Makatos1-3/+5
Signed-off-by: Thanos Makatos <thanos.makatos@nutanix.com>
2021-01-25don't use uninitialized memory (#244)Thanos Makatos2-6/+13
Signed-off-by: Thanos Makatos <thanos.makatos@nutanix.com>
2021-01-25minor rephrasing of get_pending_bytes documentation (#259)Thanos Makatos1-5/+6
Signed-off-by: Thanos Makatos <thanos.makatos@nutanix.com>
2021-01-22install dsn.h (#242)John Levon1-0/+1
Signed-off-by: John Levon <john.levon@nutanix.com> Reviewed-by: Swapnil Ingle <swapnil.ingle@nutanix.com>
2021-01-22fix compilation on newer GCC versions (#241)John Levon6-11/+64
A newer GCC caught that in test_dma_controller_add_region_no_fd(), we were not allocating enough stack space for the region at the end of the dma_controller_t. Also add Fedora Rawhide to github CI for this. Signed-off-by: John Levon <john.levon@nutanix.com> Reviewed-by: Thanos Makatos <thanos.makatos@nutanix.com>
2021-01-21Misc fixes for DMA_MAP region prot (#233)swapnili6-14/+71
* Misc fixes for DMA_MAP region prot 1. Validate prot passed in vfu_addr_to_sg() 2. Let user know region prot via vfu_unmap_dma_cb_t Signed-off-by: Swapnil Ingle <swapnil.ingle@nutanix.com> Reviewed-by: Thanos Makatos <thanos.makatos@nutanix.com>
2021-01-20reword explanation of how dirty bitmaps are returned for clarity (#234)Thanos Makatos1-16/+20
reword explanation of how dirty bitmaps are returned for clarity Signed-off-by: Thanos Makatos <thanos.makatos@nutanix.com>
2021-01-20support extended capabilities (#226)John Levon15-203/+777
Provide initial support for extended capabilities, and implement handlers for the Device Serial Number and Vendor-Specific capabilities. Signed-off-by: John Levon <john.levon@nutanix.com> Reviewed-by: Swapnil Ingle <swapnil.ingle@nutanix.com>
2021-01-20add whole-region mmap area for vfu_setup_region() (#225)John Levon4-68/+52
If an fd is provided, automatically add a mmap area covering the entire region unless an mmap_areas array is provided. Signed-off-by: John Levon <john.levon@nutanix.com> Reviewed-by: Swapnil Ingle <swapnil.ingle@nutanix.com>
2021-01-20re-work API for adding capabilities (#200)John Levon12-738/+908
Allow to add capabilities individually, including extended capabilities, and those to be handled via the region callback. As a side effect, rework config space accesses to handle reads that straddle capabilities and non-standard areas and use callbacks as needed. 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-01-13don't fail vfio_device_info if incoming struct has more fields (#232)Thanos Makatos2-1/+24
Such incompatibilites are expected in the VFIO protocol. That's what argsz is for. Signed-off-by: Thanos Makatos <thanos.makatos@nutanix.com>
2021-01-13make vfu_region_to_offset public (#228)Thanos Makatos2-0/+16
Signed-off-by: Thanos Makatos <thanos.makatos@nutanix.com>
2021-01-08Fix error path (#229)swapnili1-0/+1
Signed-off-by: Swapnil Ingle <swapnil.ingle@nutanix.com> Reviewed-by: Thanos Makatos <thanos.makatos@nutanix.com>
2021-01-08Use prot flags sent by client to map dma regions (#227)swapnili5-17/+45
* Use prot flags sent by client to map dma regions Signed-off-by: Swapnil Ingle <swapnil.ingle@nutanix.com> Reviewed-by: Thanos Makatos <thanos.makatos@nutanix.com>
2021-01-07re-work access handling (#220)John Levon9-470/+367
Various cleanups and fixes to handling of region accesses, including: - there should be no reason for us to split accesses into 1/2/4/8 byte accesses: in general, the client will have already be doing that, and if not, there's no particular reason we should be the ones to split up such larger accesses. - use a callback for PCI config space reads and writes if one is provided (needs more work for capabilities) 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-01-05re-work capability-locating API (#199)John Levon5-75/+154
Explicitly mimic the Linux kernel API: the searching functions return an offset into configuration space. Just like a driver, libvfio-user devices can then look into config space via vfu_pci_get_config_space() to read the capability as needed. In general, the driver itself will know exactly what the size and shape of the capability is, so this seems like a low-friction, and familiar to driver writers, API. Signed-off-by: John Levon <john.levon@nutanix.com> Reviewed-by: Thanos Makatos <thanos.makatos@nutanix.com>
2021-01-04re-work PCI config setup API (#198)John Levon8-69/+94
Split up vfu_pci_setup_config_hdr(): individual "helpers" like vfu_pci_set_id() are much simpler to use than making the user specify the values in header-formatted structs; and this way if we want to add additional helpers, we won't need to modify the existing functions. Signed-off-by: John Levon <john.levon@nutanix.com> Reviewed-by: Thanos Makatos <thanos.makatos@nutanix.com>
2021-01-04move PCI-specific code to pci.c (#219)John Levon7-200/+217
It's still pretty entangled, but move the bulk of the non-cap PCI code over to pci.c. Signed-off-by: John Levon <john.levon@nutanix.com> Reviewed-by: Thanos Makatos <thanos.makatos@nutanix.com>
2021-01-04remove vestigial vfu_mmap() (#221)John Levon2-31/+1
This is no longer useful. Signed-off-by: John Levon <john.levon@nutanix.com> Reviewed-by: Thanos Makatos <thanos.makatos@nutanix.com>
2021-01-04pass vfu_ctx_t to callbacks (#222)John Levon8-105/+121
It's easy (with the new vfu_get_private()) to go from a vfu_ctx to the private pointer, but not the reverse; pass the ctx into all the callbacks. Signed-off-by: John Levon <john.levon@nutanix.com> Reviewed-by: Thanos Makatos <thanos.makatos@nutanix.com>
2021-01-04remove Python bindings (#223)John Levon6-388/+1
They haven't kept pace with recent changes, and at this point are of no real use (and besides, options like CFFI are likely better than hand-rolled bindings). Signed-off-by: John Levon <john.levon@nutanix.com> Reviewed-by: Thanos Makatos <thanos.makatos@nutanix.com>
2020-12-18don't set wrong buffer size when replying to device info region (#217)Thanos Makatos1-5/+7
Signed-off-by: Thanos Makatos <thanos.makatos@nutanix.com>
2020-12-17add mappable bit in DMA segment (#215)Thanos Makatos4-14/+44
remove duplicate code for initializing DMA segment, mark DMA segment whether it's mappable, plus basic unit test for dma_addr_to_sg Signed-off-by: Thanos Makatos <thanos.makatos@nutanix.com>
2020-12-17General fixes (#213)swapnili3-26/+33
* Reorg vfu_create_ctx() * Unconditionally call dma_controller_create() in vfu_setup_device_dma_cb(). * Added UT for vfu_setup_device_dma_cb() Signed-off-by: Swapnil Ingle <swapnil.ingle@nutanix.com> Reviewed-by: Thanos Makatos <thanos.makatos@nutanix.com>
2020-12-17Fix passing of recv_data (#214)swapnili1-1/+1
Signed-off-by: Swapnil Ingle <swapnil.ingle@nutanix.com> Reviewed-by: Thanos Makatos <thanos.makatos@nutanix.com>
2020-12-17add copy of vfio-user protocol specification (v8)Thanos Makatos1-0/+1670
Signed-off-by: Thanos Makatos <thanos.makatos@nutanix.com>
2020-12-17unit test for validating arguments in dma_map_sgThanos Makatos1-1/+32
Signed-off-by: Thanos Makatos <thanos.makatos@nutanix.com>
2020-12-17fail to map segment if DMA region isn't backed by file descriptorThanos Makatos1-1/+4
Signed-off-by: Thanos Makatos <thanos.makatos@nutanix.com>
2020-12-17validate region is segmentThanos Makatos1-0/+8
Signed-off-by: Thanos Makatos <thanos.makatos@nutanix.com>
2020-12-16enable ERR and REQ IRQs by default (#209)Thanos Makatos3-1/+13
enable ERR and REQ IRQs by default Signed-off-by: Thanos Makatos <thanos.makatos@nutanix.com> Reviewed-by: John Levon <john.levon@nutanix.com>
2020-12-16fix clang build (#210)John Levon5-46/+61
Also add clang to pull request build checks. Signed-off-by: John Levon <john.levon@nutanix.com> Reviewed-by: Thanos Makatos <thanos.makatos@nutanix.com>