get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

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

{
    "id": 45220,
    "url": "https://patches.dpdk.org/api/patches/45220/?format=api",
    "web_url": "https://patches.dpdk.org/project/dpdk/patch/153780250604.17494.14047996367800791377.stgit@T460/",
    "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": "<153780250604.17494.14047996367800791377.stgit@T460>",
    "list_archive_url": "https://inbox.dpdk.org/dev/153780250604.17494.14047996367800791377.stgit@T460",
    "date": "2018-09-24T15:21:46",
    "name": "[v5,5/5] vhost: message handling implemented as a callback array",
    "commit_ref": null,
    "pull_url": null,
    "state": "superseded",
    "archived": true,
    "hash": "57a5b90e1ab8f657102ae0d3cf82665250577404",
    "submitter": {
        "id": 1062,
        "url": "https://patches.dpdk.org/api/people/1062/?format=api",
        "name": "Nikolay Nikolaev",
        "email": "nicknickolaev@gmail.com"
    },
    "delegate": {
        "id": 2642,
        "url": "https://patches.dpdk.org/api/users/2642/?format=api",
        "username": "mcoquelin",
        "first_name": "Maxime",
        "last_name": "Coquelin",
        "email": "maxime.coquelin@redhat.com"
    },
    "mbox": "https://patches.dpdk.org/project/dpdk/patch/153780250604.17494.14047996367800791377.stgit@T460/mbox/",
    "series": [
        {
            "id": 1468,
            "url": "https://patches.dpdk.org/api/series/1468/?format=api",
            "web_url": "https://patches.dpdk.org/project/dpdk/list/?series=1468",
            "date": "2018-09-24T15:21:10",
            "name": "vhost_user.c code cleanup",
            "version": 5,
            "mbox": "https://patches.dpdk.org/series/1468/mbox/"
        }
    ],
    "comments": "https://patches.dpdk.org/api/patches/45220/comments/",
    "check": "success",
    "checks": "https://patches.dpdk.org/api/patches/45220/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 4A62B5F2A;\n\tMon, 24 Sep 2018 17:21:49 +0200 (CEST)",
            "from mail-wr1-f66.google.com (mail-wr1-f66.google.com\n\t[209.85.221.66]) by dpdk.org (Postfix) with ESMTP id 789A75F29\n\tfor <dev@dpdk.org>; Mon, 24 Sep 2018 17:21:48 +0200 (CEST)",
            "by mail-wr1-f66.google.com with SMTP id z3-v6so8273396wrr.13\n\tfor <dev@dpdk.org>; Mon, 24 Sep 2018 08:21:48 -0700 (PDT)",
            "from [127.0.1.1] ([82.146.27.14]) by smtp.gmail.com with ESMTPSA id\n\ts2-v6sm47214737wrn.83.2018.09.24.08.21.46\n\t(version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128);\n\tMon, 24 Sep 2018 08:21:47 -0700 (PDT)"
        ],
        "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025;\n\th=subject:from:to:cc:date:message-id:in-reply-to:references\n\t:user-agent:mime-version:content-transfer-encoding;\n\tbh=4CrBV2UXTRbMJJ9MA7YjLrQh22wXx4c12ySNhkJxKKQ=;\n\tb=ACWa60ee9ZJOF5infjQRJuHqPL1ZfxsKDAuwwPmrt+4L6ncEGjMOW+NpK1oPmkK3sr\n\ttn0VBJrQvK+z1/rlVtoieNvJNF84+iZYxcfRl8nvbaMdn8LSiTwPlaDq8Py4DRGxApv6\n\t7Il9quDeeDagxVkA3msyQYbV4lTnJZ8P2niA+l3eySippUrc/BRDs0z+xQEgy6NqzNjp\n\tsGli3l3gFiU3tkuaERDqIkq6Xvn6B7N4WHg4sUS169yQm0rhyHBGS35TVhiI8+lrlHIB\n\tEnOYcRLT4FFXNnSH6mEeMAEC+VhuUVg+DJdluzyDuriUrfXFXBHRQgUF7JrZX0HPYJ7R\n\tagXg==",
        "X-Google-DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20161025;\n\th=x-gm-message-state:subject:from:to:cc:date:message-id:in-reply-to\n\t:references:user-agent:mime-version:content-transfer-encoding;\n\tbh=4CrBV2UXTRbMJJ9MA7YjLrQh22wXx4c12ySNhkJxKKQ=;\n\tb=CGyDJbhwfiO2WM3EwDIq/944vBRwU5yFdCFEAEqv8R276ntr3TRyDQbECS3/B4kKfV\n\twadL+d/LUOHFfAHfUnWDCeNhEVwWv8jlVDo5dT97DHjFU4WBUrluz8sXK2YDykgr1nkE\n\tabsLdBMd/HV+NbhWHya6MN9ZVasQFRFXqRl0vwz/OUX9MD1RfEXybizIUXjFjEok4b8i\n\to2myT3zNV7GsEofB7AOTSb1eQg3EbZAILgqJrZl0OdXBq3uPVv6e+cMlViarNoo+vUqy\n\tj6ararm1/RRFgGj74kTVkLT/ga2FI8jcrSGoeYjGBdpgXN0R4KKpNO+VtwEz+SmQDwnf\n\tjUdQ==",
        "X-Gm-Message-State": "ABuFfojDsVilRYhH5PMFMHWBBkyB4RnX+rwNgI04mmJfMKJhEUKCGCJH\n\taML9N5nfh6XHjFG/fQp08Si/derrX+ca0w==",
        "X-Google-Smtp-Source": "ACcGV62QipxogcwHeojwVlLZ85JIUepzwn4xf/uOLKQuPHUi/9LKq2BIaX/bDq1oYj0j+Bc9HZKetw==",
        "X-Received": "by 2002:adf:fb0e:: with SMTP id\n\tc14-v6mr9294788wrr.117.1537802507829; \n\tMon, 24 Sep 2018 08:21:47 -0700 (PDT)",
        "From": "Nikolay Nikolaev <nicknickolaev@gmail.com>",
        "To": "maxime.coquelin@redhat.com, anatoly.burakov@intel.com,\n\ttiwei.bie@intel.com, zhihong.wang@intel.com",
        "Cc": "dev@dpdk.org",
        "Date": "Mon, 24 Sep 2018 18:21:46 +0300",
        "Message-ID": "<153780250604.17494.14047996367800791377.stgit@T460>",
        "In-Reply-To": "<153780242838.17494.4512397995243433980.stgit@T460>",
        "References": "<153780242838.17494.4512397995243433980.stgit@T460>",
        "User-Agent": "StGit/0.17.1-dirty",
        "MIME-Version": "1.0",
        "Content-Type": "text/plain; charset=\"utf-8\"",
        "Content-Transfer-Encoding": "7bit",
        "Subject": "[dpdk-dev] [PATCH v5 5/5] vhost: message handling implemented as a\n\tcallback array",
        "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": "Introduce vhost_message_handlers, which maps the message request\ntype to the message handler. Then replace the switch construct\nwith a map and call.\n\nFailing vhost_user_set_features is fatal and all processing should\nstop immediately and propagate the error to the upper layers. Change\nthe code accordingly to reflect that.\n\nSigned-off-by: Nikolay Nikolaev <nicknickolaev@gmail.com>\n---\n lib/librte_vhost/vhost_user.c |  149 +++++++++++++++--------------------------\n 1 file changed, 56 insertions(+), 93 deletions(-)",
    "diff": "diff --git a/lib/librte_vhost/vhost_user.c b/lib/librte_vhost/vhost_user.c\nindex ac89f413d..faad3ba49 100644\n--- a/lib/librte_vhost/vhost_user.c\n+++ b/lib/librte_vhost/vhost_user.c\n@@ -1477,6 +1477,34 @@ vhost_user_iotlb_msg(struct virtio_net **pdev, struct VhostUserMsg *msg)\n \treturn VH_RESULT_OK;\n }\n \n+typedef int (*vhost_message_handler_t)(struct virtio_net **pdev, VhostUserMsg * msg);\n+static vhost_message_handler_t vhost_message_handlers[VHOST_USER_MAX] = {\n+\t[VHOST_USER_NONE] = NULL,\n+\t[VHOST_USER_GET_FEATURES] = vhost_user_get_features,\n+\t[VHOST_USER_SET_FEATURES] = vhost_user_set_features,\n+\t[VHOST_USER_SET_OWNER] = vhost_user_set_owner,\n+\t[VHOST_USER_RESET_OWNER] = vhost_user_reset_owner,\n+\t[VHOST_USER_SET_MEM_TABLE] = vhost_user_set_mem_table,\n+\t[VHOST_USER_SET_LOG_BASE] = vhost_user_set_log_base,\n+\t[VHOST_USER_SET_LOG_FD] = vhost_user_set_log_fd,\n+\t[VHOST_USER_SET_VRING_NUM] = vhost_user_set_vring_num,\n+\t[VHOST_USER_SET_VRING_ADDR] = vhost_user_set_vring_addr,\n+\t[VHOST_USER_SET_VRING_BASE] = vhost_user_set_vring_base,\n+\t[VHOST_USER_GET_VRING_BASE] = vhost_user_get_vring_base,\n+\t[VHOST_USER_SET_VRING_KICK] = vhost_user_set_vring_kick,\n+\t[VHOST_USER_SET_VRING_CALL] = vhost_user_set_vring_call,\n+\t[VHOST_USER_SET_VRING_ERR] = vhost_user_set_vring_err,\n+\t[VHOST_USER_GET_PROTOCOL_FEATURES] = vhost_user_get_protocol_features,\n+\t[VHOST_USER_SET_PROTOCOL_FEATURES] = vhost_user_set_protocol_features,\n+\t[VHOST_USER_GET_QUEUE_NUM] = vhost_user_get_queue_num,\n+\t[VHOST_USER_SET_VRING_ENABLE] = vhost_user_set_vring_enable,\n+\t[VHOST_USER_SEND_RARP] = vhost_user_send_rarp,\n+\t[VHOST_USER_NET_SET_MTU] = vhost_user_net_set_mtu,\n+\t[VHOST_USER_SET_SLAVE_REQ_FD] = vhost_user_set_req_fd,\n+\t[VHOST_USER_IOTLB_MSG] = vhost_user_iotlb_msg,\n+};\n+\n+\n /* return bytes# of read on success or negative val on failure. */\n static int\n read_vhost_message(int sockfd, struct VhostUserMsg *msg)\n@@ -1630,6 +1658,7 @@ vhost_user_msg_handler(int vid, int fd)\n \tint ret;\n \tint unlock_required = 0;\n \tuint32_t skip_master = 0;\n+\tint request;\n \n \tdev = get_device(vid);\n \tif (dev == NULL)\n@@ -1722,100 +1751,34 @@ vhost_user_msg_handler(int vid, int fd)\n \t\t\tgoto skip_to_post_handle;\n \t}\n \n-\tswitch (msg.request.master) {\n-\tcase VHOST_USER_GET_FEATURES:\n-\t\tret = vhost_user_get_features(&dev, &msg);\n-\t\tsend_vhost_reply(fd, &msg);\n-\t\tbreak;\n-\tcase VHOST_USER_SET_FEATURES:\n-\t\tret = vhost_user_set_features(&dev, &msg);\n-\t\tbreak;\n-\n-\tcase VHOST_USER_GET_PROTOCOL_FEATURES:\n-\t\tret = vhost_user_get_protocol_features(&dev, &msg);\n-\t\tsend_vhost_reply(fd, &msg);\n-\t\tbreak;\n-\tcase VHOST_USER_SET_PROTOCOL_FEATURES:\n-\t\tret = vhost_user_set_protocol_features(&dev, &msg);\n-\t\tbreak;\n-\n-\tcase VHOST_USER_SET_OWNER:\n-\t\tret = vhost_user_set_owner(&dev, &msg);\n-\t\tbreak;\n-\tcase VHOST_USER_RESET_OWNER:\n-\t\tret = vhost_user_reset_owner(&dev, &msg);\n-\t\tbreak;\n-\n-\tcase VHOST_USER_SET_MEM_TABLE:\n-\t\tret = vhost_user_set_mem_table(&dev, &msg);\n-\t\tbreak;\n-\n-\tcase VHOST_USER_SET_LOG_BASE:\n-\t\tret = vhost_user_set_log_base(&dev, &msg);\n-\t\tif (ret)\n-\t\t\tgoto skip_to_reply;\n-\t\t/* it needs a reply */\n-\t\tsend_vhost_reply(fd, &msg);\n-\t\tbreak;\n-\tcase VHOST_USER_SET_LOG_FD:\n-\t\tret = vhost_user_set_log_fd(&dev, &msg);\n-\t\tbreak;\n-\n-\tcase VHOST_USER_SET_VRING_NUM:\n-\t\tret = vhost_user_set_vring_num(&dev, &msg);\n-\t\tbreak;\n-\tcase VHOST_USER_SET_VRING_ADDR:\n-\t\tret = vhost_user_set_vring_addr(&dev, &msg);\n-\t\tbreak;\n-\tcase VHOST_USER_SET_VRING_BASE:\n-\t\tret = vhost_user_set_vring_base(&dev, &msg);\n-\t\tbreak;\n-\n-\tcase VHOST_USER_GET_VRING_BASE:\n-\t\tret = vhost_user_get_vring_base(&dev, &msg);\n-\t\tif (ret)\n-\t\t\tgoto skip_to_reply;\n-\t\tsend_vhost_reply(fd, &msg);\n-\t\tbreak;\n-\n-\tcase VHOST_USER_SET_VRING_KICK:\n-\t\tret = vhost_user_set_vring_kick(&dev, &msg);\n-\t\tbreak;\n-\tcase VHOST_USER_SET_VRING_CALL:\n-\t\tret = vhost_user_set_vring_call(&dev, &msg);\n-\t\tbreak;\n-\n-\tcase VHOST_USER_SET_VRING_ERR:\n-\t\tret = vhost_user_set_vring_err(&dev, &msg);\n-\t\tbreak;\n-\n-\tcase VHOST_USER_GET_QUEUE_NUM:\n-\t\tret = vhost_user_get_queue_num(&dev, &msg);\n-\t\tsend_vhost_reply(fd, &msg);\n-\t\tbreak;\n-\n-\tcase VHOST_USER_SET_VRING_ENABLE:\n-\t\tret = vhost_user_set_vring_enable(&dev, &msg);\n-\t\tbreak;\n-\tcase VHOST_USER_SEND_RARP:\n-\t\tret = vhost_user_send_rarp(&dev, &msg);\n-\t\tbreak;\n-\n-\tcase VHOST_USER_NET_SET_MTU:\n-\t\tret = vhost_user_net_set_mtu(&dev, &msg);\n-\t\tbreak;\n-\n-\tcase VHOST_USER_SET_SLAVE_REQ_FD:\n-\t\tret = vhost_user_set_req_fd(&dev, &msg);\n-\t\tbreak;\n-\n-\tcase VHOST_USER_IOTLB_MSG:\n-\t\tret = vhost_user_iotlb_msg(&dev, &msg);\n-\t\tbreak;\n+\trequest = msg.request.master;\n+\tif (request > VHOST_USER_NONE && request < VHOST_USER_MAX) {\n+\t\tif (!vhost_message_handlers[request])\n+\t\t\tgoto skip_to_post_handle;\n+\t\tret = vhost_message_handlers[request](&dev, &msg);\n \n-\tdefault:\n-\t\tret = -1;\n-\t\tbreak;\n+\t\tswitch (ret) {\n+\t\tcase VH_RESULT_ERR:\n+\t\t\tRTE_LOG(ERR, VHOST_CONFIG,\n+\t\t\t\t\"Processing %s failed.\\n\",\n+\t\t\t\tvhost_message_str[request]);\n+\t\t\tbreak;\n+\t\tcase VH_RESULT_OK:\n+\t\t\tRTE_LOG(DEBUG, VHOST_CONFIG,\n+\t\t\t\t\"Processing %s succeeded.\\n\",\n+\t\t\t\tvhost_message_str[request]);\n+\t\t\tbreak;\n+\t\tcase VH_RESULT_REPLY:\n+\t\t\tRTE_LOG(INFO, VHOST_CONFIG,\n+\t\t\t\t\"Processing %s succeeded and needs reply.\\n\",\n+\t\t\t\tvhost_message_str[request]);\n+\t\t\tsend_vhost_reply(fd, &msg);\n+\t\t\tbreak;\n+\t\t}\n+\t} else {\n+\t\tRTE_LOG(ERR, VHOST_CONFIG,\n+\t\t\t\"Requested invalid message type %d.\\n\", request);\n+\t\tret = VH_RESULT_ERR;\n \t}\n \n skip_to_post_handle:\n",
    "prefixes": [
        "v5",
        "5/5"
    ]
}