From: linhaifeng <haifeng.lin@huawei.com>
To: qemu-devel@nongnu.org
Cc: mst@redhat.com
Subject: [Qemu-devel] [PATCH v1 3/3] vhost-user:add reply for other messages
Date: Fri, 13 Feb 2015 20:00:31 +0800 [thread overview]
Message-ID: <1423828831-12152-4-git-send-email-haifeng.lin@huawei.com> (raw)
In-Reply-To: <1423828831-12152-1-git-send-email-haifeng.lin@huawei.com>
From: Linhaifeng <haifeng.lin@huawei.com>
If slave's version bigger than 0x5 we will wait for reply.
Signed-off-by: Linhaifeng <haifeng.lin@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
prev parent reply other threads:[~2015-02-13 12:01 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-02-13 12:00 [Qemu-devel] [PATCH v1 0/3] vhost-user: support safe protocol linhaifeng
2015-02-13 12:00 ` [Qemu-devel] [PATCH v1 1/3] vhost-user: add reply let the portocol more safe linhaifeng
2015-02-13 12:00 ` [Qemu-devel] [PATCH v1 2/3] vhost-user:update the version to 0x6 linhaifeng
2015-02-13 12:00 ` linhaifeng [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1423828831-12152-4-git-send-email-haifeng.lin@huawei.com \
--to=haifeng.lin@huawei.com \
--cc=mst@redhat.com \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).