From: Maxime Coquelin <maxime.coquelin@redhat.com>
To: dev@dpdk.org, changpeng.liu@intel.com, tiwei.bie@intel.com,
i.maximets@samsung.com
Cc: Maxime Coquelin <maxime.coquelin@redhat.com>
Subject: [dpdk-dev] [RFC 2/2] vhost: support vhost-user request only handled by external backend
Date: Wed, 27 Feb 2019 11:02:35 +0100 [thread overview]
Message-ID: <20190227100235.14514-3-maxime.coquelin@redhat.com> (raw)
In-Reply-To: <20190227100235.14514-1-maxime.coquelin@redhat.com>
External backends may have specific requests to handle, and so
we don't want the vhost-user lib to handle these requests as
errors.
This patch also catch the case where a request is neither handled
by the external backend nor by the vhost library.
Signed-off-by: Maxime Coquelin <maxime.coquelin@redhat.com>
---
lib/librte_vhost/vhost_user.c | 28 +++++++++++++++-------------
1 file changed, 15 insertions(+), 13 deletions(-)
diff --git a/lib/librte_vhost/vhost_user.c b/lib/librte_vhost/vhost_user.c
index 36c0c676d..bae5ef1cc 100644
--- a/lib/librte_vhost/vhost_user.c
+++ b/lib/librte_vhost/vhost_user.c
@@ -1924,27 +1924,29 @@ vhost_user_msg_handler(int vid, int fd)
}
ret = read_vhost_message(fd, &msg);
- if (ret <= 0 || msg.request.master >= VHOST_USER_MAX) {
+ if (ret <= 0) {
if (ret < 0)
RTE_LOG(ERR, VHOST_CONFIG,
"vhost read message failed\n");
- else if (ret == 0)
+ else
RTE_LOG(INFO, VHOST_CONFIG,
"vhost peer closed\n");
- else
- RTE_LOG(ERR, VHOST_CONFIG,
- "vhost read incorrect message\n");
return -1;
}
ret = 0;
- if (msg.request.master != VHOST_USER_IOTLB_MSG)
- RTE_LOG(INFO, VHOST_CONFIG, "read message %s\n",
- vhost_message_str[msg.request.master]);
- else
- RTE_LOG(DEBUG, VHOST_CONFIG, "read message %s\n",
- vhost_message_str[msg.request.master]);
+ request = msg.request.master;
+ if (request < VHOST_USER_MAX && vhost_message_str[req]) {
+ if (request != VHOST_USER_IOTLB_MSG)
+ RTE_LOG(INFO, VHOST_CONFIG, "read message %s\n",
+ vhost_message_str[request]);
+ else if (
+ RTE_LOG(DEBUG, VHOST_CONFIG, "read message %s\n",
+ vhost_message_str[request]);
+ } else {
+ RTE_LOG(INFO, VHOST_CONFIG, "External request %d\n", request);
+ }
ret = vhost_user_check_and_alloc_queue_pair(dev, &msg);
if (ret < 0) {
@@ -1960,7 +1962,7 @@ vhost_user_msg_handler(int vid, int fd)
* inactive, so it is safe. Otherwise taking the access_lock
* would cause a dead lock.
*/
- switch (msg.request.master) {
+ switch (request) {
case VHOST_USER_SET_FEATURES:
case VHOST_USER_SET_PROTOCOL_FEATURES:
case VHOST_USER_SET_OWNER:
@@ -1985,6 +1987,7 @@ vhost_user_msg_handler(int vid, int fd)
}
+ ret = RTE_VHOST_MSG_RESULT_ERR;
if (dev->extern_ops.pre_msg_handle) {
ret = (*dev->extern_ops.pre_msg_handle)(dev->vid,
(void *)&msg, &skip_master);
@@ -1997,7 +2000,6 @@ vhost_user_msg_handler(int vid, int fd)
goto skip_to_post_handle;
}
- request = msg.request.master;
if (request > VHOST_USER_NONE && request < VHOST_USER_MAX) {
if (!vhost_message_handlers[request])
goto skip_to_post_handle;
--
2.20.1
next prev parent reply other threads:[~2019-02-27 10:02 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-02-27 10:02 [dpdk-dev] [RFC 0/2] vhost: Support external backend only vhost-user requests Maxime Coquelin
2019-02-27 10:02 ` [dpdk-dev] [RFC 1/2] vhost: add API to set protocol features flags Maxime Coquelin
2019-02-27 10:02 ` Maxime Coquelin [this message]
2019-02-27 13:15 ` [dpdk-dev] [RFC 2/2] vhost: support vhost-user request only handled by external backend Ilya Maximets
2019-02-28 8:46 ` Maxime Coquelin
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=20190227100235.14514-3-maxime.coquelin@redhat.com \
--to=maxime.coquelin@redhat.com \
--cc=changpeng.liu@intel.com \
--cc=dev@dpdk.org \
--cc=i.maximets@samsung.com \
--cc=tiwei.bie@intel.com \
/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).