From: Tom Lonergan <tom.lonergan@nutanix.com>
To: mst@redhat.com
Cc: raphael.norwitz@nutanix.com, qemu-devel@nongnu.org,
yuanmh12@chinatelecom.cn, Tom Lonergan <tom.lonergan@nutanix.com>
Subject: [PATCH 1/2] vhost-user: Change one_time to per_device request
Date: Wed, 28 Jun 2023 16:39:26 +0000 [thread overview]
Message-ID: <20230628163927.108171-2-tom.lonergan@nutanix.com> (raw)
In-Reply-To: <20230628163927.108171-1-tom.lonergan@nutanix.com>
Some devices, like virtio-scsi, consist of one vhost_dev, while others, like
virtio-net, contain multiple vhost_devs. The QEMU vhost-user code has a
concept of one-time messages which is misleading. One-time messages are sent
once per operation on the device, not once for the lifetime of the device.
Therefore, as discussed in [1], vhost_user_one_time_request should be
renamed to vhost_user_per_device_request and the relevant comments updated
to match the real functionality.
[1] https://lore.kernel.org/qemu-devel/20230127083027-mutt-send-email-mst@kernel.org/
Signed-off-by: Tom Lonergan <tom.lonergan@nutanix.com>
---
hw/virtio/vhost-user.c | 18 ++++++++++++------
1 file changed, 12 insertions(+), 6 deletions(-)
diff --git a/hw/virtio/vhost-user.c b/hw/virtio/vhost-user.c
index c4e0cbd702..65d6299343 100644
--- a/hw/virtio/vhost-user.c
+++ b/hw/virtio/vhost-user.c
@@ -367,7 +367,7 @@ static int process_message_reply(struct vhost_dev *dev,
return msg_reply.payload.u64 ? -EIO : 0;
}
-static bool vhost_user_one_time_request(VhostUserRequest request)
+static bool vhost_user_per_device_request(VhostUserRequest request)
{
switch (request) {
case VHOST_USER_SET_OWNER:
@@ -392,11 +392,17 @@ static int vhost_user_write(struct vhost_dev *dev, VhostUserMsg *msg,
int ret, size = VHOST_USER_HDR_SIZE + msg->hdr.size;
/*
- * For non-vring specific requests, like VHOST_USER_SET_MEM_TABLE,
- * we just need send it once in the first time. For later such
- * request, we just ignore it.
+ * Some devices, like virtio-scsi, are implemented as a single vhost_dev,
+ * while others, like virtio-net, contain multiple vhost_devs. For
+ * operations such as configuring device memory mappings or issuing device
+ * resets, which affect the whole device instead of individual VQs,
+ * vhost-user messages should only be sent once.
+ *
+ * Devices with multiple vhost_devs are given an associated dev->vq_index
+ * so per_device requests are only sent if vq_index is 0.
*/
- if (vhost_user_one_time_request(msg->hdr.request) && dev->vq_index != 0) {
+ if (vhost_user_per_device_request(msg->hdr.request)
+ && dev->vq_index != 0) {
msg->hdr.flags &= ~VHOST_USER_NEED_REPLY_MASK;
return 0;
}
@@ -1256,7 +1262,7 @@ static int vhost_user_get_u64(struct vhost_dev *dev, int request, uint64_t *u64)
.hdr.flags = VHOST_USER_VERSION,
};
- if (vhost_user_one_time_request(request) && dev->vq_index != 0) {
+ if (vhost_user_per_device_request(request) && dev->vq_index != 0) {
return 0;
}
--
2.22.3
next prev parent reply other threads:[~2023-06-28 16:59 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-06-28 16:39 [PATCH 0/2] vhost user one time message fixes Tom Lonergan
2023-06-28 16:39 ` Tom Lonergan [this message]
2023-06-30 12:15 ` [PATCH 1/2] vhost-user: Change one_time to per_device request Raphael Norwitz
2023-06-28 16:39 ` [PATCH 2/2] vhost-user: Make RESET_DEVICE a per device message Tom Lonergan
2023-06-30 12:16 ` Raphael Norwitz
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=20230628163927.108171-2-tom.lonergan@nutanix.com \
--to=tom.lonergan@nutanix.com \
--cc=mst@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=raphael.norwitz@nutanix.com \
--cc=yuanmh12@chinatelecom.cn \
/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).