vhost: fix lock on device readiness notification

The vhost notifies the application of device readiness via
vhost_user_notify_queue_state(), but calling this function
is not protected by the lock. This patch is to make this
function call lock protected.

Fixes: d0fcc38f5f ("vhost: improve device readiness notifications")
Cc: stable@dpdk.org

Signed-off-by: Jiayu Hu <jiayu.hu@intel.com>
Reviewed-by: Maxime Coquelin <maxime.coquelin@redhat.com>
This commit is contained in:
Jiayu Hu 2021-07-19 11:00:45 -04:00 committed by Chenbo Xia
parent 92ed77dce6
commit 7f31d4ea05

View File

@ -2995,9 +2995,6 @@ vhost_user_msg_handler(int vid, int fd)
} }
} }
if (unlock_required)
vhost_user_unlock_all_queue_pairs(dev);
/* If message was not handled at this stage, treat it as an error */ /* If message was not handled at this stage, treat it as an error */
if (!handled) { if (!handled) {
VHOST_LOG_CONFIG(ERR, VHOST_LOG_CONFIG(ERR,
@ -3032,6 +3029,8 @@ vhost_user_msg_handler(int vid, int fd)
} }
} }
if (unlock_required)
vhost_user_unlock_all_queue_pairs(dev);
if (!virtio_is_ready(dev)) if (!virtio_is_ready(dev))
goto out; goto out;