From mboxrd@z Thu Jan 1 00:00:00 1970 From: Zhiyong Yang Subject: [PATCH 4/4] net/vhost: add memory checking to support client mode Date: Wed, 14 Feb 2018 22:53:30 +0800 Message-ID: <20180214145330.4679-5-zhiyong.yang@intel.com> References: <20180214145330.4679-1-zhiyong.yang@intel.com> Cc: dong1.wang@intel.com, Zhiyong Yang To: dev@dpdk.org, yliu@fridaylinux.org, maxime.coquelin@redhat.com, jianfeng.tan@intel.com, tiwei.bie@intel.com, zhihong.wang@intel.com Return-path: Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by dpdk.org (Postfix) with ESMTP id 7A9E21B360 for ; Wed, 14 Feb 2018 15:53:42 +0100 (CET) In-Reply-To: <20180214145330.4679-1-zhiyong.yang@intel.com> List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" 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 --- drivers/net/vhost/rte_eth_vhost.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/drivers/net/vhost/rte_eth_vhost.c b/drivers/net/vhost/rte_eth_vhost.c index 3aae01c39..cd67bc7c5 100644 --- a/drivers/net/vhost/rte_eth_vhost.c +++ b/drivers/net/vhost/rte_eth_vhost.c @@ -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) -- 2.13.3