From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga14.intel.com (mga14.intel.com [192.55.52.115]) by dpdk.org (Postfix) with ESMTP id C397D7CC4 for ; Wed, 21 Mar 2018 04:03:54 +0100 (CET) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga002.jf.intel.com ([10.7.209.21]) by fmsmga103.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 20 Mar 2018 20:03:54 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.48,338,1517904000"; d="scan'208";a="43883975" Received: from dpdk9.bj.intel.com ([172.16.182.183]) by orsmga002.jf.intel.com with ESMTP; 20 Mar 2018 20:03:52 -0700 From: zhiyong.yang@intel.com To: dev@dpdk.org Cc: jianfeng.tan@intel.com, zhihong.wang@intel.com, maxime.coquelin@redhat.com, thomas@monjalon.net, dong1.wang@intel.com, tiwei.bie@intel.com, Zhiyong Yang Date: Wed, 21 Mar 2018 11:03:43 +0800 Message-Id: <20180321030343.64399-5-zhiyong.yang@intel.com> X-Mailer: git-send-email 2.14.3 In-Reply-To: <20180321030343.64399-1-zhiyong.yang@intel.com> References: <20180214145330.4679-1-zhiyong.yang@intel.com> <20180321030343.64399-1-zhiyong.yang@intel.com> Subject: [dpdk-dev] [PATCH v3 4/4] net/vhost: add NULL pointer checking X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 21 Mar 2018 03:03:55 -0000 When vhost user PMD works in client mode to connect/reconnect virtio-user with 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. Release note is updated in the patch. Signed-off-by: Zhiyong Yang --- doc/guides/rel_notes/release_18_05.rst | 7 +++++++ drivers/net/vhost/rte_eth_vhost.c | 9 +++++++++ 2 files changed, 16 insertions(+) diff --git a/doc/guides/rel_notes/release_18_05.rst b/doc/guides/rel_notes/release_18_05.rst index 3923dc253..7b301f021 100644 --- a/doc/guides/rel_notes/release_18_05.rst +++ b/doc/guides/rel_notes/release_18_05.rst @@ -41,6 +41,13 @@ New Features Also, make sure to start the actual text at the margin. ========================================================= +* **Added support for virtio-user server mode.** + + In a container environment if the vhost-user backend restarts, there's no way + for it to reconnect to virtio-user. To address this, support for server mode + is added. In this mode the socket file is created by virtio-user, which the + backend then connects to. This means that if the backend restarts, it can + reconnect to virtio-user and continue communications. API Changes ----------- diff --git a/drivers/net/vhost/rte_eth_vhost.c b/drivers/net/vhost/rte_eth_vhost.c index 3aae01c39..2490bad0b 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) { + usleep(1); + } + for (i = 0; i < eth_dev->data->nb_rx_queues; i++) { vq = eth_dev->data->rx_queues[i]; if (vq == NULL) -- 2.14.3