In order to avoid breaking Vhost-user live-migration, we want the
rte_vhost_driver_set_max_queue_num API to only be effective with
VDUSE.

Furthermore, this API is only really needed for VDUSE where the
device number of queues is defined by the backend. For Vhost-user,
this is defined by the frontend (e.g. QEMU), so the advantages of
restricting more the maximum number of queue pairs is limited to
a small memory gain (a handful of pointers).

Fixes: 4aa1f88ac13d ("vhost: add API to set max queue pairs")
Cc: sta...@dpdk.org

Reported-by: Yu Jiang <yux.ji...@intel.com>
Signed-off-by: Maxime Coquelin <maxime.coque...@redhat.com>
---
 lib/vhost/socket.c | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/lib/vhost/socket.c b/lib/vhost/socket.c
index a75728a2e4..d29d15494c 100644
--- a/lib/vhost/socket.c
+++ b/lib/vhost/socket.c
@@ -860,6 +860,18 @@ rte_vhost_driver_set_max_queue_num(const char *path, 
uint32_t max_queue_pairs)
                goto unlock_exit;
        }
 
+       /*
+        * This is only useful for VDUSE for which number of virtqueues is set
+        * by the backend. For Vhost-user, the number of virtqueues is defined
+        * by the frontend.
+        */
+       if (!vsocket->is_vduse) {
+               VHOST_CONFIG_LOG(path, DEBUG,
+                               "Keeping %u max queue pairs for Vhost-user 
backend",
+                               VHOST_MAX_QUEUE_PAIRS);
+               goto unlock_exit;
+       }
+
        vsocket->max_queue_pairs = max_queue_pairs;
 
 unlock_exit:
-- 
2.46.1

Reply via email to