From: jiangdongxu1 jiangdongxu1@huawei.com
virt inclusion category: feature bugzilla: https://gitee.com/openeuler/kernel/issues/I86ITO
----------------------------------------------------------------------
Introduce several interfaces to allow vdpa device save/load device status when guest machine resume and suspend.
The get_dev_buffer_size interface is used to get the buffer size of vdpa device status.
The get_dev_buffer interface is used to get the device buffer from vdpa device, and VMM can save it.
The set_dev_buffer interface is used to set the device status from userspace.
These operations are optional. If they are not implemented, return EOPNOTSUPP.
Signed-off-by: jiangdongxu1 jiangdongxu1@huawei.com --- include/linux/vdpa.h | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+)
diff --git a/include/linux/vdpa.h b/include/linux/vdpa.h index c628003104db..fbc74fa458b4 100644 --- a/include/linux/vdpa.h +++ b/include/linux/vdpa.h @@ -302,6 +302,19 @@ struct vdpa_map_file { * @log_sync Synchronize logging buffer from kernel space to * user space. (optional) * @vdev: vdpa device + * @get_dev_buffer_size Get device state buffer size. (optional) + * @vdev: vdpa device + * Return device status buffer size of vdpa device. + * @get_dev_buffer Get device state buffer. (optional) + * @vdev: vdpa device + * @offset: offset of dest for saving device state. + * @dest: userspace address for saving device state. + * @len: device state buffer length. + * @set_dev_buffer Set device state buffer. (opetional) + * @vdev: vdpa device + * @offset: offset of src addr of device state. + * @src: userspace addr of device state + * @len: device state buffer length. * @free: Free resources that belongs to vDPA (optional) * @vdev: vdpa device */ @@ -371,6 +384,13 @@ struct vdpa_config_ops { int (*set_log_size)(struct vdpa_device *vdev, uint64_t size); int (*log_sync)(struct vdpa_device *vdev);
+ /* device state ops */ + uint32_t (*get_dev_buffer_size)(struct vdpa_device *vdpa); + int (*get_dev_buffer)(struct vdpa_device *vdev, unsigned int offset, + void __user *dest, unsigned int len); + int (*set_dev_buffer)(struct vdpa_device *vdev, unsigned int offset, + const void __user *src, unsigned int len); + /* Free device resources */ void (*free)(struct vdpa_device *vdev); };