get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

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

{
    "id": 813098,
    "url": "http://patchwork.ozlabs.org/api/patches/813098/?format=api",
    "web_url": "http://patchwork.ozlabs.org/project/qemu-devel/patch/150525325219.15988.2418594999948440514.stgit@frigg.lan/",
    "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": "<150525325219.15988.2418594999948440514.stgit@frigg.lan>",
    "list_archive_url": null,
    "date": "2017-09-12T21:54:12",
    "name": "[v5,13/22] instrument: Support synchronous modification of vCPU state",
    "commit_ref": null,
    "pull_url": null,
    "state": "new",
    "archived": false,
    "hash": "27d23aa8069ecbc4db3992273663a5366cfe7086",
    "submitter": {
        "id": 9099,
        "url": "http://patchwork.ozlabs.org/api/people/9099/?format=api",
        "name": "Lluís Vilanova",
        "email": "vilanova@ac.upc.edu"
    },
    "delegate": null,
    "mbox": "http://patchwork.ozlabs.org/project/qemu-devel/patch/150525325219.15988.2418594999948440514.stgit@frigg.lan/mbox/",
    "series": [
        {
            "id": 2775,
            "url": "http://patchwork.ozlabs.org/api/series/2775/?format=api",
            "web_url": "http://patchwork.ozlabs.org/project/qemu-devel/list/?series=2775",
            "date": "2017-09-12T21:01:42",
            "name": "instrument: Add basic event instrumentation",
            "version": 5,
            "mbox": "http://patchwork.ozlabs.org/series/2775/mbox/"
        }
    ],
    "comments": "http://patchwork.ozlabs.org/api/patches/813098/comments/",
    "check": "pending",
    "checks": "http://patchwork.ozlabs.org/api/patches/813098/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 3xsJVc2mbcz9t33\n\tfor <incoming@patchwork.ozlabs.org>;\n\tWed, 13 Sep 2017 07:54:48 +1000 (AEST)",
            "from localhost ([::1]:38826 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 1drt8o-0000CW-Hw\n\tfor incoming@patchwork.ozlabs.org; Tue, 12 Sep 2017 17:54:46 -0400",
            "from eggs.gnu.org ([2001:4830:134:3::10]:53775)\n\tby lists.gnu.org with esmtp (Exim 4.71)\n\t(envelope-from <vilanova@ac.upc.edu>) id 1drt8U-0000CL-N6\n\tfor qemu-devel@nongnu.org; Tue, 12 Sep 2017 17:54:27 -0400",
            "from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)\n\t(envelope-from <vilanova@ac.upc.edu>) id 1drt8R-0003Px-9n\n\tfor qemu-devel@nongnu.org; Tue, 12 Sep 2017 17:54:26 -0400",
            "from roura.ac.upc.es ([147.83.33.10]:39968)\n\tby eggs.gnu.org with esmtp (Exim 4.71)\n\t(envelope-from <vilanova@ac.upc.edu>) id 1drt8Q-0003Pl-Tj\n\tfor qemu-devel@nongnu.org; Tue, 12 Sep 2017 17:54:23 -0400",
            "from correu-1.ac.upc.es (correu-1.ac.upc.es [147.83.30.91])\n\tby roura.ac.upc.es (8.13.8/8.13.8) with ESMTP id v8CLsJVn022898;\n\tTue, 12 Sep 2017 23:54:19 +0200",
            "from localhost (unknown [31.210.187.58])\n\tby correu-1.ac.upc.es (Postfix) with ESMTPSA id 94F592EB;\n\tTue, 12 Sep 2017 23:54:13 +0200 (CEST)"
        ],
        "From": "=?utf-8?b?TGx1w61z?= Vilanova <vilanova@ac.upc.edu>",
        "To": "qemu-devel@nongnu.org",
        "Date": "Wed, 13 Sep 2017 00:54:12 +0300",
        "Message-Id": "<150525325219.15988.2418594999948440514.stgit@frigg.lan>",
        "X-Mailer": "git-send-email 2.14.1",
        "In-Reply-To": "<150525010239.15988.8172586618197849619.stgit@frigg.lan>",
        "References": "<150525010239.15988.8172586618197849619.stgit@frigg.lan>",
        "User-Agent": "StGit/0.18",
        "MIME-Version": "1.0",
        "Content-Type": "text/plain; charset=\"utf-8\"",
        "Content-Transfer-Encoding": "quoted-printable",
        "X-MIME-Autoconverted": "from 8bit to quoted-printable by roura.ac.upc.es id\n\tv8CLsJVn022898",
        "X-detected-operating-system": "by eggs.gnu.org: GNU/Linux 2.6.x [fuzzy]",
        "X-Received-From": "147.83.33.10",
        "Subject": "[Qemu-devel] [PATCH v5 13/22] instrument: Support synchronous\n\tmodification of vCPU state",
        "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": "\"Emilio G. Cota\" <cota@braap.org>, Markus Armbruster <armbru@redhat.com>,\n\tStefan Hajnoczi <stefanha@redhat.com>, =?utf-8?q?Llu=C3=ADs_Vilanova?=\n\t<vilanova@ac.upc.edu>",
        "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": "Stops all vCPUs to allow performing management operations like TB\ninvalidations. These are later necessary to ensure translated code does not\nreference unloaded instrumentation libraries.\n\nSigned-off-by: Lluís Vilanova <vilanova@ac.upc.edu>\n---\n instrument/control.c     |   66 ++++++++++++++++++++++++++++++++++++++++++++++\n instrument/control.h     |   26 ++++++++++++++++++\n instrument/control.inc.h |   11 ++++++++\n 3 files changed, 103 insertions(+)",
    "diff": "diff --git a/instrument/control.c b/instrument/control.c\nindex c4b3ca0440..20ddffdc28 100644\n--- a/instrument/control.c\n+++ b/instrument/control.c\n@@ -13,6 +13,7 @@\n #include \"instrument/load.h\"\n #include \"instrument/qemu-instr/control.h\"\n #include \"qemu/compiler.h\"\n+#include \"qemu/main-loop.h\"\n #include \"qom/cpu.h\"\n \n \n@@ -40,6 +41,71 @@ void instr_cpu_remove(CPUState *vcpu)\n }\n \n \n+static void instr_cpu_stop_all__cb(CPUState *cpu, run_on_cpu_data data)\n+{\n+    InstrCPUStop *info = data.host_ptr;\n+    /* run posted function */\n+    if (info->fun) {\n+        info->fun(cpu, info->data);\n+    }\n+#if !defined(CONFIG_USER_ONLY)\n+    /* signal we're out of the main vCPU loop */\n+    unsigned int count = atomic_load_acquire(&info->count);\n+    atomic_store_release(&info->count, count + 1);\n+    atomic_store_release(&info->stopped, true);\n+    /* wait until we're good to go again */\n+    qemu_cond_wait(&info->cond, &info->mutex);\n+    count = atomic_load_acquire(&info->count);\n+    atomic_store_release(&info->count, count - 1);\n+    qemu_mutex_unlock(&info->mutex);\n+#endif\n+}\n+\n+void instr_cpu_stop_all_begin(InstrCPUStop *info,\n+                              instr_cpu_stop_fun fun, void *data)\n+{\n+    CPUState *cpu;\n+\n+    info->fun = fun;\n+    info->data = data;\n+\n+#if !defined(CONFIG_USER_ONLY)\n+    info->count = 0;\n+    qemu_cond_init(&info->cond);\n+    qemu_mutex_init(&info->mutex);\n+\n+    /* main dispatch loop and run_on_cpu() lock the BQL */\n+    qemu_mutex_unlock_iothread();\n+#endif\n+\n+    CPU_FOREACH(cpu) {\n+#if !defined(CONFIG_USER_ONLY)\n+        atomic_store_release(&info->stopped, false);\n+        qemu_mutex_lock(&info->mutex);\n+        async_run_on_cpu(cpu, instr_cpu_stop_all__cb, RUN_ON_CPU_HOST_PTR(info));\n+        while (!atomic_load_acquire(&info->stopped)) {\n+            /* wait for vCPU to signal it's stopped */\n+        }\n+#else\n+        instr_cpu_stop_all__cb(cpu, RUN_ON_CPU_HOST_PTR(info));\n+#endif\n+    }\n+}\n+\n+void instr_cpu_stop_all_end(InstrCPUStop *info)\n+{\n+#if !defined(CONFIG_USER_ONLY)\n+    qemu_cond_broadcast(&info->cond);\n+    while (atomic_load_acquire(&info->count)) {\n+        /* wait for all vCPUs to continue before we can destroy info */\n+    }\n+    qemu_cond_destroy(&info->cond);\n+    qemu_mutex_destroy(&info->mutex);\n+    qemu_mutex_lock_iothread();\n+#endif\n+}\n+\n+\n qi_fini_fn instr_event__fini_fn;\n void *instr_event__fini_data;\n \ndiff --git a/instrument/control.h b/instrument/control.h\nindex 57cea07fa7..03e87b2b8f 100644\n--- a/instrument/control.h\n+++ b/instrument/control.h\n@@ -46,6 +46,32 @@ static inline QICPU instr_cpu_to_qicpu(CPUState *vcpu);\n  */\n static inline CPUState *instr_cpu_from_qicpu(QICPU vcpu);\n \n+typedef struct InstrCPUStop InstrCPUStop;\n+typedef void (*instr_cpu_stop_fun)(CPUState *cpu, void *data);\n+\n+/**\n+ * instr_cpu_stop_all_begin:\n+ * @info: Opaque structure describing the operation.\n+ * @fun: Function to run on the context of each vCPU once stopped.\n+ * @data: Pointer to pass to @fun.\n+ *\n+ * Ensure all vCPUs stop executing guest code, and execute @fun on their context\n+ * in turn. Returns with all vCPUs still stopped.\n+ *\n+ * Assumes cpu_list_lock() and that the QBL is locked before calling.\n+ */\n+void instr_cpu_stop_all_begin(InstrCPUStop *info,\n+                              instr_cpu_stop_fun fun, void *data);\n+\n+/**\n+ * instr_cpu_stop_all_end:\n+ * @info: Opaque structure passed to a previous instr_cpu_stop_all_begin()\n+ *     call.\n+ *\n+ * Resume execution on all vCPUs stopped by instr_cpu_stop_all_begin().\n+ */\n+void instr_cpu_stop_all_end(InstrCPUStop *info);\n+\n \n /**\n  * InstrState:\ndiff --git a/instrument/control.inc.h b/instrument/control.inc.h\nindex 45daae7d1d..6d65b23ead 100644\n--- a/instrument/control.inc.h\n+++ b/instrument/control.inc.h\n@@ -15,6 +15,17 @@\n #include <stdint.h>\n \n \n+struct InstrCPUStop {\n+    instr_cpu_stop_fun fun;\n+    void *data;\n+#if !defined(CONFIG_USER_ONLY)\n+    bool stopped;\n+    unsigned int count;\n+    QemuCond cond;\n+    QemuMutex mutex;\n+#endif\n+};\n+\n extern unsigned int instr_cpus_count;\n extern CPUState **instr_cpus;\n \n",
    "prefixes": [
        "v5",
        "13/22"
    ]
}