get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

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

{
    "id": 818224,
    "url": "http://patchwork.ozlabs.org/api/patches/818224/?format=api",
    "web_url": "http://patchwork.ozlabs.org/project/qemu-devel/patch/20170925122808.14561-2-kwolf@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": "<20170925122808.14561-2-kwolf@redhat.com>",
    "list_archive_url": null,
    "date": "2017-09-25T12:28:04",
    "name": "[1/5] block: Introduce BdrvChildRole.update_filename",
    "commit_ref": null,
    "pull_url": null,
    "state": "new",
    "archived": false,
    "hash": "d9b1f95db9e48459c64bcec866a7039e29009da7",
    "submitter": {
        "id": 2714,
        "url": "http://patchwork.ozlabs.org/api/people/2714/?format=api",
        "name": "Kevin Wolf",
        "email": "kwolf@redhat.com"
    },
    "delegate": null,
    "mbox": "http://patchwork.ozlabs.org/project/qemu-devel/patch/20170925122808.14561-2-kwolf@redhat.com/mbox/",
    "series": [
        {
            "id": 4949,
            "url": "http://patchwork.ozlabs.org/api/series/4949/?format=api",
            "web_url": "http://patchwork.ozlabs.org/project/qemu-devel/list/?series=4949",
            "date": "2017-09-25T12:28:05",
            "name": "commit: Support multiple roots above top node",
            "version": 1,
            "mbox": "http://patchwork.ozlabs.org/series/4949/mbox/"
        }
    ],
    "comments": "http://patchwork.ozlabs.org/api/patches/818224/comments/",
    "check": "pending",
    "checks": "http://patchwork.ozlabs.org/api/patches/818224/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-mx09.extmail.prod.ext.phx2.redhat.com;\n\tdmarc=none (p=none dis=none) header.from=redhat.com",
            "ext-mx09.extmail.prod.ext.phx2.redhat.com;\n\tspf=fail smtp.mailfrom=kwolf@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 3y13NS4TT2z9tXD\n\tfor <incoming@patchwork.ozlabs.org>;\n\tMon, 25 Sep 2017 22:31:20 +1000 (AEST)",
            "from localhost ([::1]:42271 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 1dwSXe-0005jI-NB\n\tfor incoming@patchwork.ozlabs.org; Mon, 25 Sep 2017 08:31:18 -0400",
            "from eggs.gnu.org ([2001:4830:134:3::10]:47218)\n\tby lists.gnu.org with esmtp (Exim 4.71)\n\t(envelope-from <kwolf@redhat.com>) id 1dwSUn-0003VG-KQ\n\tfor qemu-devel@nongnu.org; Mon, 25 Sep 2017 08:28:22 -0400",
            "from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)\n\t(envelope-from <kwolf@redhat.com>) id 1dwSUm-000655-Iv\n\tfor qemu-devel@nongnu.org; Mon, 25 Sep 2017 08:28:21 -0400",
            "from mx1.redhat.com ([209.132.183.28]:59094)\n\tby eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32)\n\t(Exim 4.71) (envelope-from <kwolf@redhat.com>)\n\tid 1dwSUg-00061q-MX; Mon, 25 Sep 2017 08:28:14 -0400",
            "from smtp.corp.redhat.com\n\t(int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12])\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 B938B4ACA4;\n\tMon, 25 Sep 2017 12:28:13 +0000 (UTC)",
            "from localhost.localdomain.com (ovpn-116-119.ams2.redhat.com\n\t[10.36.116.119])\n\tby smtp.corp.redhat.com (Postfix) with ESMTP id 7D7E960E3E;\n\tMon, 25 Sep 2017 12:28:12 +0000 (UTC)"
        ],
        "DMARC-Filter": "OpenDMARC Filter v1.3.2 mx1.redhat.com B938B4ACA4",
        "From": "Kevin Wolf <kwolf@redhat.com>",
        "To": "qemu-block@nongnu.org",
        "Date": "Mon, 25 Sep 2017 14:28:04 +0200",
        "Message-Id": "<20170925122808.14561-2-kwolf@redhat.com>",
        "In-Reply-To": "<20170925122808.14561-1-kwolf@redhat.com>",
        "References": "<20170925122808.14561-1-kwolf@redhat.com>",
        "X-Scanned-By": "MIMEDefang 2.79 on 10.5.11.12",
        "X-Greylist": "Sender IP whitelisted, not delayed by milter-greylist-4.5.16\n\t(mx1.redhat.com [10.5.110.38]);\n\tMon, 25 Sep 2017 12:28:13 +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 1/5] block: Introduce\n\tBdrvChildRole.update_filename",
        "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": "kwolf@redhat.com, qemu-devel@nongnu.org, 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": "There is no good reason for bdrv_drop_intermediate() to know the active\nlayer above the subchain it is operating on - even more so, because\nthe assumption that there is a single active layer above it is not\ngenerally true.\n\nIn order to prepare removal of the active parameter, use a BdrvChildRole\ncallback to update the backing file string in the overlay image instead\nof directly calling bdrv_change_backing_file().\n\nSigned-off-by: Kevin Wolf <kwolf@redhat.com>\n---\n include/block/block_int.h |  6 ++++++\n block.c                   | 33 ++++++++++++++++++++++++++++-----\n 2 files changed, 34 insertions(+), 5 deletions(-)",
    "diff": "diff --git a/include/block/block_int.h b/include/block/block_int.h\nindex 99abe2ce74..e6d53cc15e 100644\n--- a/include/block/block_int.h\n+++ b/include/block/block_int.h\n@@ -544,6 +544,12 @@ struct BdrvChildRole {\n \n     void (*attach)(BdrvChild *child);\n     void (*detach)(BdrvChild *child);\n+\n+    /* Notifies the parent that the filename of its child has changed (e.g.\n+     * because the direct child was removed from the backing chain), so that it\n+     * can update its reference. */\n+    int (*update_filename)(BdrvChild *child, BlockDriverState *new_base,\n+                           const char *filename, Error **errp);\n };\n \n extern const BdrvChildRole child_file;\ndiff --git a/block.c b/block.c\nindex 5c65fac672..7ac8cd521b 100644\n--- a/block.c\n+++ b/block.c\n@@ -981,6 +981,21 @@ static void bdrv_backing_options(int *child_flags, QDict *child_options,\n     *child_flags = flags;\n }\n \n+static int bdrv_backing_update_filename(BdrvChild *c, BlockDriverState *base,\n+                                        const char *filename, Error **errp)\n+{\n+    BlockDriverState *parent = c->opaque;\n+    int ret;\n+\n+    ret = bdrv_change_backing_file(parent, filename,\n+                                   base->drv ? base->drv->format_name : \"\");\n+    if (ret < 0) {\n+        error_setg_errno(errp, ret, \"Could not update backing file link\");\n+    }\n+\n+    return ret;\n+}\n+\n const BdrvChildRole child_backing = {\n     .get_parent_desc = bdrv_child_get_parent_desc,\n     .attach          = bdrv_backing_attach,\n@@ -989,6 +1004,7 @@ const BdrvChildRole child_backing = {\n     .drained_begin   = bdrv_child_cb_drained_begin,\n     .drained_end     = bdrv_child_cb_drained_end,\n     .inactivate      = bdrv_child_cb_inactivate,\n+    .update_filename = bdrv_backing_update_filename,\n };\n \n static int bdrv_open_flags(BlockDriverState *bs, int flags)\n@@ -3470,6 +3486,8 @@ int bdrv_drop_intermediate(BlockDriverState *active, BlockDriverState *top,\n     Error *local_err = NULL;\n     int ret = -EIO;\n \n+    bdrv_ref(top);\n+\n     if (!top->drv || !base->drv) {\n         goto exit;\n     }\n@@ -3494,11 +3512,15 @@ int bdrv_drop_intermediate(BlockDriverState *active, BlockDriverState *top,\n     }\n \n     /* success - we can delete the intermediate states, and link top->base */\n-    backing_file_str = backing_file_str ? backing_file_str : base->filename;\n-    ret = bdrv_change_backing_file(new_top_bs, backing_file_str,\n-                                   base->drv ? base->drv->format_name : \"\");\n-    if (ret) {\n-        goto exit;\n+    if (new_top_bs->backing->role->update_filename) {\n+        backing_file_str = backing_file_str ? backing_file_str : base->filename;\n+        ret = new_top_bs->backing->role->update_filename(new_top_bs->backing,\n+                                                         base, backing_file_str,\n+                                                         &local_err);\n+        if (ret < 0) {\n+            bdrv_set_backing_hd(new_top_bs, top, &error_abort);\n+            goto exit;\n+        }\n     }\n \n     bdrv_set_backing_hd(new_top_bs, base, &local_err);\n@@ -3510,6 +3532,7 @@ int bdrv_drop_intermediate(BlockDriverState *active, BlockDriverState *top,\n \n     ret = 0;\n exit:\n+    bdrv_unref(top);\n     return ret;\n }\n \n",
    "prefixes": [
        "1/5"
    ]
}