Callback to get the estimated data length of the data that will be required to complete reading of the vfio device's internal state. It's mandatory for VFIO_DEVICE_FEATURE_MIGRATION migration support. The function pointer for this callback is specified via the 'migration_get_data_size' field of the 'vfio_migration_ops' structure which is stored with the VFIO device when the 'vfio_device' structure representing the mediated device is initialized. Signed-off-by: Anthony Krowiak --- drivers/s390/crypto/vfio_ap_migration.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/drivers/s390/crypto/vfio_ap_migration.c b/drivers/s390/crypto/vfio_ap_migration.c index 572db04c4ac1..83e1ce2c40c0 100644 --- a/drivers/s390/crypto/vfio_ap_migration.c +++ b/drivers/s390/crypto/vfio_ap_migration.c @@ -1283,7 +1283,18 @@ static int vfio_ap_get_state(struct vfio_device *vdev, static int vfio_ap_get_data_size(struct vfio_device *vdev, unsigned long *stop_copy_length) { - return -EOPNOTSUPP; + struct ap_matrix_mdev *matrix_mdev; + size_t qinfo_sz; + int num_queues; + + mutex_lock(&matrix_dev->mdevs_lock); + matrix_mdev = container_of(vdev, struct ap_matrix_mdev, vdev); + num_queues = vfio_ap_mdev_get_num_queues(&matrix_mdev->shadow_apcb); + qinfo_sz = num_queues * sizeof(struct vfio_ap_queue_info); + *stop_copy_length = qinfo_sz + sizeof(struct vfio_ap_config); + mutex_unlock(&matrix_dev->mdevs_lock); + + return 0; } static const struct vfio_migration_ops vfio_ap_migration_ops = { -- 2.53.0