nvmf/vfio-user: migration: don't ignore unsupported ranges

The read_data, write_data, and data_written migration callbacks assume
that the migration data are accessed in one go. Until this is fixed,
with this patch we ensure we don't ignore unsupported ranges.

Change-Id: I640415858b8c374ffc9e487cd20f5130e0be9305
Signed-off-by: Thanos Makatos <thanos.makatos@nutanix.com>
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/11717
Community-CI: Broadcom CI <spdk-ci.pdl@broadcom.com>
Community-CI: Mellanox Build Bot
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Changpeng Liu <changpeng.liu@intel.com>
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
This commit is contained in:
Thanos Makatos 2022-02-23 09:49:03 +00:00 committed by Tomasz Zawadzki
parent 310836b9af
commit db73e999e9

View File

@ -3802,33 +3802,42 @@ vfio_user_migration_prepare_data(vfu_ctx_t *vfu_ctx, uint64_t *offset, uint64_t
} }
static ssize_t static ssize_t
vfio_user_migration_read_data(vfu_ctx_t *vfu_ctx, void *buf, uint64_t count, uint64_t offset) vfio_user_migration_read_data(vfu_ctx_t *vfu_ctx __attribute__((unused)),
void *buf __attribute__((unused)),
uint64_t count __attribute__((unused)),
uint64_t offset __attribute__((unused)))
{ {
struct nvmf_vfio_user_endpoint *endpoint = vfu_get_private(vfu_ctx); SPDK_DEBUGLOG(nvmf_vfio, "%s: migration read data not supported\n",
struct nvmf_vfio_user_ctrlr *ctrlr = endpoint->ctrlr; endpoint_id(vfu_get_private(vfu_ctx)));
struct vfio_user_migration_region *migr_reg = &ctrlr->migr_reg; errno = ENOTSUP;
return -1;
memcpy(buf, endpoint->migr_data, count);
migr_reg->pending_bytes = 0;
return 0;
} }
static ssize_t static ssize_t
vfio_user_migration_write_data(vfu_ctx_t *vfu_ctx, void *buf, uint64_t count, uint64_t offset) vfio_user_migration_write_data(vfu_ctx_t *vfu_ctx __attribute__((unused)),
void *buf __attribute__((unused)),
uint64_t count __attribute__((unused)),
uint64_t offset __attribute__((unused)))
{ {
struct nvmf_vfio_user_endpoint *endpoint = vfu_get_private(vfu_ctx); SPDK_DEBUGLOG(nvmf_vfio, "%s: migration write data not supported\n",
endpoint_id(vfu_get_private(vfu_ctx)));
memcpy(endpoint->migr_data, buf, count); errno = ENOTSUP;
return -1;
return 0;
} }
static int static int
vfio_user_migration_data_written(vfu_ctx_t *vfu_ctx, uint64_t count) vfio_user_migration_data_written(vfu_ctx_t *vfu_ctx __attribute__((unused)),
uint64_t count)
{ {
SPDK_DEBUGLOG(nvmf_vfio, "write 0x%"PRIx64"\n", (uint64_t)count); SPDK_DEBUGLOG(nvmf_vfio, "write 0x%"PRIx64"\n", (uint64_t)count);
if (count != vfio_user_migr_data_len()) {
SPDK_DEBUGLOG(nvmf_vfio, "%s bad count %#lx\n",
endpoint_id(vfu_get_private(vfu_ctx)), count);
errno = EINVAL;
return -1;
}
return 0; return 0;
} }