get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

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

{
    "id": 985230,
    "url": "http://patchwork.ozlabs.org/api/patches/985230/?format=api",
    "web_url": "http://patchwork.ozlabs.org/project/qemu-devel/patch/20181017082702.5581-34-armbru@redhat.com/",
    "project": {
        "id": 14,
        "url": "http://patchwork.ozlabs.org/api/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": "<20181017082702.5581-34-armbru@redhat.com>",
    "list_archive_url": null,
    "date": "2018-10-17T08:26:57",
    "name": "[v4,33/38] blockdev: Convert drive_new() to Error",
    "commit_ref": null,
    "pull_url": null,
    "state": "new",
    "archived": false,
    "hash": "1075bac2fd0b0ef925d237090f9a0129ab512163",
    "submitter": {
        "id": 2645,
        "url": "http://patchwork.ozlabs.org/api/people/2645/?format=api",
        "name": "Markus Armbruster",
        "email": "armbru@redhat.com"
    },
    "delegate": null,
    "mbox": "http://patchwork.ozlabs.org/project/qemu-devel/patch/20181017082702.5581-34-armbru@redhat.com/mbox/",
    "series": [
        {
            "id": 71196,
            "url": "http://patchwork.ozlabs.org/api/series/71196/?format=api",
            "web_url": "http://patchwork.ozlabs.org/project/qemu-devel/list/?series=71196",
            "date": "2018-10-17T08:26:36",
            "name": "Replace some unwise uses of error_report() & friends",
            "version": 4,
            "mbox": "http://patchwork.ozlabs.org/series/71196/mbox/"
        }
    ],
    "comments": "http://patchwork.ozlabs.org/api/patches/985230/comments/",
    "check": "pending",
    "checks": "http://patchwork.ozlabs.org/api/patches/985230/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>)",
            "ozlabs.org;\n\tdmarc=fail (p=none dis=none) header.from=redhat.com"
        ],
        "Received": [
            "from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11])\n\t(using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits))\n\t(No client certificate requested)\n\tby ozlabs.org (Postfix) with ESMTPS id 42Zm0H1sdVz9s1x\n\tfor <incoming@patchwork.ozlabs.org>;\n\tWed, 17 Oct 2018 19:42:55 +1100 (AEDT)",
            "from localhost ([::1]:34576 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 1gChPo-0004Jm-6a\n\tfor incoming@patchwork.ozlabs.org; Wed, 17 Oct 2018 04:42:52 -0400",
            "from eggs.gnu.org ([2001:4830:134:3::10]:51279)\n\tby lists.gnu.org with esmtp (Exim 4.71)\n\t(envelope-from <armbru@redhat.com>) id 1gChAu-0008My-CB\n\tfor qemu-devel@nongnu.org; Wed, 17 Oct 2018 04:27:29 -0400",
            "from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)\n\t(envelope-from <armbru@redhat.com>) id 1gChAl-0001PN-Ez\n\tfor qemu-devel@nongnu.org; Wed, 17 Oct 2018 04:27:23 -0400",
            "from mx1.redhat.com ([209.132.183.28]:56230)\n\tby eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32)\n\t(Exim 4.71) (envelope-from <armbru@redhat.com>) id 1gChAd-00016p-Se\n\tfor qemu-devel@nongnu.org; Wed, 17 Oct 2018 04:27:14 -0400",
            "from smtp.corp.redhat.com\n\t(int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15])\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 5DFD0317C40B\n\tfor <qemu-devel@nongnu.org>; Wed, 17 Oct 2018 08:27:10 +0000 (UTC)",
            "from blackfin.pond.sub.org (ovpn-116-50.ams2.redhat.com\n\t[10.36.116.50])\n\tby smtp.corp.redhat.com (Postfix) with ESMTPS id EAEF618763;\n\tWed, 17 Oct 2018 08:27:09 +0000 (UTC)",
            "by blackfin.pond.sub.org (Postfix, from userid 1000)\n\tid 8C233110E7DC; Wed, 17 Oct 2018 10:27:02 +0200 (CEST)"
        ],
        "From": "Markus Armbruster <armbru@redhat.com>",
        "To": "qemu-devel@nongnu.org",
        "Date": "Wed, 17 Oct 2018 10:26:57 +0200",
        "Message-Id": "<20181017082702.5581-34-armbru@redhat.com>",
        "In-Reply-To": "<20181017082702.5581-1-armbru@redhat.com>",
        "References": "<20181017082702.5581-1-armbru@redhat.com>",
        "MIME-Version": "1.0",
        "Content-Type": "text/plain; charset=UTF-8",
        "X-Scanned-By": "MIMEDefang 2.79 on 10.5.11.15",
        "X-Greylist": "Sender IP whitelisted, not delayed by milter-greylist-4.5.16\n\t(mx1.redhat.com [10.5.110.41]);\n\tWed, 17 Oct 2018 08:27:10 +0000 (UTC)",
        "Content-Transfer-Encoding": "quoted-printable",
        "X-detected-operating-system": "by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic]",
        "X-Received-From": "209.132.183.28",
        "Subject": "[Qemu-devel] [PATCH v4 33/38] blockdev: Convert drive_new() to Error",
        "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": "Kevin Wolf <kwolf@redhat.com>, Max Reitz <mreitz@redhat.com>",
        "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": "Calling error_report() from within a function that takes an Error **\nargument is suspicious.  drive_new() calls error_report() even though\nit can run within drive_init_func(), which takes an Error ** argument.\ndrive_init_func()'s caller main(), via qemu_opts_foreach(), is fine\nwith it, but clean it up anyway:\n\n* Convert drive_new() to Error\n\n* Update add_init_drive() to report the error received from\n  drive_new()\n\n* Make main() pass &error_fatal through qemu_opts_foreach(),\n  drive_init_func() to drive_new()\n\n* Make default_drive() pass &error_abort through qemu_opts_foreach(),\n  drive_init_func() to drive_new()\n\nCc: Kevin Wolf <kwolf@redhat.com>\nCc: Max Reitz <mreitz@redhat.com>\nSigned-off-by: Markus Armbruster <armbru@redhat.com>\nReviewed-by: Eric Blake <eblake@redhat.com>\nReviewed-by: Max Reitz <mreitz@redhat.com>\nReviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>\n---\n blockdev.c                | 27 ++++++++++++++-------------\n device-hotplug.c          |  5 ++++-\n include/sysemu/blockdev.h |  3 ++-\n vl.c                      |  8 ++++----\n 4 files changed, 24 insertions(+), 19 deletions(-)",
    "diff": "diff --git a/blockdev.c b/blockdev.c\nindex a8755bd908..574adbcb7f 100644\n--- a/blockdev.c\n+++ b/blockdev.c\n@@ -759,7 +759,8 @@ QemuOptsList qemu_legacy_drive_opts = {\n     },\n };\n \n-DriveInfo *drive_new(QemuOpts *all_opts, BlockInterfaceType block_default_type)\n+DriveInfo *drive_new(QemuOpts *all_opts, BlockInterfaceType block_default_type,\n+                     Error **errp)\n {\n     const char *value;\n     BlockBackend *blk;\n@@ -808,7 +809,7 @@ DriveInfo *drive_new(QemuOpts *all_opts, BlockInterfaceType block_default_type)\n         qemu_opt_rename(all_opts, opt_renames[i].from, opt_renames[i].to,\n                         &local_err);\n         if (local_err) {\n-            error_report_err(local_err);\n+            error_propagate(errp, local_err);\n             return NULL;\n         }\n     }\n@@ -819,7 +820,7 @@ DriveInfo *drive_new(QemuOpts *all_opts, BlockInterfaceType block_default_type)\n         bool writethrough;\n \n         if (bdrv_parse_cache_mode(value, &flags, &writethrough) != 0) {\n-            error_report(\"invalid cache option\");\n+            error_setg(errp, \"invalid cache option\");\n             return NULL;\n         }\n \n@@ -847,7 +848,7 @@ DriveInfo *drive_new(QemuOpts *all_opts, BlockInterfaceType block_default_type)\n                                    &error_abort);\n     qemu_opts_absorb_qdict(legacy_opts, bs_opts, &local_err);\n     if (local_err) {\n-        error_report_err(local_err);\n+        error_propagate(errp, local_err);\n         goto fail;\n     }\n \n@@ -860,7 +861,7 @@ DriveInfo *drive_new(QemuOpts *all_opts, BlockInterfaceType block_default_type)\n             media = MEDIA_CDROM;\n             read_only = true;\n         } else {\n-            error_report(\"'%s' invalid media\", value);\n+            error_setg(errp, \"'%s' invalid media\", value);\n             goto fail;\n         }\n     }\n@@ -885,7 +886,7 @@ DriveInfo *drive_new(QemuOpts *all_opts, BlockInterfaceType block_default_type)\n              type++) {\n         }\n         if (type == IF_COUNT) {\n-            error_report(\"unsupported bus type '%s'\", value);\n+            error_setg(errp, \"unsupported bus type '%s'\", value);\n             goto fail;\n         }\n     } else {\n@@ -902,7 +903,7 @@ DriveInfo *drive_new(QemuOpts *all_opts, BlockInterfaceType block_default_type)\n \n     if (index != -1) {\n         if (bus_id != 0 || unit_id != -1) {\n-            error_report(\"index cannot be used with bus and unit\");\n+            error_setg(errp, \"index cannot be used with bus and unit\");\n             goto fail;\n         }\n         bus_id = drive_index_to_bus_id(type, index);\n@@ -921,13 +922,13 @@ DriveInfo *drive_new(QemuOpts *all_opts, BlockInterfaceType block_default_type)\n     }\n \n     if (max_devs && unit_id >= max_devs) {\n-        error_report(\"unit %d too big (max is %d)\", unit_id, max_devs - 1);\n+        error_setg(errp, \"unit %d too big (max is %d)\", unit_id, max_devs - 1);\n         goto fail;\n     }\n \n     if (drive_get(type, bus_id, unit_id) != NULL) {\n-        error_report(\"drive with bus=%d, unit=%d (index=%d) exists\",\n-                     bus_id, unit_id, index);\n+        error_setg(errp, \"drive with bus=%d, unit=%d (index=%d) exists\",\n+                   bus_id, unit_id, index);\n         goto fail;\n     }\n \n@@ -970,7 +971,7 @@ DriveInfo *drive_new(QemuOpts *all_opts, BlockInterfaceType block_default_type)\n     if (werror != NULL) {\n         if (type != IF_IDE && type != IF_SCSI && type != IF_VIRTIO &&\n             type != IF_NONE) {\n-            error_report(\"werror is not supported by this bus type\");\n+            error_setg(errp, \"werror is not supported by this bus type\");\n             goto fail;\n         }\n         qdict_put_str(bs_opts, \"werror\", werror);\n@@ -980,7 +981,7 @@ DriveInfo *drive_new(QemuOpts *all_opts, BlockInterfaceType block_default_type)\n     if (rerror != NULL) {\n         if (type != IF_IDE && type != IF_VIRTIO && type != IF_SCSI &&\n             type != IF_NONE) {\n-            error_report(\"rerror is not supported by this bus type\");\n+            error_setg(errp, \"rerror is not supported by this bus type\");\n             goto fail;\n         }\n         qdict_put_str(bs_opts, \"rerror\", rerror);\n@@ -991,7 +992,7 @@ DriveInfo *drive_new(QemuOpts *all_opts, BlockInterfaceType block_default_type)\n     bs_opts = NULL;\n     if (!blk) {\n         if (local_err) {\n-            error_report_err(local_err);\n+            error_propagate(errp, local_err);\n         }\n         goto fail;\n     } else {\ndiff --git a/device-hotplug.c b/device-hotplug.c\nindex cd427e2c76..6090d5f1e9 100644\n--- a/device-hotplug.c\n+++ b/device-hotplug.c\n@@ -28,6 +28,7 @@\n #include \"sysemu/block-backend.h\"\n #include \"sysemu/blockdev.h\"\n #include \"qapi/qmp/qdict.h\"\n+#include \"qapi/error.h\"\n #include \"qemu/config-file.h\"\n #include \"qemu/option.h\"\n #include \"sysemu/sysemu.h\"\n@@ -36,6 +37,7 @@\n \n static DriveInfo *add_init_drive(const char *optstr)\n {\n+    Error *err = NULL;\n     DriveInfo *dinfo;\n     QemuOpts *opts;\n     MachineClass *mc;\n@@ -45,8 +47,9 @@ static DriveInfo *add_init_drive(const char *optstr)\n         return NULL;\n \n     mc = MACHINE_GET_CLASS(current_machine);\n-    dinfo = drive_new(opts, mc->block_default_type);\n+    dinfo = drive_new(opts, mc->block_default_type, &err);\n     if (!dinfo) {\n+        error_report_err(err);\n         qemu_opts_del(opts);\n         return NULL;\n     }\ndiff --git a/include/sysemu/blockdev.h b/include/sysemu/blockdev.h\nindex 24954b94e0..d34c4920dc 100644\n--- a/include/sysemu/blockdev.h\n+++ b/include/sysemu/blockdev.h\n@@ -54,7 +54,8 @@ DriveInfo *drive_get_next(BlockInterfaceType type);\n QemuOpts *drive_def(const char *optstr);\n QemuOpts *drive_add(BlockInterfaceType type, int index, const char *file,\n                     const char *optstr);\n-DriveInfo *drive_new(QemuOpts *arg, BlockInterfaceType block_default_type);\n+DriveInfo *drive_new(QemuOpts *arg, BlockInterfaceType block_default_type,\n+                     Error **errp);\n \n /* device-hotplug */\n \ndiff --git a/vl.c b/vl.c\nindex 65366b961e..22beca29d1 100644\n--- a/vl.c\n+++ b/vl.c\n@@ -1129,7 +1129,7 @@ static int drive_init_func(void *opaque, QemuOpts *opts, Error **errp)\n {\n     BlockInterfaceType *block_default_type = opaque;\n \n-    return drive_new(opts, *block_default_type) == NULL;\n+    return drive_new(opts, *block_default_type, errp) == NULL;\n }\n \n static int drive_enable_snapshot(void *opaque, QemuOpts *opts, Error **errp)\n@@ -1155,8 +1155,7 @@ static void default_drive(int enable, int snapshot, BlockInterfaceType type,\n         drive_enable_snapshot(NULL, opts, NULL);\n     }\n \n-    dinfo = drive_new(opts, type);\n-    assert(dinfo);\n+    dinfo = drive_new(opts, type, &error_abort);\n     dinfo->is_default = true;\n \n }\n@@ -4396,7 +4395,8 @@ int main(int argc, char **argv, char **envp)\n                           NULL, NULL);\n     }\n     if (qemu_opts_foreach(qemu_find_opts(\"drive\"), drive_init_func,\n-                          &machine_class->block_default_type, NULL)) {\n+                          &machine_class->block_default_type, &error_fatal)) {\n+        /* We printed help */\n         exit(1);\n     }\n \n",
    "prefixes": [
        "v4",
        "33/38"
    ]
}