From: Maxime Coquelin <maxime.coquelin@redhat.com>
To: dev@dpdk.org, tiwei.bie@intel.com, yliu@fridaylinux.org,
jfreimann@redhat.com
Cc: Maxime Coquelin <maxime.coquelin@redhat.com>
Subject: [dpdk-dev] [RFC 1/2] vhost-user: don't allocate new queue once device is running
Date: Fri, 12 Jan 2018 16:50:15 +0100 [thread overview]
Message-ID: <20180112155016.8990-2-maxime.coquelin@redhat.com> (raw)
In-Reply-To: <20180112155016.8990-1-maxime.coquelin@redhat.com>
Once the device is created, it is not possible to hot-add new
queues. If it happens, it could confuse the application, as
the new queue might not be initialized but nr_vring is
incremented.
Signed-off-by: Maxime Coquelin <maxime.coquelin@redhat.com>
---
lib/librte_vhost/vhost_user.c | 20 +++++++++++++++++---
1 file changed, 17 insertions(+), 3 deletions(-)
diff --git a/lib/librte_vhost/vhost_user.c b/lib/librte_vhost/vhost_user.c
index e54795a41..f94fd16cf 100644
--- a/lib/librte_vhost/vhost_user.c
+++ b/lib/librte_vhost/vhost_user.c
@@ -1220,13 +1220,23 @@ vhost_user_check_and_alloc_queue_pair(struct virtio_net *dev, VhostUserMsg *msg)
if (vring_idx >= VHOST_MAX_VRING) {
RTE_LOG(ERR, VHOST_CONFIG,
"invalid vring index: %u\n", vring_idx);
- return -1;
+ return -EINVAL;
}
if (dev->virtqueue[vring_idx])
return 0;
- return alloc_vring_queue(dev, vring_idx);
+ /* Queues cannot be added dynamically */
+ if (dev->flags & VIRTIO_DEV_RUNNING) {
+ RTE_LOG(DEBUG, VHOST_CONFIG,
+ "Cannot allocate new queue, device is running\n");
+ return -EPERM;
+ }
+
+ if (alloc_vring_queue(dev, vring_idx) < 0)
+ return -ENOMEM;
+
+ return 0;
}
int
@@ -1274,7 +1284,10 @@ vhost_user_msg_handler(int vid, int fd)
vhost_message_str[msg.request.master]);
ret = vhost_user_check_and_alloc_queue_pair(dev, &msg);
- if (ret < 0) {
+ if (ret == -EPERM) {
+ RTE_LOG(DEBUG, VHOST_CONFIG, "Skipping message\n");
+ goto out;
+ } else if (ret < 0) {
RTE_LOG(ERR, VHOST_CONFIG,
"failed to alloc queue\n");
return -1;
@@ -1383,6 +1396,7 @@ vhost_user_msg_handler(int vid, int fd)
}
+out:
if (msg.flags & VHOST_USER_NEED_REPLY) {
msg.payload.u64 = !!ret;
msg.size = sizeof(msg.payload.u64);
--
2.14.3
next prev parent reply other threads:[~2018-01-12 15:50 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-01-12 15:50 [dpdk-dev] [RFC 0/2] vhost-user: add VHOST_USER_SET_QUEUE_NUM support Maxime Coquelin
2018-01-12 15:50 ` Maxime Coquelin [this message]
2018-01-12 15:50 ` [dpdk-dev] [RFC 2/2] vhost-user: add support for VHOST_USER_SET_QUEUE_NUM 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=20180112155016.8990-2-maxime.coquelin@redhat.com \
--to=maxime.coquelin@redhat.com \
--cc=dev@dpdk.org \
--cc=jfreimann@redhat.com \
--cc=tiwei.bie@intel.com \
--cc=yliu@fridaylinux.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).