在 2022/8/24 17:04, Jason Wang 写道:
在 2022/8/24 12:57, Kangjie Xu 写道:
在 2022/8/24 12:05, Jason Wang 写道:
在 2022/8/16 09:06, Kangjie Xu 写道:
Update vhost_net_virtqueue_stop() for vhost-user scenario.
Let's explain why it is needed now or why it doesn't cause any issue
or it's a bug fix or not.
Thanks
This patch is to suppport vq reset for vhost-user.
We need this simply because the behavior of vhost_ops->get_vq_index()
is different in vhost-user and vhost-kernel.
vhost_user_get_vq_index(dev, idx) simply returns "idx".
vhost_kernel_get_vq_index(dev, idx) returns "idx - dev->vq_index".
Thanks
Let's add them in the change-log in the next version.
Sorry, i don't get what to be changed here, could you explain it?
But the question still, is this a bug fix (requires a Fixes tag)? If
not why do we need this now?
Thanks
Actually, it is not a bugfix, it is simply intended to support vhost-user.
Because vhost_ops->get_vq_index returns different values for
vhost-kernel and vhost-user.
To align vhost-kernel and vhost-user and reuse the following code,
vhost_dev_virtqueue_stop(&net->dev, vdev, idx);
we process the 'idx' here for vhost-user specifically.
Thanks.
Signed-off-by: Kangjie Xu <kangjie...@linux.alibaba.com>
Signed-off-by: Xuan Zhuo <xuanz...@linux.alibaba.com>
---
hw/net/vhost_net.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/hw/net/vhost_net.c b/hw/net/vhost_net.c
index 2ab67e875e..c0d408f3b4 100644
--- a/hw/net/vhost_net.c
+++ b/hw/net/vhost_net.c
@@ -533,6 +533,10 @@ void vhost_net_virtqueue_stop(VirtIODevice
*vdev, NetClientState *nc,
assert(r >= 0);
}
+ if (net->nc->info->type == NET_CLIENT_DRIVER_VHOST_USER) {
+ idx = idx - net->dev.vq_index;
+ }
+
vhost_dev_virtqueue_stop(&net->dev, vdev, idx);
}