[v2] vhost: fix passing destroyed device to destroy callback

Message ID 20190412083228.8371-1-i.maximets@samsung.com
State Accepted, archived
Delegated to: Maxime Coquelin
Headers show
Series
  • [v2] vhost: fix passing destroyed device to destroy callback
Related show

Checks

Context Check Description
ci/mellanox-Performance-Testing success Performance Testing PASS
ci/intel-Performance-Testing success Performance Testing PASS
ci/Intel-compilation success Compilation OK
ci/checkpatch success coding style OK

Commit Message

Ilya Maximets April 12, 2019, 8:32 a.m.
Application should be able to obtain information like 'ifname' from
the 'vid' passed to 'destroy_connection' callback. Currently, all the
API calls with passed 'vid' fails with 'device not found'.

Fixes: efba12a78ddf ("vhost: add user callbacks for socket open/close")
Cc: stable@dpdk.org

Signed-off-by: Ilya Maximets <i.maximets@samsung.com>
---

Version 2:
	* Fixed wrong order of 'destroy_device' and 'destroy_connection'.

 lib/librte_vhost/socket.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

Comments

Tiwei Bie April 15, 2019, 6:21 a.m. | #1
On Fri, Apr 12, 2019 at 11:32:28AM +0300, Ilya Maximets wrote:
> Application should be able to obtain information like 'ifname' from
> the 'vid' passed to 'destroy_connection' callback. Currently, all the
> API calls with passed 'vid' fails with 'device not found'.
> 
> Fixes: efba12a78ddf ("vhost: add user callbacks for socket open/close")
> Cc: stable@dpdk.org
> 
> Signed-off-by: Ilya Maximets <i.maximets@samsung.com>
> ---
> 
> Version 2:
> 	* Fixed wrong order of 'destroy_device' and 'destroy_connection'.
> 
>  lib/librte_vhost/socket.c | 8 +++++++-
>  1 file changed, 7 insertions(+), 1 deletion(-)

Reviewed-by: Tiwei Bie <tiwei.bie@intel.com>
Maxime Coquelin April 17, 2019, 7:54 a.m. | #2
On 4/12/19 10:32 AM, Ilya Maximets wrote:
> Application should be able to obtain information like 'ifname' from
> the 'vid' passed to 'destroy_connection' callback. Currently, all the
> API calls with passed 'vid' fails with 'device not found'.
> 
> Fixes: efba12a78ddf ("vhost: add user callbacks for socket open/close")
> Cc:stable@dpdk.org
> 
> Signed-off-by: Ilya Maximets<i.maximets@samsung.com>
> ---
> 
> Version 2:
> 	* Fixed wrong order of 'destroy_device' and 'destroy_connection'.
> 
>   lib/librte_vhost/socket.c | 8 +++++++-
>   1 file changed, 7 insertions(+), 1 deletion(-)


Applied to dpdk-next-virtio/master.

Thanks,
Maxime

Patch

diff --git a/lib/librte_vhost/socket.c b/lib/librte_vhost/socket.c
index 3da9de62c..af09dfa17 100644
--- a/lib/librte_vhost/socket.c
+++ b/lib/librte_vhost/socket.c
@@ -295,13 +295,19 @@  vhost_user_read_cb(int connfd, void *dat, int *remove)
 
 	ret = vhost_user_msg_handler(conn->vid, connfd);
 	if (ret < 0) {
+		struct virtio_net *dev = get_device(conn->vid);
+
 		close(connfd);
 		*remove = 1;
-		vhost_destroy_device(conn->vid);
+
+		if (dev)
+			vhost_destroy_device_notify(dev);
 
 		if (vsocket->notify_ops->destroy_connection)
 			vsocket->notify_ops->destroy_connection(conn->vid);
 
+		vhost_destroy_device(conn->vid);
+
 		pthread_mutex_lock(&vsocket->conn_mutex);
 		TAILQ_REMOVE(&vsocket->conn_list, conn, next);
 		pthread_mutex_unlock(&vsocket->conn_mutex);