Commit db73e999 authored by Thanos Makatos's avatar Thanos Makatos Committed by Tomasz Zawadzki
Browse files

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: default avatarThanos 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: default avatarSPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: default avatarChangpeng Liu <changpeng.liu@intel.com>
Reviewed-by: default avatarBen Walker <benjamin.walker@intel.com>
parent 310836b9
Loading
Loading
Loading
Loading
+27 −18
Original line number Diff line number Diff line
@@ -3802,33 +3802,42 @@ vfio_user_migration_prepare_data(vfu_ctx_t *vfu_ctx, uint64_t *offset, uint64_t
}

static ssize_t
vfio_user_migration_read_data(vfu_ctx_t *vfu_ctx, void *buf, uint64_t count, uint64_t offset)
{
	struct nvmf_vfio_user_endpoint *endpoint = vfu_get_private(vfu_ctx);
	struct nvmf_vfio_user_ctrlr *ctrlr = endpoint->ctrlr;
	struct vfio_user_migration_region *migr_reg = &ctrlr->migr_reg;

	memcpy(buf, endpoint->migr_data, count);
	migr_reg->pending_bytes = 0;

	return 0;
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)))
{
	SPDK_DEBUGLOG(nvmf_vfio, "%s: migration read data not supported\n",
		      endpoint_id(vfu_get_private(vfu_ctx)));
	errno = ENOTSUP;
	return -1;
}

static ssize_t
vfio_user_migration_write_data(vfu_ctx_t *vfu_ctx, void *buf, uint64_t count, uint64_t offset)
{
	struct nvmf_vfio_user_endpoint *endpoint = vfu_get_private(vfu_ctx);

	memcpy(endpoint->migr_data, buf, count);

	return 0;
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)))
{
	SPDK_DEBUGLOG(nvmf_vfio, "%s: migration write data not supported\n",
		      endpoint_id(vfu_get_private(vfu_ctx)));
	errno = ENOTSUP;
	return -1;
}

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);

	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;
}