vhost: add config change slave msg support
Checks
Commit Message
This msg is used to notify qemu that should get the config of backend.
For example, vhost-user-blk uses this msg to notify guest os the
compacity of backend has changed.
Signed-off-by: Li Feng <fengli@smartx.com>
---
lib/librte_vhost/vhost_user.c | 31 +++++++++++++++++++++++++++++++
lib/librte_vhost/vhost_user.h | 2 ++
2 files changed, 33 insertions(+)
@@ -2840,6 +2840,37 @@ vhost_user_iotlb_miss(struct virtio_net *dev, uint64_t iova, uint8_t perm)
return 0;
}
+static int
+vhost_user_slave_config_change(struct virtio_net *dev)
+{
+ int ret;
+ struct VhostUserMsg msg = {
+ .request.slave = VHOST_USER_SLAVE_CONFIG_CHANGE_MSG,
+ .flags = VHOST_USER_VERSION,
+ .size = 0,
+ };
+
+ ret = send_vhost_message(dev->slave_req_fd, &msg);
+ if (ret < 0) {
+ RTE_LOG(ERR, VHOST_CONFIG,
+ "Failed to send config change (%d)\n",
+ ret);
+ return ret;
+ }
+
+ return 0;
+}
+
+int
+rte_vhost_user_slave_config_change(int vid)
+{
+ struct virtio_net *dev;
+ dev = get_device(vid);
+ if (!dev)
+ return -ENODEV;
+ return vhost_user_slave_config_change(dev);
+}
+
static int vhost_user_slave_set_vring_host_notifier(struct virtio_net *dev,
int index, int fd,
uint64_t offset,
@@ -62,6 +62,7 @@ typedef enum VhostUserRequest {
typedef enum VhostUserSlaveRequest {
VHOST_USER_SLAVE_NONE = 0,
VHOST_USER_SLAVE_IOTLB_MSG = 1,
+ VHOST_USER_SLAVE_CONFIG_CHANGE_MSG = 2,
VHOST_USER_SLAVE_VRING_HOST_NOTIFIER_MSG = 3,
VHOST_USER_SLAVE_MAX
} VhostUserSlaveRequest;
@@ -158,6 +159,7 @@ typedef struct VhostUserMsg {
/* vhost_user.c */
int vhost_user_msg_handler(int vid, int fd);
int vhost_user_iotlb_miss(struct virtio_net *dev, uint64_t iova, uint8_t perm);
+int rte_vhost_user_slave_config_change(int vid);
/* socket.c */
int read_fd_message(int sockfd, char *buf, int buflen, int *fds, int max_fds,