get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

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

{
    "id": 41583,
    "url": "http://patchwork.dpdk.org/api/patches/41583/?format=api",
    "web_url": "http://patchwork.dpdk.org/project/dpdk/patch/153002997827.22089.15583649737397622971.stgit@T460/",
    "project": {
        "id": 1,
        "url": "http://patchwork.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": "<153002997827.22089.15583649737397622971.stgit@T460>",
    "list_archive_url": "https://inbox.dpdk.org/dev/153002997827.22089.15583649737397622971.stgit@T460",
    "date": "2018-06-26T16:19:38",
    "name": "[v1,5/5] vhost: message handling implemented as a callback array",
    "commit_ref": null,
    "pull_url": null,
    "state": "superseded",
    "archived": true,
    "hash": "8c104ef842b1a55987c0192a920ae09277014039",
    "submitter": {
        "id": 1062,
        "url": "http://patchwork.dpdk.org/api/people/1062/?format=api",
        "name": "Nikolay Nikolaev",
        "email": "nicknickolaev@gmail.com"
    },
    "delegate": {
        "id": 2642,
        "url": "http://patchwork.dpdk.org/api/users/2642/?format=api",
        "username": "mcoquelin",
        "first_name": "Maxime",
        "last_name": "Coquelin",
        "email": "maxime.coquelin@redhat.com"
    },
    "mbox": "http://patchwork.dpdk.org/project/dpdk/patch/153002997827.22089.15583649737397622971.stgit@T460/mbox/",
    "series": [
        {
            "id": 246,
            "url": "http://patchwork.dpdk.org/api/series/246/?format=api",
            "web_url": "http://patchwork.dpdk.org/project/dpdk/list/?series=246",
            "date": "2018-06-26T16:19:02",
            "name": "vhost_user.c code cleanup",
            "version": 1,
            "mbox": "http://patchwork.dpdk.org/series/246/mbox/"
        }
    ],
    "comments": "http://patchwork.dpdk.org/api/patches/41583/comments/",
    "check": "success",
    "checks": "http://patchwork.dpdk.org/api/patches/41583/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 019BB4C97;\n\tTue, 26 Jun 2018 18:19:42 +0200 (CEST)",
            "from mail-wr0-f193.google.com (mail-wr0-f193.google.com\n\t[209.85.128.193]) by dpdk.org (Postfix) with ESMTP id B1F391BB92\n\tfor <dev@dpdk.org>; Tue, 26 Jun 2018 18:19:40 +0200 (CEST)",
            "by mail-wr0-f193.google.com with SMTP id p12-v6so16224645wrn.11\n\tfor <dev@dpdk.org>; Tue, 26 Jun 2018 09:19:40 -0700 (PDT)",
            "from [127.0.1.1] ([82.146.27.14]) by smtp.gmail.com with ESMTPSA id\n\tw67-v6sm2687951wmw.0.2018.06.26.09.19.38\n\t(version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128);\n\tTue, 26 Jun 2018 09:19:39 -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=DeHYl6S+qE/deqeKTsfPvmsfGNhx2ikapv2wcW5uuvQ=;\n\tb=cuX/DrAMiAuETJTy89+IJpeTHqvXD+mdtCmEoHytw2iNqfqBmHYWbV3mI/iKX02J4a\n\tN/0IuNEmfRSJ3DUxAJ/5z/APoYIhjYK0J5WqRF7Uh0FX3iJpiiz0xNIT/wTrwhYw41ja\n\tXYuyV1L6GGNHz7b6gLRw24REk0oxCpwrTDyfUiH5my05VfC/tg1eCif4G6LFJQTUUweE\n\tZFCaZFELsq42CGXx1PnA4NFJzKNZje9TVN5U1PJhHvcMQEvMLpjKBiC5dWF7Kh8slRA9\n\tQPTGuJvEyjvU+TKtmobJyKPwqR5TYiSDyJMS23WRoOclJ7dr5A8DC+iIuLmH+1RXAUC4\n\t6WJw==",
        "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=DeHYl6S+qE/deqeKTsfPvmsfGNhx2ikapv2wcW5uuvQ=;\n\tb=ihIQMnUdU0EkrTSrsgBy7+NaVZO5edJ9IQNs2QP8PtUNfmcbDVpkwd9X1oLOL2pgXj\n\t2yIlwFPLOGpPaQ17k8kEj0xsvpQCGroXSkv8Uh1BnK3wcp0JUU87kZUVv1QPh+Zn3IK6\n\tOZ7dp8IajuOzgGJlZcYhK8i7OyHVCVVnCBULiSPsSTLNXU8FalnpsebuxWpXQ6JBh3KU\n\tUxwoOm6BRDk8wbG9K/acQlOFsIl92uacF+5fZ2gAZvidv6f1V+9fr4yywpU10ucQUdMm\n\t91ul9mvL+M4fZe4xQia9G7MTLxsSVIZRj8xuC3A5dT2ywe/B2DoHd1gHC3rVg7Z95qkI\n\tk8cQ==",
        "X-Gm-Message-State": "APt69E3/jT+xtrFyCZBT7wxedU2UxOKbFsfQpJk2ftWnnZc1s69sYeVp\n\tfznZLSoAkXMGmm4OoYl9/of2bKiS",
        "X-Google-Smtp-Source": "AAOMgpcwG1el8WrYdnPLpYoASusfAymRNX2pPx1qyNo4pGAShv8tJMjcyYn/7mBVgsqXViXyJzNk+Q==",
        "X-Received": "by 2002:adf:8446:: with SMTP id\n\t64-v6mr2207082wrf.138.1530029980092; \n\tTue, 26 Jun 2018 09:19:40 -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": "Tue, 26 Jun 2018 19:19:38 +0300",
        "Message-ID": "<153002997827.22089.15583649737397622971.stgit@T460>",
        "In-Reply-To": "<153002988259.22089.8523468795459281187.stgit@T460>",
        "References": "<153002988259.22089.8523468795459281187.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 v1 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\nSigned-off-by: Nikolay Nikolaev <nicknickolaev@gmail.com>\n---\n lib/librte_vhost/vhost_user.c |  144 ++++++++++++++++-------------------------\n 1 file changed, 55 insertions(+), 89 deletions(-)",
    "diff": "diff --git a/lib/librte_vhost/vhost_user.c b/lib/librte_vhost/vhost_user.c\nindex dd47d84c7..e62164d63 100644\n--- a/lib/librte_vhost/vhost_user.c\n+++ b/lib/librte_vhost/vhost_user.c\n@@ -1379,6 +1379,36 @@ vhost_user_iotlb_msg(struct virtio_net **pdev, VhostUserMsg *msg)\n \treturn VH_RESULT_OK;\n }\n \n+typedef int (*message_handler)(struct virtio_net **pdev, VhostUserMsg * msg);\n+static message_handler 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+\t[VHOST_USER_CRYPTO_CREATE_SESS] = NULL,\n+\t[VHOST_USER_CRYPTO_CLOSE_SESS] = NULL,\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@@ -1623,97 +1653,33 @@ 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\tif (ret)\n-\t\t\treturn -1;\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\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\tsend_vhost_reply(fd, &msg);\n-\t\tbreak;\n+\tint request = msg.request.master;\n+\tif (vhost_message_handlers[request]) {\n+\t\tret = vhost_message_handlers[request](&dev, &msg);\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-\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\treturn -1;\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\treturn -1;\n \t}\n \n skip_to_post_handle:\n",
    "prefixes": [
        "v1",
        "5/5"
    ]
}