vhost: improve vDPA block device configure condition

To support multi-queue, configure device
after call fd of all queues are set.

Signed-off-by: Andy Pei <andy.pei@intel.com>
Signed-off-by: Huang Wei <wei.huang@intel.com>
Reviewed-by: Chenbo Xia <chenbo.xia@intel.com>
Reviewed-by: Maxime Coquelin <maxime.coquelin@redhat.com>
This commit is contained in:
Andy Pei 2022-10-19 16:41:24 +08:00 committed by Chenbo Xia
parent c20c5e9f88
commit 71151e7555

View File

@ -2972,6 +2972,7 @@ vhost_user_msg_handler(int vid, int fd)
bool handled;
uint32_t request;
uint32_t i;
uint16_t blk_call_fd;
dev = get_device(vid);
if (dev == NULL)
@ -3181,9 +3182,15 @@ vhost_user_msg_handler(int vid, int fd)
if (!vdpa_dev)
goto out;
if (vdpa_dev->type == RTE_VHOST_VDPA_DEVICE_TYPE_BLK
&& request != VHOST_USER_SET_VRING_CALL)
goto out;
if (vdpa_dev->type == RTE_VHOST_VDPA_DEVICE_TYPE_BLK) {
if (request == VHOST_USER_SET_VRING_CALL) {
blk_call_fd = ctx.msg.payload.u64 & VHOST_USER_VRING_IDX_MASK;
if (blk_call_fd != dev->nr_vring - 1)
goto out;
} else {
goto out;
}
}
if (!(dev->flags & VIRTIO_DEV_VDPA_CONFIGURED)) {
if (vdpa_dev->ops->dev_conf(dev->vid))