aboutsummaryrefslogtreecommitdiff
AgeCommit message (Collapse)AuthorFilesLines
2021-02-04client/server: print number of FDs per region (#302)Thanos Makatos1-2/+4
Signed-off-by: Thanos Makatos <thanos.makatos@nutanix.com>
2021-02-04client/server: misc comments (#304)Thanos Makatos1-1/+12
Signed-off-by: Thanos Makatos <thanos.makatos@nutanix.com>
2021-02-04client/server: move mapping sparse areas to separate function (#301)Thanos Makatos1-14/+36
And print file path when it fails to mmap. Signed-off-by: Thanos Makatos <thanos.makatos@nutanix.com>
2021-02-04add AddressSanitizer run (#291)John Levon2-1/+17
Run unit tests with -fsanitize-address too. Signed-off-by: John Levon <john.levon@nutanix.com> Reviewed-by: Swapnil Ingle <swapnil.ingle@nutanix.com>
2021-02-04close listening socket in vfu_destroy_ctx() (#299)John Levon4-15/+38
We were forgetting to close vfu_ctx->fd, add a tran callback for this. While we're there, clean up the tran callbacks somewhat. Signed-off-by: John Levon <john.levon@nutanix.com> Reviewed-by: Swapnil Ingle <swapnil.ingle@nutanix.com>
2021-02-04fix leaks in unit tests (#298)John Levon1-0/+26
These aren't interesting, but it lets us run ASAN. Signed-off-by: John Levon <john.levon@nutanix.com> Reviewed-by: Swapnil Ingle <swapnil.ingle@nutanix.com>
2021-02-02define full PCI Express capability struct (#289)John Levon2-6/+117
Define the full-size capability as defined in the specification. Previously, we were defining the structure as in the form used by PCI Express Integrated Endpoints. It's reasonable to assume, however, that a vfio-user device is a normal PCI Express Endpoint connected over a Link. We'll go further, and define the whole structure, including the slot registers at the end that are usually only used for Ports. The presumption here is that it can't hurt to use the larger size: the only way a client could care is if it presumed the next capability was at a particular offset from this one, and we must hope nothing is that silly. This also corrects a buffer overflow: cap_size() in fact disagreed with the original size of our struct pxcap (found via clang's address sanitizer). Signed-off-by: John Levon <john.levon@nutanix.com Reviewed-by: Thanos Makatos <thanos.makatos@nutanix.com>
2021-02-01test_process_command_free_passed_fds: fix fd array size (#294)John Levon1-0/+1
We need to initialize .client_max_fds to get the fd array allocated properly in process_request(). Signed-off-by: John Levon <john.levon@nutanix.com> Reviewed-by: Thanos Makatos <thanos.makatos@nutanix.com>
2021-02-01samples/lspci: free vfu context (#293)John Levon1-0/+2
Signed-off-by: John Levon <john.levon@nutanix.com> Reviewed-by: Swapnil Ingle <swapnil.ingle@nutanix.com>
2021-02-01remove stale FIXME (#290)John Levon1-1/+0
Signed-off-by: John Levon <john.levon@nutanix.com> Reviewed-by: Thanos Makatos <thanos.makatos@nutanix.com>
2021-02-01CI: run client/server through Valgrind (#282)Thanos Makatos2-7/+9
CI: run client/server through Valgrind And fail the test if Valgrind discovers any errors. Signed-off-by: Thanos Makatos <thanos.makatos@nutanix.com>
2021-02-01run client/server sample in CI (#274)Thanos Makatos2-0/+14
run client/server sample in CI Signed-off-by: Thanos Makatos <thanos.makatos@nutanix.com>
2021-01-29CI: run apt-get update for Ubuntu 20 (#286)Thanos Makatos1-0/+1
Signed-off-by: Thanos Makatos <thanos.makatos@nutanix.com>
2021-01-28install static library (#267)John Levon1-0/+3
SPDK would like to statically link in libvfio-user, and it builds against a staged installation directory, so always install the static library too. Signed-off-by: John Levon <john.levon@nutanix.com> Reviewed-by: Thanos Makatos <thanos.makatos@nutanix.com>
2021-01-28client/server: don't sleep before migrating (#281)Thanos Makatos1-8/+0
Migration now takes a non-trivial amount of time, plus running the sample through Valgrind will inherently be slower. Signed-off-by: Thanos Makatos <thanos.makatos@nutanix.com>
2021-01-28use unique errno when recv msg ID doesn't match (#280)Thanos Makatos1-1/+1
This is simply to make debugging easier. Signed-off-by: Thanos Makatos <thanos.makatos@nutanix.com>
2021-01-28client/server: arm timer for a little longer (#283)Thanos Makatos1-3/+3
The interrupt might be delivered too soon, when e.g. the client is waiting for a response for a message it previously sent. This isn't 100% bulletproof. Signed-off-by: Thanos Makatos <thanos.makatos@nutanix.com>
2021-01-28client/server: don't leak memory in client (#285)Thanos Makatos1-0/+6
Not that useful, apart from running it through Valgrind in CI. Signed-off-by: Thanos Makatos <thanos.makatos@nutanix.com>
2021-01-28don't leak FDs after response (#284)Thanos Makatos1-1/+1
Signed-off-by: Thanos Makatos <thanos.makatos@nutanix.com>
2021-01-28client/server: make number of migration iterations deterministic (#277)Thanos Makatos1-10/+3
The number of migration iterations would depend on whether or how many times the fake guest thread would touch BAR1. Signed-off-by: Thanos Makatos <thanos.makatos@nutanix.com>
2021-01-28client/server: disarm timer when device is stopped (#276)Thanos Makatos1-0/+5
When the device is set to stop-and-copy state it must stop operating, which means that if it has been previously programmed to triggers it should refrain from doing so. Signed-off-by: Thanos Makatos <thanos.makatos@nutanix.com>
2021-01-28client/server: don't sleep for fake guest thread (#275)Thanos Makatos1-3/+0
The fake guest thread unconditionally performs the first iteration, so there's no need to give it time to do stuff. Signed-off-by: Thanos Makatos <thanos.makatos@nutanix.com>
2021-01-28simplify client/server pre-copy phase by always copying entire BAR1 (#273)Thanos Makatos2-110/+53
Signed-off-by: Thanos Makatos <thanos.makatos@nutanix.com>
2021-01-27allow device to specify data_offset when resuming (#272)Thanos Makatos3-49/+45
Handling data_offset and data_size internally is wrong: we can't simply assume that the migration data should be appending to the migration region, devices might have their own requirements. This also requires a way for the device to return the data_offset, we do this by making the prepare_data callback applicable in resume state. Also, allow migration read/write callabcks to return errors. Signed-off-by: Thanos Makatos <thanos.makatos@nutanix.com>
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>