[dpdk-dev,RFC,3/4] vhost: get all callfd before setting datapath

Message ID 1514570702-154906-4-git-send-email-xiao.w.wang@intel.com (mailing list archive)
State Superseded, archived
Delegated to: Maxime Coquelin
Headers

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/Intel-compilation fail apply patch file failure

Commit Message

Xiao Wang Dec. 29, 2017, 6:05 p.m. UTC
  vDPA device driver will need callfd to setup device VFIO interrupt.
Looking at QEMU vhost message sequence, the real callfd comes after
the other vring messages and just before SET_VRING_ENABLE.

This patch is to make sure we configure device only when all the
guest information is in hand.

Note: virtio-user's vhost message sequence is slightly different from
QEMU, it has no SET_VRING_ENABLE in the ending. So this patch is not
applicable to virtio-user. We could align virtio-user's message
sequence to QEMU in future to address this issue.

Signed-off-by: Xiao Wang <xiao.w.wang@intel.com>
---
 lib/librte_vhost/vhost_user.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
  

Patch

diff --git a/lib/librte_vhost/vhost_user.c b/lib/librte_vhost/vhost_user.c
index 51e6443..65d52bd 100644
--- a/lib/librte_vhost/vhost_user.c
+++ b/lib/librte_vhost/vhost_user.c
@@ -1404,7 +1404,9 @@ 
 		send_vhost_reply(fd, &msg);
 	}
 
-	if (!(dev->flags & VIRTIO_DEV_RUNNING) && virtio_is_ready(dev)) {
+	if (msg.request.master == VHOST_USER_SET_VRING_ENABLE &&
+			!(dev->flags & VIRTIO_DEV_RUNNING) &&
+			virtio_is_ready(dev)) {
 		dev->flags |= VIRTIO_DEV_READY;
 
 		if (!(dev->flags & VIRTIO_DEV_RUNNING)) {