get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

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

{
    "id": 814153,
    "url": "http://patchwork.ozlabs.org/api/patches/814153/?format=api",
    "web_url": "http://patchwork.ozlabs.org/project/qemu-devel/patch/20170915084030.40988-11-aik@ozlabs.ru/",
    "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": "<20170915084030.40988-11-aik@ozlabs.ru>",
    "list_archive_url": null,
    "date": "2017-09-15T08:40:27",
    "name": "[qemu,v2,10/13] memory: Move root MR from AddressSpace to FlatView",
    "commit_ref": null,
    "pull_url": null,
    "state": "new",
    "archived": false,
    "hash": "0bfad50146d80c22738b23dce97f434860a62d3f",
    "submitter": {
        "id": 7621,
        "url": "http://patchwork.ozlabs.org/api/people/7621/?format=api",
        "name": "Alexey Kardashevskiy",
        "email": "aik@ozlabs.ru"
    },
    "delegate": null,
    "mbox": "http://patchwork.ozlabs.org/project/qemu-devel/patch/20170915084030.40988-11-aik@ozlabs.ru/mbox/",
    "series": [
        {
            "id": 3250,
            "url": "http://patchwork.ozlabs.org/api/series/3250/?format=api",
            "web_url": "http://patchwork.ozlabs.org/project/qemu-devel/list/?series=3250",
            "date": "2017-09-15T08:40:21",
            "name": "memory: Reduce memory use",
            "version": 2,
            "mbox": "http://patchwork.ozlabs.org/series/3250/mbox/"
        }
    ],
    "comments": "http://patchwork.ozlabs.org/api/patches/814153/comments/",
    "check": "pending",
    "checks": "http://patchwork.ozlabs.org/api/patches/814153/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>)",
        "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 3xtpqp0gYjz9s3w\n\tfor <incoming@patchwork.ozlabs.org>;\n\tFri, 15 Sep 2017 18:44:53 +1000 (AEST)",
            "from localhost ([::1]:51964 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 1dsmF1-0002jj-DC\n\tfor incoming@patchwork.ozlabs.org; Fri, 15 Sep 2017 04:44:51 -0400",
            "from eggs.gnu.org ([2001:4830:134:3::10]:38217)\n\tby lists.gnu.org with esmtp (Exim 4.71)\n\t(envelope-from <aik@ozlabs.ru>) id 1dsmB6-0006ye-Ia\n\tfor qemu-devel@nongnu.org; Fri, 15 Sep 2017 04:40:51 -0400",
            "from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)\n\t(envelope-from <aik@ozlabs.ru>) id 1dsmB5-0002XC-9F\n\tfor qemu-devel@nongnu.org; Fri, 15 Sep 2017 04:40:48 -0400",
            "from ozlabs.ru ([107.173.13.209]:44668)\n\tby eggs.gnu.org with esmtp (Exim 4.71)\n\t(envelope-from <aik@ozlabs.ru>) id 1dsmB4-0002Ql-Rx\n\tfor qemu-devel@nongnu.org; Fri, 15 Sep 2017 04:40:47 -0400",
            "from vpl1.ozlabs.ibm.com (localhost [IPv6:::1])\n\tby ozlabs.ru (Postfix) with ESMTP id 4F5003A60061;\n\tFri, 15 Sep 2017 04:42:00 -0400 (EDT)"
        ],
        "From": "Alexey Kardashevskiy <aik@ozlabs.ru>",
        "To": "qemu-devel@nongnu.org",
        "Date": "Fri, 15 Sep 2017 18:40:27 +1000",
        "Message-Id": "<20170915084030.40988-11-aik@ozlabs.ru>",
        "X-Mailer": "git-send-email 2.11.0",
        "In-Reply-To": "<20170915084030.40988-1-aik@ozlabs.ru>",
        "References": "<20170915084030.40988-1-aik@ozlabs.ru>",
        "X-detected-operating-system": "by eggs.gnu.org: GNU/Linux 3.x [fuzzy]",
        "X-Received-From": "107.173.13.209",
        "Subject": "[Qemu-devel] [PATCH qemu v2 10/13] memory: Move root MR from\n\tAddressSpace to FlatView",
        "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": "Alexey Kardashevskiy <aik@ozlabs.ru>, Paolo Bonzini <pbonzini@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": "Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>\n---\n include/exec/memory.h |  2 +-\n hw/pci/pci.c          |  3 ++-\n memory.c              | 30 ++++++++++++++++--------------\n 3 files changed, 19 insertions(+), 16 deletions(-)",
    "diff": "diff --git a/include/exec/memory.h b/include/exec/memory.h\nindex 7816e5d655..be8cc1ccd3 100644\n--- a/include/exec/memory.h\n+++ b/include/exec/memory.h\n@@ -308,7 +308,6 @@ struct AddressSpace {\n     /* All fields are private. */\n     struct rcu_head rcu;\n     char *name;\n-    MemoryRegion *root;\n     int ref_count;\n     bool malloced;\n \n@@ -322,6 +321,7 @@ struct AddressSpace {\n };\n \n FlatView *address_space_to_flatview(AddressSpace *as);\n+MemoryRegion *address_space_root(AddressSpace *as);\n \n /**\n  * MemoryRegionSection: describes a fragment of a #MemoryRegion\ndiff --git a/hw/pci/pci.c b/hw/pci/pci.c\nindex 353195d154..7bf82aac9f 100644\n--- a/hw/pci/pci.c\n+++ b/hw/pci/pci.c\n@@ -90,7 +90,8 @@ static void pci_init_bus_master(PCIDevice *pci_dev)\n \n     memory_region_init_alias(&pci_dev->bus_master_enable_region,\n                              OBJECT(pci_dev), \"bus master\",\n-                             dma_as->root, 0, memory_region_size(dma_as->root));\n+                             address_space_root(dma_as), 0,\n+                             memory_region_size(address_space_root(dma_as)));\n     memory_region_set_enabled(&pci_dev->bus_master_enable_region, false);\n     memory_region_add_subregion(&pci_dev->bus_master_container_region, 0,\n                                 &pci_dev->bus_master_enable_region);\ndiff --git a/memory.c b/memory.c\nindex 0651be49ac..29f8588945 100644\n--- a/memory.c\n+++ b/memory.c\n@@ -231,6 +231,7 @@ struct FlatView {\n     unsigned nr;\n     unsigned nr_allocated;\n     struct AddressSpaceDispatch *dispatch;\n+    MemoryRegion *root;\n };\n \n typedef struct AddressSpaceOps AddressSpaceOps;\n@@ -260,12 +261,14 @@ static bool flatrange_equal(FlatRange *a, FlatRange *b)\n         && a->readonly == b->readonly;\n }\n \n-static FlatView *flatview_alloc(void)\n+static FlatView *flatview_alloc(MemoryRegion *mr_root)\n {\n     FlatView *view;\n \n     view = g_new0(FlatView, 1);\n     view->ref = 1;\n+    view->root = mr_root;\n+    memory_region_ref(mr_root);\n \n     return view;\n }\n@@ -298,6 +301,7 @@ static void flatview_destroy(FlatView *view)\n         memory_region_unref(view->ranges[i].mr);\n     }\n     g_free(view->ranges);\n+    memory_region_unref(view->root);\n     g_free(view);\n }\n \n@@ -629,7 +633,7 @@ static AddressSpace *memory_region_to_address_space(MemoryRegion *mr)\n         mr = mr->container;\n     }\n     QTAILQ_FOREACH(as, &address_spaces, address_spaces_link) {\n-        if (mr == as->root) {\n+        if (mr == as->current_map->root) {\n             return as;\n         }\n     }\n@@ -728,7 +732,7 @@ static FlatView *generate_memory_topology(MemoryRegion *mr)\n {\n     FlatView *view;\n \n-    view = flatview_alloc();\n+    view = flatview_alloc(mr);\n \n     if (mr) {\n         render_memory_region(view, mr, int128_zero(),\n@@ -952,7 +956,7 @@ static void flatview_render_new(FlatView *old_view, FlatView *new_view)\n static void address_space_update_topology(AddressSpace *as)\n {\n     FlatView *old_view = address_space_get_flatview(as);\n-    FlatView *new_view = generate_memory_topology(as->root);\n+    FlatView *new_view = generate_memory_topology(old_view->root);\n \n     flatview_render_new(old_view, new_view);\n     address_space_update_topology_pass(as, old_view, new_view, false);\n@@ -2680,12 +2684,10 @@ void memory_region_invalidate_mmio_ptr(MemoryRegion *mr, hwaddr offset,\n \n void address_space_init(AddressSpace *as, MemoryRegion *root, const char *name)\n {\n-    memory_region_ref(root);\n     memory_region_transaction_begin();\n     as->ref_count = 1;\n-    as->root = root;\n     as->malloced = false;\n-    as->current_map = flatview_alloc();\n+    as->current_map = flatview_alloc(root);\n     as->ioeventfd_nb = 0;\n     as->ioeventfds = NULL;\n     QTAILQ_INIT(&as->listeners);\n@@ -2695,6 +2697,11 @@ void address_space_init(AddressSpace *as, MemoryRegion *root, const char *name)\n     memory_region_transaction_commit();\n }\n \n+MemoryRegion *address_space_root(AddressSpace *as)\n+{\n+    return as->current_map->root;\n+}\n+\n static void do_address_space_destroy(AddressSpace *as)\n {\n     bool do_free = as->malloced;\n@@ -2704,7 +2711,6 @@ static void do_address_space_destroy(AddressSpace *as)\n     flatview_unref(as->current_map);\n     g_free(as->name);\n     g_free(as->ioeventfds);\n-    memory_region_unref(as->root);\n     if (do_free) {\n         g_free(as);\n     }\n@@ -2715,7 +2721,7 @@ AddressSpace *address_space_init_shareable(MemoryRegion *root, const char *name)\n     AddressSpace *as;\n \n     QTAILQ_FOREACH(as, &address_spaces, address_spaces_link) {\n-        if (root == as->root && as->malloced) {\n+        if (root == address_space_root(as) && as->malloced) {\n             as->ref_count++;\n             return as;\n         }\n@@ -2729,15 +2735,12 @@ AddressSpace *address_space_init_shareable(MemoryRegion *root, const char *name)\n \n void address_space_destroy(AddressSpace *as)\n {\n-    MemoryRegion *root = as->root;\n-\n     as->ref_count--;\n     if (as->ref_count) {\n         return;\n     }\n     /* Flush out anything from MemoryListeners listening in on this */\n     memory_region_transaction_begin();\n-    as->root = NULL;\n     memory_region_transaction_commit();\n     QTAILQ_REMOVE(&address_spaces, as, address_spaces_link);\n \n@@ -2745,7 +2748,6 @@ void address_space_destroy(AddressSpace *as)\n      * entries that the guest should never use.  Wait for the old\n      * values to expire before freeing the data.\n      */\n-    as->root = root;\n     call_rcu(as, do_address_space_destroy, rcu);\n }\n \n@@ -2934,7 +2936,7 @@ void mtree_info(fprintf_function mon_printf, void *f, bool flatview)\n \n     QTAILQ_FOREACH(as, &address_spaces, address_spaces_link) {\n         mon_printf(f, \"address-space: %s\\n\", as->name);\n-        mtree_print_mr(mon_printf, f, as->root, 1, 0, &ml_head);\n+        mtree_print_mr(mon_printf, f, address_space_root(as), 1, 0, &ml_head);\n         mon_printf(f, \"\\n\");\n     }\n \n",
    "prefixes": [
        "qemu",
        "v2",
        "10/13"
    ]
}