get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

GET /api/patches/54968/?format=api
HTTP 200 OK
Allow: GET, PUT, PATCH, HEAD, OPTIONS
Content-Type: application/json
Vary: Accept

{
    "id": 54968,
    "url": "http://patches.dpdk.org/api/patches/54968/?format=api",
    "web_url": "http://patches.dpdk.org/project/dpdk/patch/1560957293-17294-15-git-send-email-ndragazis@arrikto.com/",
    "project": {
        "id": 1,
        "url": "http://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": "<1560957293-17294-15-git-send-email-ndragazis@arrikto.com>",
    "list_archive_url": "https://inbox.dpdk.org/dev/1560957293-17294-15-git-send-email-ndragazis@arrikto.com",
    "date": "2019-06-19T15:14:39",
    "name": "[14/28] vhost: move setup of the log memory region",
    "commit_ref": null,
    "pull_url": null,
    "state": "rfc",
    "archived": true,
    "hash": "0dc3eb6d2ccc3b90ac30443502d6523aeb93db70",
    "submitter": {
        "id": 1339,
        "url": "http://patches.dpdk.org/api/people/1339/?format=api",
        "name": "Nikos Dragazis",
        "email": "ndragazis@arrikto.com"
    },
    "delegate": {
        "id": 2642,
        "url": "http://patches.dpdk.org/api/users/2642/?format=api",
        "username": "mcoquelin",
        "first_name": "Maxime",
        "last_name": "Coquelin",
        "email": "maxime.coquelin@redhat.com"
    },
    "mbox": "http://patches.dpdk.org/project/dpdk/patch/1560957293-17294-15-git-send-email-ndragazis@arrikto.com/mbox/",
    "series": [
        {
            "id": 5082,
            "url": "http://patches.dpdk.org/api/series/5082/?format=api",
            "web_url": "http://patches.dpdk.org/project/dpdk/list/?series=5082",
            "date": "2019-06-19T15:14:25",
            "name": "vhost: add virtio-vhost-user transport",
            "version": 1,
            "mbox": "http://patches.dpdk.org/series/5082/mbox/"
        }
    ],
    "comments": "http://patches.dpdk.org/api/patches/54968/comments/",
    "check": "fail",
    "checks": "http://patches.dpdk.org/api/patches/54968/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 [127.0.0.1])\n\tby dpdk.org (Postfix) with ESMTP id 0940F1C3FD;\n\tWed, 19 Jun 2019 17:16:22 +0200 (CEST)",
            "from mx0.arrikto.com (mx0.arrikto.com [212.71.252.59])\n\tby dpdk.org (Postfix) with ESMTP id 2E5ED1C393\n\tfor <dev@dpdk.org>; Wed, 19 Jun 2019 17:15:42 +0200 (CEST)",
            "from troi.prod.arr (mail.arr [10.99.0.5])\n\tby mx0.arrikto.com (Postfix) with ESMTP id F3E8C182012;\n\tWed, 19 Jun 2019 18:15:41 +0300 (EEST)",
            "from localhost.localdomain (unknown [10.89.50.133])\n\tby troi.prod.arr (Postfix) with ESMTPSA id 75D6B2B2;\n\tWed, 19 Jun 2019 18:15:41 +0300 (EEST)"
        ],
        "From": "Nikos Dragazis <ndragazis@arrikto.com>",
        "To": "dev@dpdk.org",
        "Cc": "Maxime Coquelin <maxime.coquelin@redhat.com>,\n\tTiwei Bie <tiwei.bie@intel.com>, Zhihong Wang <zhihong.wang@intel.com>,\n\tStefan Hajnoczi <stefanha@redhat.com>, Wei Wang <wei.w.wang@intel.com>,\n\tStojaczyk Dariusz <dariusz.stojaczyk@intel.com>,\n\tVangelis Koukis <vkoukis@arrikto.com>",
        "Date": "Wed, 19 Jun 2019 18:14:39 +0300",
        "Message-Id": "<1560957293-17294-15-git-send-email-ndragazis@arrikto.com>",
        "X-Mailer": "git-send-email 2.7.4",
        "In-Reply-To": "<1560957293-17294-1-git-send-email-ndragazis@arrikto.com>",
        "References": "<1560957293-17294-1-git-send-email-ndragazis@arrikto.com>",
        "Subject": "[dpdk-dev] [PATCH 14/28] vhost: move setup of the log memory region",
        "X-BeenThere": "dev@dpdk.org",
        "X-Mailman-Version": "2.1.15",
        "Precedence": "list",
        "List-Id": "DPDK patches and discussions <dev.dpdk.org>",
        "List-Unsubscribe": "<https://mails.dpdk.org/options/dev>,\n\t<mailto:dev-request@dpdk.org?subject=unsubscribe>",
        "List-Archive": "<http://mails.dpdk.org/archives/dev/>",
        "List-Post": "<mailto:dev@dpdk.org>",
        "List-Help": "<mailto:dev-request@dpdk.org?subject=help>",
        "List-Subscribe": "<https://mails.dpdk.org/listinfo/dev>,\n\t<mailto:dev-request@dpdk.org?subject=subscribe>",
        "Errors-To": "dev-bounces@dpdk.org",
        "Sender": "\"dev\" <dev-bounces@dpdk.org>"
    },
    "content": "Setting up the log memory region involves mapping/unmapping guest\nmemory. This is a transport-specific operation. Other transports may use\nother means of accessing the guest memory log. Therefore, the mmap/unmap\noperations, that are related to the memory log, are moved to\ntrans_af_unix.c. A new set_log_base() transport operation is introduced.\n\nSigned-off-by: Nikos Dragazis <ndragazis@arrikto.com>\n---\n lib/librte_vhost/trans_af_unix.c | 41 ++++++++++++++++++++++++++++++++++++++++\n lib/librte_vhost/vhost.h         | 13 +++++++++++++\n lib/librte_vhost/vhost_user.c    | 27 +-------------------------\n 3 files changed, 55 insertions(+), 26 deletions(-)",
    "diff": "diff --git a/lib/librte_vhost/trans_af_unix.c b/lib/librte_vhost/trans_af_unix.c\nindex 522823f..35b1c45 100644\n--- a/lib/librte_vhost/trans_af_unix.c\n+++ b/lib/librte_vhost/trans_af_unix.c\n@@ -763,6 +763,11 @@ af_unix_cleanup_device(struct virtio_net *dev, int destroy __rte_unused)\n \tstruct vhost_user_connection *conn =\n \t\tcontainer_of(dev, struct vhost_user_connection, device);\n \n+\tif (dev->log_addr) {\n+\t\tmunmap((void *)(uintptr_t)dev->log_addr, dev->log_size);\n+\t\tdev->log_addr = 0;\n+\t}\n+\n \tif (conn->slave_req_fd >= 0) {\n \t\tclose(conn->slave_req_fd);\n \t\tconn->slave_req_fd = -1;\n@@ -950,6 +955,41 @@ af_unix_unmap_mem_regions(struct virtio_net *dev)\n \t}\n }\n \n+static int\n+af_unix_set_log_base(struct virtio_net *dev, const struct VhostUserMsg *msg)\n+{\n+\tint fd = msg->fds[0];\n+\tuint64_t size, off;\n+\tvoid *addr;\n+\n+\tsize = msg->payload.log.mmap_size;\n+\toff  = msg->payload.log.mmap_offset;\n+\n+\t/*\n+\t * mmap from 0 to workaround a hugepage mmap bug: mmap will\n+\t * fail when offset is not page size aligned.\n+\t */\n+\taddr = mmap(0, size + off, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0);\n+\tclose(fd);\n+\tif (addr == MAP_FAILED) {\n+\t\tRTE_LOG(ERR, VHOST_CONFIG, \"mmap log base failed!\\n\");\n+\t\treturn -1;\n+\t}\n+\n+\t/*\n+\t * Free previously mapped log memory on occasionally\n+\t * multiple VHOST_USER_SET_LOG_BASE.\n+\t */\n+\tif (dev->log_addr) {\n+\t\tmunmap((void *)(uintptr_t)dev->log_addr, dev->log_size);\n+\t}\n+\tdev->log_addr = (uint64_t)(uintptr_t)addr;\n+\tdev->log_base = dev->log_addr + off;\n+\tdev->log_size = size;\n+\n+\treturn 0;\n+}\n+\n const struct vhost_transport_ops af_unix_trans_ops = {\n \t.socket_size = sizeof(struct af_unix_socket),\n \t.device_size = sizeof(struct vhost_user_connection),\n@@ -964,4 +1004,5 @@ const struct vhost_transport_ops af_unix_trans_ops = {\n \t.set_slave_req_fd = af_unix_set_slave_req_fd,\n \t.map_mem_regions = af_unix_map_mem_regions,\n \t.unmap_mem_regions = af_unix_unmap_mem_regions,\n+\t.set_log_base = af_unix_set_log_base,\n };\ndiff --git a/lib/librte_vhost/vhost.h b/lib/librte_vhost/vhost.h\nindex 28038c6..b15d223 100644\n--- a/lib/librte_vhost/vhost.h\n+++ b/lib/librte_vhost/vhost.h\n@@ -437,6 +437,19 @@ struct vhost_transport_ops {\n \t *  vhost device\n \t */\n \tvoid (*unmap_mem_regions)(struct virtio_net *dev);\n+\n+\t/**\n+\t * Setup the log memory region.\n+\t *\n+\t * @param dev\n+\t *  vhost device\n+\t * @param msg\n+\t *  message\n+\t * @return\n+\t *  0 on success, -1 on failure\n+\t */\n+\tint (*set_log_base)(struct virtio_net *dev,\n+\t\t\t    const struct VhostUserMsg *msg);\n };\n \n /** The traditional AF_UNIX vhost-user protocol transport. */\ndiff --git a/lib/librte_vhost/vhost_user.c b/lib/librte_vhost/vhost_user.c\nindex ed8dbd8..acb1135 100644\n--- a/lib/librte_vhost/vhost_user.c\n+++ b/lib/librte_vhost/vhost_user.c\n@@ -137,11 +137,6 @@ vhost_backend_cleanup(struct virtio_net *dev)\n \tfree(dev->guest_pages);\n \tdev->guest_pages = NULL;\n \n-\tif (dev->log_addr) {\n-\t\tmunmap((void *)(uintptr_t)dev->log_addr, dev->log_size);\n-\t\tdev->log_addr = 0;\n-\t}\n-\n \tif (dev->postcopy_ufd >= 0) {\n \t\tclose(dev->postcopy_ufd);\n \t\tdev->postcopy_ufd = -1;\n@@ -1275,7 +1270,6 @@ vhost_user_set_log_base(struct virtio_net **pdev, struct VhostUserMsg *msg,\n \tstruct virtio_net *dev = *pdev;\n \tint fd = msg->fds[0];\n \tuint64_t size, off;\n-\tvoid *addr;\n \n \tif (fd < 0) {\n \t\tRTE_LOG(ERR, VHOST_CONFIG, \"invalid log fd: %d\\n\", fd);\n@@ -1304,27 +1298,8 @@ vhost_user_set_log_base(struct virtio_net **pdev, struct VhostUserMsg *msg,\n \t\t\"log mmap size: %\"PRId64\", offset: %\"PRId64\"\\n\",\n \t\tsize, off);\n \n-\t/*\n-\t * mmap from 0 to workaround a hugepage mmap bug: mmap will\n-\t * fail when offset is not page size aligned.\n-\t */\n-\taddr = mmap(0, size + off, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0);\n-\tclose(fd);\n-\tif (addr == MAP_FAILED) {\n-\t\tRTE_LOG(ERR, VHOST_CONFIG, \"mmap log base failed!\\n\");\n+\tif (dev->trans_ops->set_log_base(dev, msg) < 0)\n \t\treturn RTE_VHOST_MSG_RESULT_ERR;\n-\t}\n-\n-\t/*\n-\t * Free previously mapped log memory on occasionally\n-\t * multiple VHOST_USER_SET_LOG_BASE.\n-\t */\n-\tif (dev->log_addr) {\n-\t\tmunmap((void *)(uintptr_t)dev->log_addr, dev->log_size);\n-\t}\n-\tdev->log_addr = (uint64_t)(uintptr_t)addr;\n-\tdev->log_base = dev->log_addr + off;\n-\tdev->log_size = size;\n \n \t/*\n \t * The spec is not clear about it (yet), but QEMU doesn't expect\n",
    "prefixes": [
        "14/28"
    ]
}