[PATCH 15/15] vhost: make sure each queue callfd is configured
Andy Pei
andy.pei at intel.com
Tue Jan 25 07:47:38 CET 2022
During the vhost data path building process, qemu will create a call fd at first,
and create another call fd in the end. The final call fd will be used to relay notify.
In the original code, after kick fd is set, dev_conf will set the first
call fd. Even though the actual call fd will set, the data path will not work correctly.
Signed-off-by: Andy Pei <andy.pei at intel.com>
---
lib/vhost/vhost_user.c | 15 +++++++++++++++
1 file changed, 15 insertions(+)
diff --git a/lib/vhost/vhost_user.c b/lib/vhost/vhost_user.c
index 5eb1dd6..0be879a 100644
--- a/lib/vhost/vhost_user.c
+++ b/lib/vhost/vhost_user.c
@@ -3137,12 +3137,27 @@ typedef int (*vhost_message_handler_t)(struct virtio_net **pdev,
if (!vdpa_dev)
goto out;
+ if (request != VHOST_USER_SET_VRING_CALL)
+ goto out;
+
if (!(dev->flags & VIRTIO_DEV_VDPA_CONFIGURED)) {
if (vdpa_dev->ops->dev_conf(dev->vid))
VHOST_LOG_CONFIG(ERR,
"Failed to configure vDPA device\n");
else
dev->flags |= VIRTIO_DEV_VDPA_CONFIGURED;
+ } else {
+ /**
+ ** when VIRTIO_DEV_VDPA_CONFIGURED already configured
+ ** close the device and config the device again,
+ ** make sure the call fd of each queue is configed correctly.
+ **/
+ if (vdpa_dev->ops->dev_close(dev->vid))
+ VHOST_LOG_CONFIG(ERR,
+ "Failed to close vDPA device\n");
+ if (vdpa_dev->ops->dev_conf(dev->vid))
+ VHOST_LOG_CONFIG(ERR,
+ "Failed to re-config vDPA device\n");
}
out:
--
1.8.3.1
More information about the dev
mailing list