aboutsummaryrefslogtreecommitdiff
path: root/hw/net/vhost_net.c
diff options
context:
space:
mode:
authorJason Wang <jasowang@redhat.com>2021-10-20 12:55:58 +0800
committerMichael S. Tsirkin <mst@redhat.com>2021-10-20 04:44:05 -0400
commit049eb15b5fc9c54ae76254a196b695000127da7a (patch)
treef0ad6a3a82302ddbe400ecd68aac45c5168bfdd3 /hw/net/vhost_net.c
parent441537f1ce0153978b4c9ee1cc4d4152147aa16f (diff)
vhost: record the last virtqueue index for the virtio device
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> Message-Id: <20211020045600.16082-9-jasowang@redhat.com> Reviewed-by: Michael S. Tsirkin <mst@redhat.com> Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Diffstat (limited to 'hw/net/vhost_net.c')
-rw-r--r--hw/net/vhost_net.c12
1 files changed, 9 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