mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-07 17:53:56 -06:00
vhost-user: add new vhost user messages to support virtio config space
Add VHOST_USER_GET_CONFIG/VHOST_USER_SET_CONFIG messages which can be used for live migration of vhost user devices, also vhost user devices can benefit from the messages to get/set virtio config space from/to the I/O target. For the purpose to support virtio config space change, VHOST_USER_SLAVE_CONFIG_CHANGE_MSG message is added as the event notifier in case virtio config space change in the slave I/O target. Signed-off-by: Changpeng Liu <changpeng.liu@intel.com> Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com> Reviewed-by: Michael S. Tsirkin <mst@redhat.com> Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
This commit is contained in:
parent
1bcf209154
commit
4c3e257b5e
5 changed files with 232 additions and 0 deletions
|
@ -20,6 +20,11 @@ typedef enum VhostBackendType {
|
|||
VHOST_BACKEND_TYPE_MAX = 3,
|
||||
} VhostBackendType;
|
||||
|
||||
typedef enum VhostSetConfigType {
|
||||
VHOST_SET_CONFIG_TYPE_MASTER = 0,
|
||||
VHOST_SET_CONFIG_TYPE_MIGRATION = 1,
|
||||
} VhostSetConfigType;
|
||||
|
||||
struct vhost_dev;
|
||||
struct vhost_log;
|
||||
struct vhost_memory;
|
||||
|
@ -84,6 +89,11 @@ typedef void (*vhost_set_iotlb_callback_op)(struct vhost_dev *dev,
|
|||
int enabled);
|
||||
typedef int (*vhost_send_device_iotlb_msg_op)(struct vhost_dev *dev,
|
||||
struct vhost_iotlb_msg *imsg);
|
||||
typedef int (*vhost_set_config_op)(struct vhost_dev *dev, const uint8_t *data,
|
||||
uint32_t offset, uint32_t size,
|
||||
uint32_t flags);
|
||||
typedef int (*vhost_get_config_op)(struct vhost_dev *dev, uint8_t *config,
|
||||
uint32_t config_len);
|
||||
|
||||
typedef struct VhostOps {
|
||||
VhostBackendType backend_type;
|
||||
|
@ -118,6 +128,8 @@ typedef struct VhostOps {
|
|||
vhost_vsock_set_running_op vhost_vsock_set_running;
|
||||
vhost_set_iotlb_callback_op vhost_set_iotlb_callback;
|
||||
vhost_send_device_iotlb_msg_op vhost_send_device_iotlb_msg;
|
||||
vhost_get_config_op vhost_get_config;
|
||||
vhost_set_config_op vhost_set_config;
|
||||
} VhostOps;
|
||||
|
||||
extern const VhostOps user_ops;
|
||||
|
|
|
@ -46,6 +46,12 @@ struct vhost_iommu {
|
|||
QLIST_ENTRY(vhost_iommu) iommu_next;
|
||||
};
|
||||
|
||||
typedef struct VhostDevConfigOps {
|
||||
/* Vhost device config space changed callback
|
||||
*/
|
||||
int (*vhost_dev_config_notifier)(struct vhost_dev *dev);
|
||||
} VhostDevConfigOps;
|
||||
|
||||
struct vhost_memory;
|
||||
struct vhost_dev {
|
||||
VirtIODevice *vdev;
|
||||
|
@ -76,6 +82,7 @@ struct vhost_dev {
|
|||
QLIST_ENTRY(vhost_dev) entry;
|
||||
QLIST_HEAD(, vhost_iommu) iommu_list;
|
||||
IOMMUNotifier n;
|
||||
const VhostDevConfigOps *config_ops;
|
||||
};
|
||||
|
||||
int vhost_dev_init(struct vhost_dev *hdev, void *opaque,
|
||||
|
@ -106,4 +113,12 @@ int vhost_net_set_backend(struct vhost_dev *hdev,
|
|||
struct vhost_vring_file *file);
|
||||
|
||||
int vhost_device_iotlb_miss(struct vhost_dev *dev, uint64_t iova, int write);
|
||||
int vhost_dev_get_config(struct vhost_dev *dev, uint8_t *config,
|
||||
uint32_t config_len);
|
||||
int vhost_dev_set_config(struct vhost_dev *dev, const uint8_t *data,
|
||||
uint32_t offset, uint32_t size, uint32_t flags);
|
||||
/* notifier callback in case vhost device config space changed
|
||||
*/
|
||||
void vhost_dev_set_config_notifier(struct vhost_dev *dev,
|
||||
const VhostDevConfigOps *ops);
|
||||
#endif
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue