get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

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

{
    "id": 44754,
    "url": "http://patches.dpdk.org/api/patches/44754/?format=api",
    "web_url": "http://patches.dpdk.org/project/dpdk/patch/153698885466.23049.5627861471035122455.stgit@T460/",
    "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": "<153698885466.23049.5627861471035122455.stgit@T460>",
    "list_archive_url": "https://inbox.dpdk.org/dev/153698885466.23049.5627861471035122455.stgit@T460",
    "date": "2018-09-15T05:20:54",
    "name": "[v3,5/5] vhost: message handling implemented as a callback array",
    "commit_ref": null,
    "pull_url": null,
    "state": "superseded",
    "archived": true,
    "hash": "df3c87cffcc679d3106ba74e50dc68cb12bba238",
    "submitter": {
        "id": 1062,
        "url": "http://patches.dpdk.org/api/people/1062/?format=api",
        "name": "Nikolay Nikolaev",
        "email": "nicknickolaev@gmail.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/153698885466.23049.5627861471035122455.stgit@T460/mbox/",
    "series": [
        {
            "id": 1332,
            "url": "http://patches.dpdk.org/api/series/1332/?format=api",
            "web_url": "http://patches.dpdk.org/project/dpdk/list/?series=1332",
            "date": "2018-09-15T05:20:19",
            "name": "vhost: vhost_user.c code cleanup",
            "version": 3,
            "mbox": "http://patches.dpdk.org/series/1332/mbox/"
        }
    ],
    "comments": "http://patches.dpdk.org/api/patches/44754/comments/",
    "check": "success",
    "checks": "http://patches.dpdk.org/api/patches/44754/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 B5AA94D3A;\n\tSat, 15 Sep 2018 07:20:58 +0200 (CEST)",
            "from mail-wr1-f67.google.com (mail-wr1-f67.google.com\n\t[209.85.221.67]) by dpdk.org (Postfix) with ESMTP id 26C2E4F9B\n\tfor <dev@dpdk.org>; Sat, 15 Sep 2018 07:20:57 +0200 (CEST)",
            "by mail-wr1-f67.google.com with SMTP id w11-v6so12386070wrc.5\n\tfor <dev@dpdk.org>; Fri, 14 Sep 2018 22:20:57 -0700 (PDT)",
            "from [127.0.1.1] ([82.146.27.14]) by smtp.gmail.com with ESMTPSA id\n\t60-v6sm9827382wre.82.2018.09.14.22.20.55\n\t(version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128);\n\tFri, 14 Sep 2018 22:20:56 -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=Yv236JZO8MBwNudwgeRbvCz9ijAwsid6llq78vrEdfI=;\n\tb=M41PSF1384aSFyIeQmnyTLwZhfgtpePKAq68cWu2AmkFanCMs6ev5tCIUW5R/sYKVz\n\tQLSXOZrszJch5yrAWAzLJRlcnemgR9a2vh9W5OBogVZB2QdtsO8/J2uoGQFnxyQ4ihMV\n\t4hCh6e3DzllOEJ7U7PjN6f/xwc3HJRaG0T5HGL2joMI1KWQNLmlg/PoLqBS3xF3/0pk5\n\tiHPAY/YmdecJR5nv4GlzGmB5Lg5jc44wq8qIJLMCLfSm+AvU2FAu6hFXi92ucQ5Fwnnc\n\tVtSjC1nfmlcT7ZKmUg79iEkpM6KdRmYDjEQow8X4fUyeDT6UbWS5re6UcOX8KAQ1PTIp\n\tlQiQ==",
        "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=Yv236JZO8MBwNudwgeRbvCz9ijAwsid6llq78vrEdfI=;\n\tb=V/2y2YZdKPRYHNnHfN3x+IVXQ3hyh4Cnnx03DjOUtkNyfm8vMbvz3TOyzOcVjeMV+0\n\t5WotHn3AKNuxDZiTSjeC2EBtdy/9vqB0YpYPkKm9E3pEffBjkpr8fzX+WsNDquH2u3Zt\n\tie/9RB6ZrRAf7KjeWRvW7n4AdPKkUlwJ8NMaHbIdLFZaD4CkVSQJFu+f3KxtEukcJMNs\n\tAY1h3pgKjZ0qQ3ykl6SiHNw1kdXizbi3be1A3xT9sCyP0uaSy26P5a5ek8rL7MvVt/Oy\n\tLJl6kHXle4gEQW+L0keGQMbgTw/ttYomqyEWhgjQAZzzi1UGBoGoE2YuMQqJjHbzfbiR\n\tmbZA==",
        "X-Gm-Message-State": "APzg51CzKP1RdUfCCOtypRqY8LkDDvV+hh8MV1AHKIJBG55FyPSOX3bh\n\tIxkkHXZpP2sG9bUceRpd0AjY3K133EitbA==",
        "X-Google-Smtp-Source": "ANB0VdYfa3diLEuEPiT3cjGCuB94gXBUQhE+nPNgtA95F/A5/9tg2IZ9xWKjAmPiIuTFQqKcOjxecw==",
        "X-Received": "by 2002:a5d:50cf:: with SMTP id\n\tf15-v6mr12415525wrt.128.1536988856596; \n\tFri, 14 Sep 2018 22:20:56 -0700 (PDT)",
        "From": "Nikolay Nikolaev <nicknickolaev@gmail.com>",
        "To": "maxime.coquelin@redhat.com, tiwei.bie@intel.com, zhihong.wang@intel.com",
        "Cc": "dev@dpdk.org",
        "Date": "Sat, 15 Sep 2018 08:20:54 +0300",
        "Message-ID": "<153698885466.23049.5627861471035122455.stgit@T460>",
        "In-Reply-To": "<153698873346.23049.10966616323159180622.stgit@T460>",
        "References": "<153698873346.23049.10966616323159180622.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 v3 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 |  161 +++++++++++++++++------------------------\n 1 file changed, 66 insertions(+), 95 deletions(-)",
    "diff": "diff --git a/lib/librte_vhost/vhost_user.c b/lib/librte_vhost/vhost_user.c\nindex 81c0396de..9004e1ac8 100644\n--- a/lib/librte_vhost/vhost_user.c\n+++ b/lib/librte_vhost/vhost_user.c\n@@ -73,6 +73,8 @@ static const char *vhost_message_str[VHOST_USER_MAX] = {\n \n /* The possible results of a message handling function */\n enum vh_result {\n+\t/* Message handling failed with an unrecoverable error */\n+\tVH_RESULT_FATAL = -2,\n \t/* Message handling failed */\n \tVH_RESULT_ERR   = -1,\n \t/* Message handling successful */\n@@ -206,7 +208,7 @@ vhost_user_set_features(struct virtio_net **pdev, VhostUserMsg *msg)\n \t\tRTE_LOG(ERR, VHOST_CONFIG,\n \t\t\t\"(%d) received invalid negotiated features.\\n\",\n \t\t\tdev->vid);\n-\t\treturn VH_RESULT_ERR;\n+\t\treturn VH_RESULT_FATAL;\n \t}\n \n \tif (dev->flags & VIRTIO_DEV_RUNNING) {\n@@ -222,7 +224,7 @@ vhost_user_set_features(struct virtio_net **pdev, VhostUserMsg *msg)\n \t\t\tRTE_LOG(ERR, VHOST_CONFIG,\n \t\t\t\t\"(%d) features changed while device is running.\\n\",\n \t\t\t\tdev->vid);\n-\t\t\treturn VH_RESULT_ERR;\n+\t\t\treturn VH_RESULT_FATAL;\n \t\t}\n \n \t\tif (dev->notify_ops->features_changed)\n@@ -1477,6 +1479,34 @@ vhost_user_iotlb_msg(struct virtio_net **pdev, 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, VhostUserMsg *msg)\n@@ -1629,6 +1659,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@@ -1721,100 +1752,40 @@ 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_FATAL:\n+\t\t\tRTE_LOG(ERR, VHOST_CONFIG,\n+\t\t\t\t\"Processing %s failed with an unrecoverable error.\\n\",\n+\t\t\t\tvhost_message_str[request]);\n+\t\t\t/* Propagate the error to the upper layer */\n+\t\t\treturn -1;\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": [
        "v3",
        "5/5"
    ]
}