From: Linhaifeng <haifeng....@huawei.com> If slave's version bigger than 0x5 we will wait for reply.
Signed-off-by: Linhaifeng <haifeng....@huawei.com> --- hw/virtio/vhost-user.c | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/hw/virtio/vhost-user.c b/hw/virtio/vhost-user.c index d56115a..fdfd14b 100644 --- a/hw/virtio/vhost-user.c +++ b/hw/virtio/vhost-user.c @@ -82,8 +82,15 @@ static VhostUserMsg m __attribute__ ((unused)); /* The version of the protocol we support. * Slaves' version should maller than VHOST_USER_VERSION. */ +#define VHOST_USER_BASE (0x5) #define VHOST_USER_VERSION (0x6) +#define VHOST_NEED_REPLY \ +{ \ + if (slave_version > VHOST_USER_BASE) \ + need_reply = 1; \ +} + static bool ioeventfd_enabled(void) { return kvm_enabled() && kvm_eventfds_enabled(); @@ -207,6 +214,8 @@ static int vhost_user_call(struct vhost_dev *dev, unsigned long int request, case VHOST_SET_LOG_BASE: msg.u64 = *((__u64 *) arg); msg.size = sizeof(m.u64); + + VHOST_NEED_REPLY; break; case VHOST_SET_OWNER: @@ -244,16 +253,21 @@ static int vhost_user_call(struct vhost_dev *dev, unsigned long int request, msg.size += sizeof(m.memory.padding); msg.size += fd_num * sizeof(VhostUserMemoryRegion); + VHOST_NEED_REPLY; break; case VHOST_SET_LOG_FD: fds[fd_num++] = *((int *) arg); + + VHOST_NEED_REPLY; break; case VHOST_SET_VRING_NUM: case VHOST_SET_VRING_BASE: memcpy(&msg.state, arg, sizeof(struct vhost_vring_state)); msg.size = sizeof(m.state); + + VHOST_NEED_REPLY; break; case VHOST_GET_VRING_BASE: @@ -265,6 +279,8 @@ static int vhost_user_call(struct vhost_dev *dev, unsigned long int request, case VHOST_SET_VRING_ADDR: memcpy(&msg.addr, arg, sizeof(struct vhost_vring_addr)); msg.size = sizeof(m.addr); + + VHOST_NEED_REPLY; break; case VHOST_SET_VRING_KICK: @@ -278,6 +294,8 @@ static int vhost_user_call(struct vhost_dev *dev, unsigned long int request, } else { msg.u64 |= VHOST_USER_VRING_NOFD_MASK; } + + VHOST_NEED_REPLY; break; default: error_report("vhost-user trying to send unhandled ioctl\n"); @@ -315,6 +333,28 @@ static int vhost_user_call(struct vhost_dev *dev, unsigned long int request, } memcpy(arg, &msg.state, sizeof(struct vhost_vring_state)); break; + case VHOST_USER_SET_FEATURES: + case VHOST_USER_SET_LOG_BASE: + case VHOST_USER_SET_OWNER: + case VHOST_USER_RESET_OWNER: + case VHOST_USER_SET_MEM_TABLE: + case VHOST_USER_SET_LOG_FD: + case VHOST_USER_SET_VRING_NUM: + case VHOST_USER_SET_VRING_BASE: + case VHOST_USER_SET_VRING_ADDR: + case VHOST_USER_SET_VRING_KICK: + case VHOST_USER_SET_VRING_CALL: + case VHOST_USER_SET_VRING_ERR: + if (msg.size != sizeof(m.u64)) { + error_report("Received bad msg size."); + return -1; + } else { + if (m.u64) { + error_report("Failed to handle request %d.", msg_request); + return -1; + } + } + break; default: error_report("Received unexpected msg type.\n"); return -1; -- 1.7.12.4