[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH V3 08/10] vhost: record the last virtqueue index for the virtio d
From: |
Jason Wang |
Subject: |
[PATCH V3 08/10] vhost: record the last virtqueue index for the virtio device |
Date: |
Tue, 7 Sep 2021 17:03:20 +0800 |
This patch introduces a new field in the vhost_dev structure to record
the last virtqueue index for the virtio device. This will be useful
for the vhost backends with 1:N model to start or stop the device
after all the vhost_dev structures were started or stopped.
Signed-off-by: Jason Wang <jasowang@redhat.com>
---
hw/net/vhost_net.c | 12 +++++++++---
include/hw/virtio/vhost.h | 2 ++
2 files changed, 11 insertions(+), 3 deletions(-)
diff --git a/hw/net/vhost_net.c b/hw/net/vhost_net.c
index 2b594b4642..3aabab06ea 100644
--- a/hw/net/vhost_net.c
+++ b/hw/net/vhost_net.c
@@ -231,9 +231,11 @@ fail:
return NULL;
}
-static void vhost_net_set_vq_index(struct vhost_net *net, int vq_index)
+static void vhost_net_set_vq_index(struct vhost_net *net, int vq_index,
+ int last_index)
{
net->dev.vq_index = vq_index;
+ net->dev.last_index = last_index;
}
static int vhost_net_start_one(struct vhost_net *net,
@@ -324,9 +326,13 @@ int vhost_net_start(VirtIODevice *dev, NetClientState *ncs,
VirtIONet *n = VIRTIO_NET(dev);
int nvhosts = data_queue_pairs + cvq;
struct vhost_net *net;
- int r, e, i;
+ int r, e, i, last_index = data_qps * 2;
NetClientState *peer;
+ if (!cvq) {
+ last_index -= 1;
+ }
+
if (!k->set_guest_notifiers) {
error_report("binding does not support guest notifiers");
return -ENOSYS;
@@ -341,7 +347,7 @@ int vhost_net_start(VirtIODevice *dev, NetClientState *ncs,
}
net = get_vhost_net(peer);
- vhost_net_set_vq_index(net, i * 2);
+ vhost_net_set_vq_index(net, i * 2, last_index);
/* Suppress the masking guest notifiers on vhost user
* because vhost user doesn't interrupt masking/unmasking
diff --git a/include/hw/virtio/vhost.h b/include/hw/virtio/vhost.h
index 1a9fc65089..3fa0b554ef 100644
--- a/include/hw/virtio/vhost.h
+++ b/include/hw/virtio/vhost.h
@@ -74,6 +74,8 @@ struct vhost_dev {
unsigned int nvqs;
/* the first virtqueue which would be used by this vhost dev */
int vq_index;
+ /* the last vq index for the virtio device (not vhost) */
+ int last_index;
/* if non-zero, minimum required value for max_queues */
int num_queues;
uint64_t features;
--
2.25.1
- [PATCH V3 02/10] vhost-vdpa: classify one time request, (continued)
- [PATCH V3 02/10] vhost-vdpa: classify one time request, Jason Wang, 2021/09/07
- [PATCH V3 03/10] vhost-vdpa: prepare for the multiqueue support, Jason Wang, 2021/09/07
- [PATCH V3 04/10] vhost-vdpa: let net_vhost_vdpa_init() returns NetClientState *, Jason Wang, 2021/09/07
- [PATCH V3 05/10] net: introduce control client, Jason Wang, 2021/09/07
- [PATCH V3 06/10] vhost-net: control virtqueue support, Jason Wang, 2021/09/07
- [PATCH V3 07/10] virtio-net: use "queue_pairs" instead of "queues" when possible, Jason Wang, 2021/09/07
- [PATCH V3 08/10] vhost: record the last virtqueue index for the virtio device,
Jason Wang <=
- [PATCH V3 09/10] virtio-net: vhost control virtqueue support, Jason Wang, 2021/09/07
- [PATCH V3 10/10] vhost-vdpa: multiqueue support, Jason Wang, 2021/09/07
- RE: [PATCH V3 00/10] vhost-vDPA multiqueue, Zhang, Chen, 2021/09/09
- Re: [PATCH V3 00/10] vhost-vDPA multiqueue, Jason Wang, 2021/09/29