vhost: don't start device before got valid descriptor

For each virt queue's kickfd and callfd, there are 2 invalid
status: VIRTIO_UNINITIALIZED_EVENTFD and VIRTIO_INVALID_EVENTFD.
Don't set the virt queue to ready status until got the valid
descriptor.

This is safe for polling mode drivers in Guest OS, the backend
vhost process will not post notification to interrupt vector for
PMD mode in Guest, but the interrupt vector still valid.

Change-Id: Icdf1e67f3c4e8da221843eb1383469ca1fba485c
Signed-off-by: Changpeng Liu <changpeng.liu@intel.com>
Reviewed-on: https://review.gerrithub.io/365327
Reviewed-by: Pawel Wodkowski <pawelx.wodkowski@intel.com>
Tested-by: SPDK Automated Test System <sys_sgsw@intel.com>
Reviewed-by: Daniel Verkamp <daniel.verkamp@intel.com>
This commit is contained in:
Changpeng Liu 2017-06-29 08:55:01 +08:00 committed by Daniel Verkamp
parent b3022e129d
commit c9a97addeb

View File

@ -654,7 +654,9 @@ vq_is_ready(struct vhost_virtqueue *vq)
{
return vq && vq->desc &&
vq->kickfd != VIRTIO_UNINITIALIZED_EVENTFD &&
vq->callfd != VIRTIO_UNINITIALIZED_EVENTFD;
vq->callfd != VIRTIO_UNINITIALIZED_EVENTFD &&
vq->kickfd != VIRTIO_INVALID_EVENTFD &&
vq->callfd != VIRTIO_INVALID_EVENTFD;
}
static int