get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

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

{
    "id": 813560,
    "url": "http://patchwork.ozlabs.org/api/patches/813560/?format=api",
    "web_url": "http://patchwork.ozlabs.org/project/qemu-devel/patch/20170913181910.29688-10-mreitz@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": "<20170913181910.29688-10-mreitz@redhat.com>",
    "list_archive_url": null,
    "date": "2017-09-13T18:19:01",
    "name": "[09/18] block: Generalize should_update_child() rule",
    "commit_ref": null,
    "pull_url": null,
    "state": "new",
    "archived": false,
    "hash": "5fe9a7209d8de9b636fd2d71fbccea1a9fdb8148",
    "submitter": {
        "id": 36836,
        "url": "http://patchwork.ozlabs.org/api/people/36836/?format=api",
        "name": "Max Reitz",
        "email": "mreitz@redhat.com"
    },
    "delegate": null,
    "mbox": "http://patchwork.ozlabs.org/project/qemu-devel/patch/20170913181910.29688-10-mreitz@redhat.com/mbox/",
    "series": [
        {
            "id": 2960,
            "url": "http://patchwork.ozlabs.org/api/series/2960/?format=api",
            "web_url": "http://patchwork.ozlabs.org/project/qemu-devel/list/?series=2960",
            "date": "2017-09-13T18:18:52",
            "name": "block/mirror: Add active-sync mirroring",
            "version": 1,
            "mbox": "http://patchwork.ozlabs.org/series/2960/mbox/"
        }
    ],
    "comments": "http://patchwork.ozlabs.org/api/patches/813560/comments/",
    "check": "pending",
    "checks": "http://patchwork.ozlabs.org/api/patches/813560/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=mreitz@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 3xsqnN3X3Sz9s7g\n\tfor <incoming@patchwork.ozlabs.org>;\n\tThu, 14 Sep 2017 04:24:24 +1000 (AEST)",
            "from localhost ([::1]:44012 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 1dsCKk-0002TY-I1\n\tfor incoming@patchwork.ozlabs.org; Wed, 13 Sep 2017 14:24:22 -0400",
            "from eggs.gnu.org ([2001:4830:134:3::10]:37057)\n\tby lists.gnu.org with esmtp (Exim 4.71)\n\t(envelope-from <mreitz@redhat.com>) id 1dsCHN-0000Ec-RD\n\tfor qemu-devel@nongnu.org; Wed, 13 Sep 2017 14:20:58 -0400",
            "from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)\n\t(envelope-from <mreitz@redhat.com>) id 1dsCHM-0005ZG-NR\n\tfor qemu-devel@nongnu.org; Wed, 13 Sep 2017 14:20:53 -0400",
            "from mx1.redhat.com ([209.132.183.28]:42704)\n\tby eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32)\n\t(Exim 4.71) (envelope-from <mreitz@redhat.com>)\n\tid 1dsCHC-0005RD-Jh; Wed, 13 Sep 2017 14:20:42 -0400",
            "from smtp.corp.redhat.com\n\t(int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13])\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 AF6934A6E0;\n\tWed, 13 Sep 2017 18:20:41 +0000 (UTC)",
            "from localhost (ovpn-204-23.brq.redhat.com [10.40.204.23])\n\tby smtp.corp.redhat.com (Postfix) with ESMTPS id 20C8460C17;\n\tWed, 13 Sep 2017 18:20:31 +0000 (UTC)"
        ],
        "DMARC-Filter": "OpenDMARC Filter v1.3.2 mx1.redhat.com AF6934A6E0",
        "From": "Max Reitz <mreitz@redhat.com>",
        "To": "qemu-block@nongnu.org",
        "Date": "Wed, 13 Sep 2017 20:19:01 +0200",
        "Message-Id": "<20170913181910.29688-10-mreitz@redhat.com>",
        "In-Reply-To": "<20170913181910.29688-1-mreitz@redhat.com>",
        "References": "<20170913181910.29688-1-mreitz@redhat.com>",
        "X-Scanned-By": "MIMEDefang 2.79 on 10.5.11.13",
        "X-Greylist": "Sender IP whitelisted, not delayed by milter-greylist-4.5.16\n\t(mx1.redhat.com [10.5.110.38]);\n\tWed, 13 Sep 2017 18:20:41 +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 09/18] block: Generalize should_update_child()\n\trule",
        "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>, Fam Zheng <famz@redhat.com>,\n\tqemu-devel@nongnu.org, Max Reitz <mreitz@redhat.com>,\n\tStefan Hajnoczi <stefanha@redhat.com>, John Snow <jsnow@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": "Currently, bdrv_replace_node() refuses to create loops from one BDS to\nitself if the BDS to be replaced is the backing node of the BDS to\nreplace it: Say there is a node A and a node B.  Replacing B by A means\nmaking all references to B point to A.  If B is a child of A (i.e. A has\na reference to B), that would mean we would have to make this reference\npoint to A itself -- so we'd create a loop.\n\nbdrv_replace_node() (through should_update_child()) refuses to do so if\nB is the backing node of A.  There is no reason why we should create\nloops if B is not the backing node of A, though.  The BDS graph should\nnever contain loops, so we should always refuse to create them.\n\nIf B is a child of A and B is to be replaced by A, we should simply\nleave B in place there because it is the most sensible choice.\n\nA more specific argument would be: Putting filter drivers into the BDS\ngraph is basically the same as appending an overlay to a backing chain.\nBut the main child BDS of a filter driver is not \"backing\" but \"file\",\nso restricting the no-loop rule to backing nodes would fail here.\n\nSigned-off-by: Max Reitz <mreitz@redhat.com>\n---\n include/block/block_int.h |  2 ++\n block.c                   | 44 ++++++++++++++++++++++++++++++++++----------\n 2 files changed, 36 insertions(+), 10 deletions(-)",
    "diff": "diff --git a/include/block/block_int.h b/include/block/block_int.h\nindex eaeaad9428..fa8bbf1f8b 100644\n--- a/include/block/block_int.h\n+++ b/include/block/block_int.h\n@@ -573,6 +573,8 @@ struct BdrvChild {\n     QLIST_ENTRY(BdrvChild) next_parent;\n };\n \n+typedef QLIST_HEAD(BdrvChildList, BdrvChild) BdrvChildList;\n+\n /*\n  * Note: the function bdrv_append() copies and swaps contents of\n  * BlockDriverStates, so if you add new fields to this struct, please\ndiff --git a/block.c b/block.c\nindex 0b55c5a41c..1898b958c9 100644\n--- a/block.c\n+++ b/block.c\n@@ -3134,16 +3134,39 @@ static bool should_update_child(BdrvChild *c, BlockDriverState *to)\n         return false;\n     }\n \n-    if (c->role == &child_backing) {\n-        /* If @from is a backing file of @to, ignore the child to avoid\n-         * creating a loop. We only want to change the pointer of other\n-         * parents. */\n-        QLIST_FOREACH(to_c, &to->children, next) {\n-            if (to_c == c) {\n-                break;\n-            }\n-        }\n-        if (to_c) {\n+    /* If the child @c belongs to the BDS @to, replacing the current\n+     * c->bs by @to would mean to create a loop.\n+     *\n+     * Such a case occurs when appending a BDS to a backing chain.\n+     * For instance, imagine the following chain:\n+     *\n+     *   guest device -> node A -> further backing chain...\n+     *\n+     * Now we create a new BDS B which we want to put on top of this\n+     * chain, so we first attach A as its backing node:\n+     *\n+     *                   node B\n+     *                     |\n+     *                     v\n+     *   guest device -> node A -> further backing chain...\n+     *\n+     * Finally we want to replace A by B.  When doing that, we want to\n+     * replace all pointers to A by pointers to B -- except for the\n+     * pointer from B because (1) that would create a loop, and (2)\n+     * that pointer should simply stay intact:\n+     *\n+     *   guest device -> node B\n+     *                     |\n+     *                     v\n+     *                   node A -> further backing chain...\n+     *\n+     * In general, when replacing a node A (c->bs) by a node B (@to),\n+     * if A is a child of B, that means we cannot replace A by B there\n+     * because that would create a loop.  Silently detaching A from B\n+     * is also not really an option.  So overall just leaving A in\n+     * place there is the most sensible choice. */\n+    QLIST_FOREACH(to_c, &to->children, next) {\n+        if (to_c == c) {\n             return false;\n         }\n     }\n@@ -3169,6 +3192,7 @@ void bdrv_replace_node(BlockDriverState *from, BlockDriverState *to,\n \n     /* Put all parents into @list and calculate their cumulative permissions */\n     QLIST_FOREACH_SAFE(c, &from->parents, next_parent, next) {\n+        assert(c->bs == from);\n         if (!should_update_child(c, to)) {\n             continue;\n         }\n",
    "prefixes": [
        "09/18"
    ]
}