Patch Detail
get:
Show a patch.
patch:
Update a patch.
put:
Update a patch.
GET /api/patches/2512/?format=api
https://patches.dpdk.org/api/patches/2512/?format=api", "web_url": "https://patches.dpdk.org/project/dpdk/patch/1422242440-28948-13-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": "<1422242440-28948-13-git-send-email-huawei.xie@intel.com>", "list_archive_url": "https://inbox.dpdk.org/dev/1422242440-28948-13-git-send-email-huawei.xie@intel.com", "date": "2015-01-26T03:20:38", "name": "[dpdk-dev,RFC,v2,12/14] cleanup when vhost user connection is closed", "commit_ref": null, "pull_url": null, "state": "superseded", "archived": true, "hash": "42262c4e967b13c5e9d8fe830e13499f7738c08f", "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/1422242440-28948-13-git-send-email-huawei.xie@intel.com/mbox/", "series": [], "comments": "https://patches.dpdk.org/api/patches/2512/comments/", "check": "pending", "checks": "https://patches.dpdk.org/api/patches/2512/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 C933A5A6D;\n\tMon, 26 Jan 2015 04:21:49 +0100 (CET)", "from mga02.intel.com (mga02.intel.com [134.134.136.20])\n\tby dpdk.org (Postfix) with ESMTP id A44D15AB9\n\tfor <dev@dpdk.org>; Mon, 26 Jan 2015 04:21:44 +0100 (CET)", "from fmsmga001.fm.intel.com ([10.253.24.23])\n\tby orsmga101.jf.intel.com with ESMTP; 25 Jan 2015 19:21:42 -0800", "from shvmail01.sh.intel.com ([10.239.29.42])\n\tby fmsmga001.fm.intel.com with ESMTP; 25 Jan 2015 19:21:40 -0800", "from shecgisg003.sh.intel.com (shecgisg003.sh.intel.com\n\t[10.239.29.90])\n\tby shvmail01.sh.intel.com with ESMTP id t0Q3LdoL015504;\n\tMon, 26 Jan 2015 11:21:39 +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 t0Q3La98029067; Mon, 26 Jan 2015 11:21:38 +0800", "(from hxie5@localhost)\n\tby shecgisg003.sh.intel.com (8.13.6/8.13.6/Submit) id t0Q3LaM2029063; \n\tMon, 26 Jan 2015 11:21:36 +0800" ], "X-ExtLoop1": "1", "X-IronPort-AV": "E=Sophos;i=\"5.09,466,1418112000\"; d=\"scan'208\";a=\"656346936\"", "From": "Huawei Xie <huawei.xie@intel.com>", "To": "dev@dpdk.org", "Date": "Mon, 26 Jan 2015 11:20:38 +0800", "Message-Id": "<1422242440-28948-13-git-send-email-huawei.xie@intel.com>", "X-Mailer": "git-send-email 1.7.4.1", "In-Reply-To": "<1422242440-28948-1-git-send-email-huawei.xie@intel.com>", "References": "<1422242440-28948-1-git-send-email-huawei.xie@intel.com>", "Subject": "[dpdk-dev] [RFC PATCH v2 12/14] cleanup when vhost user connection\n\tis closed", "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": "Signed-off-by: Huawei Xie <huawei.xie@intel.com>\n---\n lib/librte_vhost/vhost_user/vhost-net-user.c | 4 ++\n lib/librte_vhost/vhost_user/virtio-net-user.c | 56 +++++++++++++++++++--------\n lib/librte_vhost/vhost_user/virtio-net-user.h | 1 +\n 3 files changed, 45 insertions(+), 16 deletions(-)", "diff": "diff --git a/lib/librte_vhost/vhost_user/vhost-net-user.c b/lib/librte_vhost/vhost_user/vhost-net-user.c\nindex c84fd3b..71e5bbd 100644\n--- a/lib/librte_vhost/vhost_user/vhost-net-user.c\n+++ b/lib/librte_vhost/vhost_user/vhost-net-user.c\n@@ -289,6 +289,7 @@ vserver_message_handler(int connfd, void *dat)\n \n \t\tclose(connfd);\n \t\tfdset_del(&g_vhost_server->fdset, connfd);\n+\t\tuser_destroy_device(ctx);\n \t\tops->destroy_device(ctx);\n \n \t\treturn;\n@@ -298,6 +299,7 @@ vserver_message_handler(int connfd, void *dat)\n \n \t\tclose(connfd);\n \t\tfdset_del(&g_vhost_server->fdset, connfd);\n+\t\tuser_destroy_device(ctx);\n \t\tops->destroy_device(ctx);\n \n \t\treturn;\n@@ -308,6 +310,8 @@ vserver_message_handler(int connfd, void *dat)\n \n \t\tclose(connfd);\n \t\tfdset_del(&g_vhost_server->fdset, connfd);\n+\t\tuser_destroy_device(ctx);\n+\t\tops->destroy_device(ctx);\n \n \t\treturn;\n \t}\ndiff --git a/lib/librte_vhost/vhost_user/virtio-net-user.c b/lib/librte_vhost/vhost_user/virtio-net-user.c\nindex 3481eb8..8e6d580 100644\n--- a/lib/librte_vhost/vhost_user/virtio-net-user.c\n+++ b/lib/librte_vhost/vhost_user/virtio-net-user.c\n@@ -68,6 +68,30 @@ get_blk_size(int fd)\n \treturn (uint64_t)stat.st_blksize;\n }\n \n+static void\n+free_mem_region(struct virtio_net *dev)\n+{\n+\tstruct orig_region_map *region;\n+\tunsigned int idx;\n+\tuint64_t alignment;\n+\n+\tif (!dev || !dev->mem)\n+\t\treturn;\n+\n+\tregion = orig_region(dev->mem, dev->mem->nregions);\n+\tfor (idx = 0; idx < dev->mem->nregions; idx++) {\n+\t\tif (region[idx].mapped_address) {\n+\t\t\talignment = region[idx].blksz;\n+\t\t\tmunmap((void *)\n+\t\t\t\tRTE_ALIGN_FLOOR(\n+\t\t\t\t\tregion[idx].mapped_address, alignment),\n+\t\t\t\tRTE_ALIGN_CEIL(\n+\t\t\t\t\tregion[idx].mapped_size, alignment));\n+\t\t\tclose(region[idx].fd);\n+\t\t}\n+\t}\n+}\n+\n int\n user_set_mem_table(struct vhost_device_ctx ctx, struct VhostUserMsg *pmsg)\n {\n@@ -80,24 +104,11 @@ user_set_mem_table(struct vhost_device_ctx ctx, struct VhostUserMsg *pmsg)\n \t\t[0 ... VHOST_MEMORY_MAX_NREGIONS - 1] = { 0 } };\n \tstruct orig_region_map *region;\n \tuint64_t alignment;\n-\tint ret;\n \n \t/* unmap old memory regions one by one*/\n \tdev = get_device(ctx);\n-\tif (dev->mem) {\n-\t\tregion = orig_region(dev->mem, dev->mem->nregions);\n-\t\tfor (idx = 0; idx < dev->mem->nregions; idx++) {\n-\t\t\tif (region[idx].mapped_address) {\n-\t\t\t\talignment = region[idx].blksz;\n-\t\t\t\tprintf(\"Freeing %p\\n\",\n-\t\t\t\t\t(void *)(uintptr_t)region[idx].mapped_address);\n-\t\t\t\tret = munmap((void *)RTE_ALIGN_FLOOR(region[idx].mapped_address, alignment),\n-\t\t\t\t\tRTE_ALIGN_CEIL(region[idx].mapped_size, alignment));\n-\t\t\t\tprintf(\"munmap ret= %d\\n\", ret);\n-\t\t\t\tprintf(\"close file %d\\n\", region[idx].fd);\n-\t\t\t\tclose(region[idx].fd);\n-\t\t\t}\n-\t\t}\n+\tif (dev && dev->mem) {\n+\t\tfree_mem_region(dev);\n \t\tfree(dev->mem);\n \t\tdev->mem = NULL;\n \t}\n@@ -258,7 +269,6 @@ user_set_vring_kick(struct vhost_device_ctx ctx, struct VhostUserMsg *pmsg)\n \tif (virtio_is_ready(dev) &&\n \t\t!(dev->flags & VIRTIO_DEV_RUNNING))\n \t\t\tnotify_ops->new_device(dev);\n-\n }\n \n /*\n@@ -294,5 +304,19 @@ user_get_vring_base(struct vhost_device_ctx ctx,\n \t}\n \n \treturn 0;\n+}\n+\n+void\n+user_destroy_device(struct vhost_device_ctx ctx)\n+{\n+\tstruct virtio_net *dev = get_device(ctx);\n \n+\tif (dev && (dev->flags & VIRTIO_DEV_RUNNING))\n+\t\tnotify_ops->destroy_device(dev);\n+\n+\tif (dev && dev->mem) {\n+\t\tfree_mem_region(dev);\n+\t\tfree(dev->mem);\n+\t\tdev->mem = NULL;\n+\t}\n }\ndiff --git a/lib/librte_vhost/vhost_user/virtio-net-user.h b/lib/librte_vhost/vhost_user/virtio-net-user.h\nindex 0f6a75a..df24860 100644\n--- a/lib/librte_vhost/vhost_user/virtio-net-user.h\n+++ b/lib/librte_vhost/vhost_user/virtio-net-user.h\n@@ -45,4 +45,5 @@ void user_set_vring_kick(struct vhost_device_ctx, struct VhostUserMsg *);\n \n int user_get_vring_base(struct vhost_device_ctx, struct vhost_vring_state *);\n \n+void user_destroy_device(struct vhost_device_ctx);\n #endif\n", "prefixes": [ "dpdk-dev", "RFC", "v2", "12/14" ] }{ "id": 2512, "url": "