[dpdk-dev,4/4] net/vhost: add memory checking to support client mode
Checks
Commit Message
When vhost user PMD works in client mode to connect/reconnect virtio
user in server mode, new thread sometimes may run to new_device before
queue_setup has been done, So have to wait until memory allocation
is done.
Signed-off-by: Zhiyong Yang <zhiyong.yang@intel.com>
---
drivers/net/vhost/rte_eth_vhost.c | 9 +++++++++
1 file changed, 9 insertions(+)
@@ -580,6 +580,15 @@ new_device(int vid)
eth_dev->data->numa_node = newnode;
#endif
+ /* The thread may run here before eth_dev->data->rx_queues or
+ * eth_dev->data->tx_queues have gotten valid memory, so have to
+ * wait until memory allocation is done.
+ */
+ while (!eth_dev->data->rx_queues ||
+ !eth_dev->data->tx_queues) {
+ ;
+ }
+
for (i = 0; i < eth_dev->data->nb_rx_queues; i++) {
vq = eth_dev->data->rx_queues[i];
if (vq == NULL)