Description: backport of dpdk 16.07 fix for LP: #1570466

Backported from this discussion
http://dpdk.org/dev/patchwork/patch/12103/
Not accepted yet, but likely to be accepted in some form once tested and
confirmed.

new fix also relies on a lot of new code, vhost_destroy_device looks totally
different from the former destroy_device.
History on todays function content:
  4796ad63 - original code moved from examples to lib
  a90ca1a1 - this replaces ops->destroy_device with vhost_destroy_device
  71dc571e - simple check against null pointers
  45ca9c6f - this changed the code from linked list to arrays
    New code cleans with:
      notify_ops->destroy_device (callback into the parent)
      cleanup_device was existing before even in 2.2 code
      free_device as well existing before even in 2.2 code
    Old code cleans with:
      notify_ops->destroy_device - still there
      rm_config_ll_entry -> eventually calls cleanup_device and free_device
        (just in the more complex linked list way)
So the only adaption for backporting needed is to replace vhost_destroy_device
with ops->destroy_device(ctx)

Also along the discussion vserver-fh is now initialized with -1 to avoid
accidentially deleting the first connected port if we delete another not yet
connected port.

Forwarded: yes (based on an upstream discussion)
Author: Christian Ehrhardt <christian.ehrhardt@canonical.com>
Last-Update: 2016-04-19

Index: dpdk/lib/librte_vhost/vhost_user/vhost-net-user.c
===================================================================
--- dpdk.orig/lib/librte_vhost/vhost_user/vhost-net-user.c
+++ dpdk/lib/librte_vhost/vhost_user/vhost-net-user.c
@@ -310,6 +310,7 @@ vserver_new_vq_conn(int fd, void *dat, _
 	}
 
 	vdev_ctx.fh = fh;
+	vserver->fh = fh;
 	size = strnlen(vserver->path, PATH_MAX);
 	ops->set_ifname(vdev_ctx, vserver->path,
 		size);
@@ -482,6 +483,7 @@ rte_vhost_driver_register(const char *pa
 	}
 
 	vserver->path = strdup(path);
+	vserver->fh = -1;
 
 	ret = fdset_add(&g_vhost_server.fdset, vserver->listenfd,
 		vserver_new_vq_conn, NULL, vserver);
@@ -516,6 +518,11 @@ rte_vhost_driver_unregister(const char *
 
 	for (i = 0; i < g_vhost_server.vserver_cnt; i++) {
 		if (!strcmp(g_vhost_server.server[i]->path, path)) {
+			struct vhost_device_ctx ctx;
+
+			ctx.fh = g_vhost_server.server[i]->fh;
+			ops->destroy_device(ctx);
+
 			fdset_del(&g_vhost_server.fdset,
 				g_vhost_server.server[i]->listenfd);
 
Index: dpdk/lib/librte_vhost/vhost_user/vhost-net-user.h
===================================================================
--- dpdk.orig/lib/librte_vhost/vhost_user/vhost-net-user.h
+++ dpdk/lib/librte_vhost/vhost_user/vhost-net-user.h
@@ -43,6 +43,7 @@
 struct vhost_server {
 	char *path; /**< The path the uds is bind to. */
 	int listenfd;     /**< The listener sockfd. */
+	uint32_t fh;
 };
 
 /* refer to hw/virtio/vhost-user.c */
