get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

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

{
    "id": 831194,
    "url": "http://patchwork.ozlabs.org/api/1.2/patches/831194/?format=api",
    "web_url": "http://patchwork.ozlabs.org/project/qemu-devel/patch/20171027104037.8319-9-eblake@redhat.com/",
    "project": {
        "id": 14,
        "url": "http://patchwork.ozlabs.org/api/1.2/projects/14/?format=api",
        "name": "QEMU Development",
        "link_name": "qemu-devel",
        "list_id": "qemu-devel.nongnu.org",
        "list_email": "qemu-devel@nongnu.org",
        "web_url": "",
        "scm_url": "",
        "webscm_url": "",
        "list_archive_url": "",
        "list_archive_url_format": "",
        "commit_url_format": ""
    },
    "msgid": "<20171027104037.8319-9-eblake@redhat.com>",
    "list_archive_url": null,
    "date": "2017-10-27T10:40:33",
    "name": "[v6,08/12] nbd/server: Include human-readable message in structured errors",
    "commit_ref": null,
    "pull_url": null,
    "state": "new",
    "archived": false,
    "hash": "3feff4b15de4ee70ab76c927607640207b89550b",
    "submitter": {
        "id": 6591,
        "url": "http://patchwork.ozlabs.org/api/1.2/people/6591/?format=api",
        "name": "Eric Blake",
        "email": "eblake@redhat.com"
    },
    "delegate": null,
    "mbox": "http://patchwork.ozlabs.org/project/qemu-devel/patch/20171027104037.8319-9-eblake@redhat.com/mbox/",
    "series": [
        {
            "id": 10552,
            "url": "http://patchwork.ozlabs.org/api/1.2/series/10552/?format=api",
            "web_url": "http://patchwork.ozlabs.org/project/qemu-devel/list/?series=10552",
            "date": "2017-10-27T10:40:27",
            "name": "nbd minimal structured read",
            "version": 6,
            "mbox": "http://patchwork.ozlabs.org/series/10552/mbox/"
        }
    ],
    "comments": "http://patchwork.ozlabs.org/api/patches/831194/comments/",
    "check": "pending",
    "checks": "http://patchwork.ozlabs.org/api/patches/831194/checks/",
    "tags": {},
    "related": [],
    "headers": {
        "Return-Path": "<qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org>",
        "X-Original-To": "incoming@patchwork.ozlabs.org",
        "Delivered-To": "patchwork-incoming@bilbo.ozlabs.org",
        "Authentication-Results": [
            "ozlabs.org;\n\tspf=pass (mailfrom) smtp.mailfrom=nongnu.org\n\t(client-ip=2001:4830:134:3::11; helo=lists.gnu.org;\n\tenvelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org;\n\treceiver=<UNKNOWN>)",
            "ext-mx10.extmail.prod.ext.phx2.redhat.com;\n\tdmarc=none (p=none dis=none) header.from=redhat.com",
            "ext-mx10.extmail.prod.ext.phx2.redhat.com;\n\tspf=fail smtp.mailfrom=eblake@redhat.com"
        ],
        "Received": [
            "from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11])\n\t(using TLSv1 with cipher AES256-SHA (256/256 bits))\n\t(No client certificate requested)\n\tby ozlabs.org (Postfix) with ESMTPS id 3yNgbg2X5kz9t2Z\n\tfor <incoming@patchwork.ozlabs.org>;\n\tFri, 27 Oct 2017 21:49:01 +1100 (AEDT)",
            "from localhost ([::1]:56580 helo=lists.gnu.org)\n\tby lists.gnu.org with esmtp (Exim 4.71) (envelope-from\n\t<qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org>)\n\tid 1e82CC-0007Rb-2F\n\tfor incoming@patchwork.ozlabs.org; Fri, 27 Oct 2017 06:49:00 -0400",
            "from eggs.gnu.org ([2001:4830:134:3::10]:57430)\n\tby lists.gnu.org with esmtp (Exim 4.71)\n\t(envelope-from <eblake@redhat.com>) id 1e824W-0001MT-73\n\tfor qemu-devel@nongnu.org; Fri, 27 Oct 2017 06:41:05 -0400",
            "from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)\n\t(envelope-from <eblake@redhat.com>) id 1e824T-0005ff-2N\n\tfor qemu-devel@nongnu.org; Fri, 27 Oct 2017 06:41:04 -0400",
            "from mx1.redhat.com ([209.132.183.28]:57458)\n\tby eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32)\n\t(Exim 4.71) (envelope-from <eblake@redhat.com>)\n\tid 1e824Q-0005c8-44; Fri, 27 Oct 2017 06:40:58 -0400",
            "from smtp.corp.redhat.com\n\t(int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16])\n\t(using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits))\n\t(No client certificate requested)\n\tby mx1.redhat.com (Postfix) with ESMTPS id 373D661462;\n\tFri, 27 Oct 2017 10:40:57 +0000 (UTC)",
            "from red.redhat.com (ovpn-120-166.rdu2.redhat.com [10.10.120.166])\n\tby smtp.corp.redhat.com (Postfix) with ESMTP id EC5A15C549;\n\tFri, 27 Oct 2017 10:40:55 +0000 (UTC)"
        ],
        "DMARC-Filter": "OpenDMARC Filter v1.3.2 mx1.redhat.com 373D661462",
        "From": "Eric Blake <eblake@redhat.com>",
        "To": "qemu-devel@nongnu.org",
        "Date": "Fri, 27 Oct 2017 12:40:33 +0200",
        "Message-Id": "<20171027104037.8319-9-eblake@redhat.com>",
        "In-Reply-To": "<20171027104037.8319-1-eblake@redhat.com>",
        "References": "<20171027104037.8319-1-eblake@redhat.com>",
        "X-Scanned-By": "MIMEDefang 2.79 on 10.5.11.16",
        "X-Greylist": "Sender IP whitelisted, not delayed by milter-greylist-4.5.16\n\t(mx1.redhat.com [10.5.110.39]);\n\tFri, 27 Oct 2017 10:40:57 +0000 (UTC)",
        "X-detected-operating-system": "by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic]\n\t[fuzzy]",
        "X-Received-From": "209.132.183.28",
        "Subject": "[Qemu-devel] [PATCH v6 08/12] nbd/server: Include human-readable\n\tmessage in structured errors",
        "X-BeenThere": "qemu-devel@nongnu.org",
        "X-Mailman-Version": "2.1.21",
        "Precedence": "list",
        "List-Id": "<qemu-devel.nongnu.org>",
        "List-Unsubscribe": "<https://lists.nongnu.org/mailman/options/qemu-devel>,\n\t<mailto:qemu-devel-request@nongnu.org?subject=unsubscribe>",
        "List-Archive": "<http://lists.nongnu.org/archive/html/qemu-devel/>",
        "List-Post": "<mailto:qemu-devel@nongnu.org>",
        "List-Help": "<mailto:qemu-devel-request@nongnu.org?subject=help>",
        "List-Subscribe": "<https://lists.nongnu.org/mailman/listinfo/qemu-devel>,\n\t<mailto:qemu-devel-request@nongnu.org?subject=subscribe>",
        "Cc": "pbonzini@redhat.com, vsementsov@virtuozzo.com, qemu-block@nongnu.org",
        "Errors-To": "qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org",
        "Sender": "\"Qemu-devel\"\n\t<qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org>"
    },
    "content": "The NBD spec permits including a human-readable error string if\nstructured replies are in force, so we might as well send the\nclient the message that we logged on any error.\n\nSigned-off-by: Eric Blake <eblake@redhat.com>\nReviewed-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>\n\n---\nv6: add R-b\nv5: allow NULL msg, cast away const for ease of use [Vladimir]; send\ncorrect length over the wire\n---\n nbd/server.c     | 20 +++++++++++++-------\n nbd/trace-events |  2 +-\n 2 files changed, 14 insertions(+), 8 deletions(-)",
    "diff": "diff --git a/nbd/server.c b/nbd/server.c\nindex 5d6d9a2ddd..ea9fe9970f 100644\n--- a/nbd/server.c\n+++ b/nbd/server.c\n@@ -1295,24 +1295,25 @@ static int coroutine_fn nbd_co_send_structured_read(NBDClient *client,\n static int coroutine_fn nbd_co_send_structured_error(NBDClient *client,\n                                                      uint64_t handle,\n                                                      uint32_t error,\n+                                                     const char *msg,\n                                                      Error **errp)\n {\n     NBDStructuredError chunk;\n     int nbd_err = system_errno_to_nbd_errno(error);\n     struct iovec iov[] = {\n         {.iov_base = &chunk, .iov_len = sizeof(chunk)},\n-        /* FIXME: Support human-readable error message */\n+        {.iov_base = (char *)msg, .iov_len = msg ? strlen(msg) : 0},\n     };\n\n     assert(nbd_err);\n     trace_nbd_co_send_structured_error(handle, nbd_err,\n-                                       nbd_err_lookup(nbd_err));\n+                                       nbd_err_lookup(nbd_err), msg ? msg : \"\");\n     set_be_chunk(&chunk.h, NBD_REPLY_FLAG_DONE, NBD_REPLY_TYPE_ERROR, handle,\n-                 sizeof(chunk) - sizeof(chunk.h));\n+                 sizeof(chunk) - sizeof(chunk.h) + iov[1].iov_len);\n     stl_be_p(&chunk.error, nbd_err);\n-    stw_be_p(&chunk.message_length, 0);\n+    stw_be_p(&chunk.message_length, iov[1].iov_len);\n\n-    return nbd_co_send_iov(client, iov, 1, errp);\n+    return nbd_co_send_iov(client, iov, 1 + !!iov[1].iov_len, errp);\n }\n\n /* nbd_co_receive_request\n@@ -1413,6 +1414,7 @@ static coroutine_fn void nbd_trip(void *opaque)\n     int flags;\n     int reply_data_len = 0;\n     Error *local_err = NULL;\n+    char *msg = NULL;\n\n     trace_nbd_trip();\n     if (client->closing) {\n@@ -1529,14 +1531,17 @@ reply:\n     if (local_err) {\n         /* If we get here, local_err was not a fatal error, and should be sent\n          * to the client. */\n+        assert(ret < 0);\n+        msg = g_strdup(error_get_pretty(local_err));\n         error_report_err(local_err);\n         local_err = NULL;\n     }\n\n-    if (client->structured_reply && request.type == NBD_CMD_READ) {\n+    if (client->structured_reply &&\n+        (ret < 0 || request.type == NBD_CMD_READ)) {\n         if (ret < 0) {\n             ret = nbd_co_send_structured_error(req->client, request.handle,\n-                                               -ret, &local_err);\n+                                               -ret, msg, &local_err);\n         } else {\n             ret = nbd_co_send_structured_read(req->client, request.handle,\n                                               request.from, req->data,\n@@ -1547,6 +1552,7 @@ reply:\n                                        ret < 0 ? -ret : 0,\n                                        req->data, reply_data_len, &local_err);\n     }\n+    g_free(msg);\n     if (ret < 0) {\n         error_prepend(&local_err, \"Failed to send reply: \");\n         goto disconnect;\ndiff --git a/nbd/trace-events b/nbd/trace-events\nindex 6894f8bbb4..52150bd738 100644\n--- a/nbd/trace-events\n+++ b/nbd/trace-events\n@@ -57,7 +57,7 @@ nbd_blk_aio_attached(const char *name, void *ctx) \"Export %s: Attaching clients\n nbd_blk_aio_detach(const char *name, void *ctx) \"Export %s: Detaching clients from AIO context %p\\n\"\n nbd_co_send_simple_reply(uint64_t handle, uint32_t error, const char *errname, int len) \"Send simple reply: handle = %\" PRIu64 \", error = %\" PRIu32 \" (%s), len = %d\"\n nbd_co_send_structured_read(uint64_t handle, uint64_t offset, void *data, size_t size) \"Send structured read data reply: handle = %\" PRIu64 \", offset = %\" PRIu64 \", data = %p, len = %zu\"\n-nbd_co_send_structured_error(uint64_t handle, int err, const char *errname) \"Send structured error reply: handle = %\" PRIu64 \", error = %d (%s)\"\n+nbd_co_send_structured_error(uint64_t handle, int err, const char *errname, const char *msg) \"Send structured error reply: handle = %\" PRIu64 \", error = %d (%s), msg = '%s'\"\n nbd_co_receive_request_decode_type(uint64_t handle, uint16_t type, const char *name) \"Decoding type: handle = %\" PRIu64 \", type = %\" PRIu16 \" (%s)\"\n nbd_co_receive_request_payload_received(uint64_t handle, uint32_t len) \"Payload received: handle = %\" PRIu64 \", len = %\" PRIu32\n nbd_co_receive_request_cmd_write(uint32_t len) \"Reading %\" PRIu32 \" byte(s)\"\n",
    "prefixes": [
        "v6",
        "08/12"
    ]
}