aboutsummaryrefslogtreecommitdiff
path: root/samples
diff options
context:
space:
mode:
authorThanos Makatos <thanos.makatos@nutanix.com>2021-01-27 16:56:42 +0000
committerGitHub <noreply@github.com>2021-01-27 16:56:42 +0000
commit8adcf8f0394e68bdc04a75361898ff57bc29ddbc (patch)
treeaad7070b51863c3a0c77fd4770ca49b37af8ee38 /samples
parentfe8079d3a6c5d8d7ac2da1a747ae363668d0f9e2 (diff)
downloadlibvfio-user-8adcf8f0394e68bdc04a75361898ff57bc29ddbc.zip
libvfio-user-8adcf8f0394e68bdc04a75361898ff57bc29ddbc.tar.gz
libvfio-user-8adcf8f0394e68bdc04a75361898ff57bc29ddbc.tar.bz2
allow device to specify data_offset when resuming (#272)
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>
Diffstat (limited to 'samples')
-rw-r--r--samples/server.c14
1 files changed, 4 insertions, 10 deletions
diff --git a/samples/server.c b/samples/server.c
index ad5ce34..82b22ff 100644
--- a/samples/server.c
+++ b/samples/server.c
@@ -330,16 +330,11 @@ migration_prepare_data(vfu_ctx_t *vfu_ctx, __u64 *offset, __u64 *size)
} else {
assert(false); /* FIXME fail gracefully */
}
-
- /*
- * Don't provide all migration data in one go in order to make it a bit
- * more interesting.
- */
- *size = MIN(server_data->migration.pending_bytes, server_data->migration.migr_data_len / 4);
+ *size = server_data->migration.pending_bytes;
return 0;
}
-static size_t
+static ssize_t
migration_read_data(vfu_ctx_t *vfu_ctx, void *buf, __u64 size, __u64 offset)
{
struct server_data *server_data = vfu_get_private(vfu_ctx);
@@ -390,7 +385,7 @@ migration_read_data(vfu_ctx_t *vfu_ctx, void *buf, __u64 size, __u64 offset)
return size;
}
-static size_t
+static ssize_t
migration_write_data(vfu_ctx_t *vfu_ctx, void *data, __u64 size, __u64 offset)
{
struct server_data *server_data = vfu_get_private(vfu_ctx);
@@ -430,8 +425,7 @@ migration_write_data(vfu_ctx_t *vfu_ctx, void *data, __u64 size, __u64 offset)
static int
-migration_data_written(UNUSED vfu_ctx_t *vfu_ctx, UNUSED __u64 count,
- UNUSED __u64 offset)
+migration_data_written(UNUSED vfu_ctx_t *vfu_ctx, UNUSED __u64 count)
{
/*
* We apply migration state directly in the migration_write_data callback,