Patch Detail
get:
Show a patch.
patch:
Update a patch.
put:
Update a patch.
GET /api/patches/5156/?format=api
https://patches.dpdk.org/api/patches/5156/?format=api", "web_url": "https://patches.dpdk.org/project/dpdk/patch/1433474786-704-1-git-send-email-huawei.xie@intel.com/", "project": { "id": 1, "url": "https://patches.dpdk.org/api/projects/1/?format=api", "name": "DPDK", "link_name": "dpdk", "list_id": "dev.dpdk.org", "list_email": "dev@dpdk.org", "web_url": "http://core.dpdk.org", "scm_url": "git://dpdk.org/dpdk", "webscm_url": "http://git.dpdk.org/dpdk", "list_archive_url": "https://inbox.dpdk.org/dev", "list_archive_url_format": "https://inbox.dpdk.org/dev/{}", "commit_url_format": "" }, "msgid": "<1433474786-704-1-git-send-email-huawei.xie@intel.com>", "list_archive_url": "https://inbox.dpdk.org/dev/1433474786-704-1-git-send-email-huawei.xie@intel.com", "date": "2015-06-05T03:26:26", "name": "[dpdk-dev,v2] vhost: provide vhost API to unregister vhost unix domain socket", "commit_ref": null, "pull_url": null, "state": "changes-requested", "archived": true, "hash": "1b71286efda944ed0c20e4692a8a7994f92ebc51", "submitter": { "id": 16, "url": "https://patches.dpdk.org/api/people/16/?format=api", "name": "Huawei Xie", "email": "huawei.xie@intel.com" }, "delegate": null, "mbox": "https://patches.dpdk.org/project/dpdk/patch/1433474786-704-1-git-send-email-huawei.xie@intel.com/mbox/", "series": [], "comments": "https://patches.dpdk.org/api/patches/5156/comments/", "check": "pending", "checks": "https://patches.dpdk.org/api/patches/5156/checks/", "tags": {}, "related": [], "headers": { "Return-Path": "<dev-bounces@dpdk.org>", "X-Original-To": "patchwork@dpdk.org", "Delivered-To": "patchwork@dpdk.org", "Received": [ "from [92.243.14.124] (localhost [IPv6:::1])\n\tby dpdk.org (Postfix) with ESMTP id BCC315A0F;\n\tFri, 5 Jun 2015 05:26:36 +0200 (CEST)", "from mga02.intel.com (mga02.intel.com [134.134.136.20])\n\tby dpdk.org (Postfix) with ESMTP id E3B9B376C\n\tfor <dev@dpdk.org>; Fri, 5 Jun 2015 05:26:34 +0200 (CEST)", "from fmsmga001.fm.intel.com ([10.253.24.23])\n\tby orsmga101.jf.intel.com with ESMTP; 04 Jun 2015 20:26:34 -0700", "from shvmail01.sh.intel.com ([10.239.29.42])\n\tby fmsmga001.fm.intel.com with ESMTP; 04 Jun 2015 20:26:33 -0700", "from shecgisg003.sh.intel.com (shecgisg003.sh.intel.com\n\t[10.239.29.90])\n\tby shvmail01.sh.intel.com with ESMTP id t553QVFG020590;\n\tFri, 5 Jun 2015 11:26:31 +0800", "from shecgisg003.sh.intel.com (localhost [127.0.0.1])\n\tby shecgisg003.sh.intel.com (8.13.6/8.13.6/SuSE Linux 0.8) with ESMTP\n\tid t553QSYO000738; Fri, 5 Jun 2015 11:26:30 +0800", "(from hxie5@localhost)\n\tby shecgisg003.sh.intel.com (8.13.6/8.13.6/Submit) id t553QSRw000734; \n\tFri, 5 Jun 2015 11:26:28 +0800" ], "X-ExtLoop1": "1", "X-IronPort-AV": "E=Sophos;i=\"5.13,555,1427785200\"; d=\"scan'208\";a=\"721125345\"", "From": "Huawei Xie <huawei.xie@intel.com>", "To": "dev@dpdk.org", "Date": "Fri, 5 Jun 2015 11:26:26 +0800", "Message-Id": "<1433474786-704-1-git-send-email-huawei.xie@intel.com>", "X-Mailer": "git-send-email 1.7.4.1", "In-Reply-To": "<1433209800-29091-1-git-send-email-huawei.xie@intel.com>", "References": "<1433209800-29091-1-git-send-email-huawei.xie@intel.com>", "Subject": "[dpdk-dev] [PATCH v2] vhost: provide vhost API to unregister vhost\n\tunix domain socket", "X-BeenThere": "dev@dpdk.org", "X-Mailman-Version": "2.1.15", "Precedence": "list", "List-Id": "patches and discussions about DPDK <dev.dpdk.org>", "List-Unsubscribe": "<http://dpdk.org/ml/options/dev>,\n\t<mailto:dev-request@dpdk.org?subject=unsubscribe>", "List-Archive": "<http://dpdk.org/ml/archives/dev/>", "List-Post": "<mailto:dev@dpdk.org>", "List-Help": "<mailto:dev-request@dpdk.org?subject=help>", "List-Subscribe": "<http://dpdk.org/ml/listinfo/dev>,\n\t<mailto:dev-request@dpdk.org?subject=subscribe>", "Errors-To": "dev-bounces@dpdk.org", "Sender": "\"dev\" <dev-bounces@dpdk.org>" }, "content": "rte_vhost_driver_unregister will remove the listenfd from event list, and then close it.\n\nSigned-off-by: Huawei Xie <huawei.xie@intel.com>\nSigned-off-by: Peng Sun <peng.a.sun@intel.com>\n---\n lib/librte_vhost/rte_virtio_net.h | 3 ++\n lib/librte_vhost/vhost_cuse/vhost-net-cdev.c | 9 ++++\n lib/librte_vhost/vhost_user/vhost-net-user.c | 68 +++++++++++++++++++++++-----\n lib/librte_vhost/vhost_user/vhost-net-user.h | 2 +-\n 4 files changed, 69 insertions(+), 13 deletions(-)", "diff": "diff --git a/lib/librte_vhost/rte_virtio_net.h b/lib/librte_vhost/rte_virtio_net.h\nindex 5d38185..5630fbc 100644\n--- a/lib/librte_vhost/rte_virtio_net.h\n+++ b/lib/librte_vhost/rte_virtio_net.h\n@@ -188,6 +188,9 @@ int rte_vhost_enable_guest_notification(struct virtio_net *dev, uint16_t queue_i\n /* Register vhost driver. dev_name could be different for multiple instance support. */\n int rte_vhost_driver_register(const char *dev_name);\n \n+/* Unregister vhost driver. This is only meaningful to vhost user. */\n+int rte_vhost_driver_unregister(const char *dev_name);\n+\n /* Register callbacks. */\n int rte_vhost_driver_callback_register(struct virtio_net_device_ops const * const);\n /* Start vhost driver session blocking loop. */\ndiff --git a/lib/librte_vhost/vhost_cuse/vhost-net-cdev.c b/lib/librte_vhost/vhost_cuse/vhost-net-cdev.c\nindex 6b68abf..1ae7c49 100644\n--- a/lib/librte_vhost/vhost_cuse/vhost-net-cdev.c\n+++ b/lib/librte_vhost/vhost_cuse/vhost-net-cdev.c\n@@ -405,6 +405,15 @@ rte_vhost_driver_register(const char *dev_name)\n }\n \n /**\n+ * An empty function for unregister\n+ */\n+int\n+rte_vhost_driver_unregister(const char *dev_name __rte_unused)\n+{\n+\treturn 0;\n+}\n+\n+/**\n * The CUSE session is launched allowing the application to receive open,\n * release and ioctl calls.\n */\ndiff --git a/lib/librte_vhost/vhost_user/vhost-net-user.c b/lib/librte_vhost/vhost_user/vhost-net-user.c\nindex 31f1215..87a4711 100644\n--- a/lib/librte_vhost/vhost_user/vhost-net-user.c\n+++ b/lib/librte_vhost/vhost_user/vhost-net-user.c\n@@ -66,6 +66,8 @@ struct connfd_ctx {\n struct _vhost_server {\n \tstruct vhost_server *server[MAX_VHOST_SERVER];\n \tstruct fdset fdset;\n+\tint vserver_cnt;\n+\tpthread_mutex_t server_mutex;\n };\n \n static struct _vhost_server g_vhost_server = {\n@@ -74,10 +76,10 @@ static struct _vhost_server g_vhost_server = {\n \t\t.fd_mutex = PTHREAD_MUTEX_INITIALIZER,\n \t\t.num = 0\n \t},\n+\t.vserver_cnt = 0,\n+\t.server_mutex = PTHREAD_MUTEX_INITIALIZER,\n };\n \n-static int vserver_idx;\n-\n static const char *vhost_message_str[VHOST_USER_MAX] = {\n \t[VHOST_USER_NONE] = \"VHOST_USER_NONE\",\n \t[VHOST_USER_GET_FEATURES] = \"VHOST_USER_GET_FEATURES\",\n@@ -427,7 +429,6 @@ vserver_message_handler(int connfd, void *dat, int *remove)\n \t}\n }\n \n-\n /**\n * Creates and initialise the vhost server.\n */\n@@ -436,34 +437,77 @@ rte_vhost_driver_register(const char *path)\n {\n \tstruct vhost_server *vserver;\n \n-\tif (vserver_idx == 0)\n+\tpthread_mutex_lock(&g_vhost_server.server_mutex);\n+\tif (ops == NULL)\n \t\tops = get_virtio_net_callbacks();\n-\tif (vserver_idx == MAX_VHOST_SERVER)\n+\n+\tif (g_vhost_server.vserver_cnt == MAX_VHOST_SERVER) {\n+\t\tRTE_LOG(ERR, VHOST_CONFIG,\n+\t\t\t\"error: the number of servers reaches maximum\\n\");\n+\t\tpthread_mutex_unlock(&g_vhost_server.server_mutex);\n \t\treturn -1;\n+\t}\n \n \tvserver = calloc(sizeof(struct vhost_server), 1);\n-\tif (vserver == NULL)\n+\tif (vserver == NULL) {\n+\t\tpthread_mutex_unlock(&g_vhost_server.server_mutex);\n \t\treturn -1;\n-\n-\tunlink(path);\n+\t}\n \n \tvserver->listenfd = uds_socket(path);\n \tif (vserver->listenfd < 0) {\n \t\tfree(vserver);\n+\t\tpthread_mutex_unlock(&g_vhost_server.server_mutex);\n \t\treturn -1;\n \t}\n-\tvserver->path = path;\n+\n+\tvserver->path = strdup(path);\n \n \tfdset_add(&g_vhost_server.fdset, vserver->listenfd,\n-\t\tvserver_new_vq_conn, NULL,\n-\t\tvserver);\n+\t\tvserver_new_vq_conn, NULL, vserver);\n \n-\tg_vhost_server.server[vserver_idx++] = vserver;\n+\tg_vhost_server.server[g_vhost_server.vserver_cnt++] = vserver;\n+\tpthread_mutex_unlock(&g_vhost_server.server_mutex);\n \n \treturn 0;\n }\n \n \n+/**\n+ * Unregister the specified vhost server\n+ */\n+int\n+rte_vhost_driver_unregister(const char *path)\n+{\n+\tint i;\n+\tint count;\n+\n+\tpthread_mutex_lock(&g_vhost_server.server_mutex);\n+\n+\tfor (i = 0; i < g_vhost_server.vserver_cnt; i++) {\n+\t\tif (!strcmp(g_vhost_server.server[i]->path, path)) {\n+\t\t\tfdset_del(&g_vhost_server.fdset,\n+\t\t\t\tg_vhost_server.server[i]->listenfd);\n+\n+\t\t\tclose(g_vhost_server.server[i]->listenfd);\n+\t\t\tfree(g_vhost_server.server[i]->path);\n+\t\t\tfree(g_vhost_server.server[i]);\n+\n+\t\t\tunlink(path);\n+\n+\t\t\tcount = --g_vhost_server.vserver_cnt;\n+\t\t\tg_vhost_server.server[i] = g_vhost_server.server[count];\n+\t\t\tg_vhost_server.server[count] = NULL;\n+\t\t\tpthread_mutex_unlock(&g_vhost_server.server_mutex);\n+\n+\t\t\treturn 0;\n+\t\t}\n+\t}\n+\tpthread_mutex_unlock(&g_vhost_server.server_mutex);\n+\n+\treturn -1;\n+}\n+\n int\n rte_vhost_driver_session_start(void)\n {\ndiff --git a/lib/librte_vhost/vhost_user/vhost-net-user.h b/lib/librte_vhost/vhost_user/vhost-net-user.h\nindex 1b6be6c..2e72f3c 100644\n--- a/lib/librte_vhost/vhost_user/vhost-net-user.h\n+++ b/lib/librte_vhost/vhost_user/vhost-net-user.h\n@@ -41,7 +41,7 @@\n #include \"fd_man.h\"\n \n struct vhost_server {\n-\tconst char *path; /**< The path the uds is bind to. */\n+\tchar *path; /**< The path the uds is bind to. */\n \tint listenfd; /**< The listener sockfd. */\n };\n \n", "prefixes": [ "dpdk-dev", "v2" ] }{ "id": 5156, "url": "