From a1cd28c6f349c580b5566fe61a20b952f71c151a Mon Sep 17 00:00:00 2001 From: Changpeng Liu Date: Tue, 11 Oct 2022 15:15:25 +0800 Subject: [PATCH] lib/vhost: get negotiated features after SET_FEATURES message Feature negotiation is done after SET_FEATURES message, here we move it in this message context, so that we can use the negotiated features before starting the device. Change-Id: Ic6388dbcebd72bc5ef182e65798d34c07f6fc35c Signed-off-by: Changpeng Liu Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/14924 Community-CI: Mellanox Build Bot Reviewed-by: Ben Walker Reviewed-by: Jim Harris Tested-by: SPDK CI Jenkins --- lib/vhost/rte_vhost_user.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/lib/vhost/rte_vhost_user.c b/lib/vhost/rte_vhost_user.c index cde959ab4..70f88a9d7 100644 --- a/lib/vhost/rte_vhost_user.c +++ b/lib/vhost/rte_vhost_user.c @@ -1041,11 +1041,6 @@ start_device(int vid) goto out; } - if (vhost_get_negotiated_features(vid, &vsession->negotiated_features) != 0) { - SPDK_ERRLOG("vhost device %d: Failed to get negotiated driver features\n", vid); - goto out; - } - packed_ring = ((vsession->negotiated_features & (1ULL << VIRTIO_F_RING_PACKED)) != 0); vsession->max_queues = 0; @@ -1564,6 +1559,7 @@ extern_vhost_post_msg_handler(int vid, void *_msg) { struct vhost_user_msg *msg = _msg; struct spdk_vhost_session *vsession; + int rc; vsession = vhost_session_find_by_vid(vid); if (vsession == NULL) { @@ -1584,6 +1580,12 @@ extern_vhost_post_msg_handler(int vid, void *_msg) switch (msg->request) { case VHOST_USER_SET_FEATURES: + rc = vhost_get_negotiated_features(vid, &vsession->negotiated_features); + if (rc) { + SPDK_ERRLOG("vhost device %d: Failed to get negotiated driver features\n", vid); + return RTE_VHOST_MSG_RESULT_ERR; + } + /* rte_vhost requires all queues to be fully initialized in order * to start I/O processing. This behavior is not compliant with the * vhost-user specification and doesn't work with QEMU 2.12+, which