Patch Detail
get:
Show a patch.
patch:
Update a patch.
put:
Update a patch.
GET /api/patches/813101/?format=api
{ "id": 813101, "url": "http://patchwork.ozlabs.org/api/patches/813101/?format=api", "web_url": "http://patchwork.ozlabs.org/project/qemu-devel/patch/150525373641.15988.12142967916976724761.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": "<150525373641.15988.12142967916976724761.stgit@frigg.lan>", "list_archive_url": null, "date": "2017-09-12T22:02:16", "name": "[v5,15/22] instrument: Add event 'guest_cpu_exit'", "commit_ref": null, "pull_url": null, "state": "new", "archived": false, "hash": "89d4dfa566eb1bab44157715be4c33f7d8a02377", "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/150525373641.15988.12142967916976724761.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/813101/comments/", "check": "pending", "checks": "http://patchwork.ozlabs.org/api/patches/813101/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 3xsJgx5lnjz9s4q\n\tfor <incoming@patchwork.ozlabs.org>;\n\tWed, 13 Sep 2017 08:02:53 +1000 (AEST)", "from localhost ([::1]:38874 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 1drtGd-00055s-W0\n\tfor incoming@patchwork.ozlabs.org; Tue, 12 Sep 2017 18:02:52 -0400", "from eggs.gnu.org ([2001:4830:134:3::10]:58949)\n\tby lists.gnu.org with esmtp (Exim 4.71)\n\t(envelope-from <vilanova@ac.upc.edu>) id 1drtGI-00055S-VY\n\tfor qemu-devel@nongnu.org; Tue, 12 Sep 2017 18:02:32 -0400", "from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)\n\t(envelope-from <vilanova@ac.upc.edu>) id 1drtGG-0000Iu-6H\n\tfor qemu-devel@nongnu.org; Tue, 12 Sep 2017 18:02:31 -0400", "from roura.ac.upc.es ([147.83.33.10]:43378)\n\tby eggs.gnu.org with esmtp (Exim 4.71)\n\t(envelope-from <vilanova@ac.upc.edu>) id 1drtGF-0000I2-NR\n\tfor qemu-devel@nongnu.org; Tue, 12 Sep 2017 18:02:28 -0400", "from correu-2.ac.upc.es (correu-2.ac.upc.es [147.83.30.92])\n\tby roura.ac.upc.es (8.13.8/8.13.8) with ESMTP id v8CM2NdL023099;\n\tWed, 13 Sep 2017 00:02:23 +0200", "from localhost (unknown [31.210.187.58])\n\tby correu-2.ac.upc.es (Postfix) with ESMTPSA id F051E840;\n\tWed, 13 Sep 2017 00:02:17 +0200 (CEST)" ], "From": "=?utf-8?b?TGx1w61z?= Vilanova <vilanova@ac.upc.edu>", "To": "qemu-devel@nongnu.org", "Date": "Wed, 13 Sep 2017 01:02:16 +0300", "Message-Id": "<150525373641.15988.12142967916976724761.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\tv8CM2NdL023099", "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 15/22] instrument: Add event 'guest_cpu_exit'", "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": "Markus Armbruster <armbru@redhat.com>, \"Emilio G. Cota\" <cota@braap.org>,\n\tStefan Hajnoczi <stefanha@redhat.com>,\n\tPaolo Bonzini <pbonzini@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": "Signed-off-by: Lluís Vilanova <vilanova@ac.upc.edu>\n---\n instrument/control.c | 9 +++++++++\n instrument/events.h | 3 +++\n instrument/events.inc.h | 11 +++++++++++\n instrument/load.c | 17 +++++++++++++++++\n instrument/qemu-instr/control.h | 11 +++++++++++\n stubs/instrument.c | 1 +\n trace/control.c | 4 +++-\n 7 files changed, 55 insertions(+), 1 deletion(-)", "diff": "diff --git a/instrument/control.c b/instrument/control.c\nindex 20ddffdc28..0be8065409 100644\n--- a/instrument/control.c\n+++ b/instrument/control.c\n@@ -124,3 +124,12 @@ SYM_PUBLIC void qi_event_set_guest_cpu_enter(void (*fn)(QICPU vcpu))\n ERROR_IF(!instr_get_state(), \"called outside instrumentation\");\n instr_set_event(guest_cpu_enter, fn);\n }\n+\n+\n+void (*instr_event__guest_cpu_exit)(QICPU vcpu);\n+\n+SYM_PUBLIC void qi_event_set_guest_cpu_exit(void (*fn)(QICPU vcpu))\n+{\n+ ERROR_IF(!instr_get_state(), \"called outside instrumentation\");\n+ instr_set_event(guest_cpu_exit, fn);\n+}\ndiff --git a/instrument/events.h b/instrument/events.h\nindex 947f120aa9..c743cb8180 100644\n--- a/instrument/events.h\n+++ b/instrument/events.h\n@@ -36,6 +36,9 @@ extern void *instr_event__fini_data;\n extern void (*instr_event__guest_cpu_enter)(QICPU vcpu);\n static inline void instr_guest_cpu_enter(CPUState *vcpu);\n \n+extern void (*instr_event__guest_cpu_exit)(QICPU vcpu);\n+static inline void instr_guest_cpu_exit(CPUState *vcpu);\n+\n \n #include \"instrument/events.inc.h\"\n \ndiff --git a/instrument/events.inc.h b/instrument/events.inc.h\nindex e3f8024716..c88df7e42f 100644\n--- a/instrument/events.inc.h\n+++ b/instrument/events.inc.h\n@@ -20,3 +20,14 @@ static inline void instr_guest_cpu_enter(CPUState *vcpu)\n instr_set_state(INSTR_STATE_DISABLE);\n }\n }\n+\n+static inline void instr_guest_cpu_exit(CPUState *vcpu)\n+{\n+ void (*cb)(QICPU vcpu) = instr_get_event(guest_cpu_exit);\n+ if (cb) {\n+ QICPU vcpu_ = instr_cpu_to_qicpu(vcpu);\n+ instr_set_state(INSTR_STATE_ENABLE);\n+ (*cb)(vcpu_);\n+ instr_set_state(INSTR_STATE_DISABLE);\n+ }\n+}\ndiff --git a/instrument/load.c b/instrument/load.c\nindex 218bca74b2..6808d361b5 100644\n--- a/instrument/load.c\n+++ b/instrument/load.c\n@@ -11,7 +11,9 @@\n #include \"qemu-common.h\"\n \n #include <dlfcn.h>\n+#include \"cpu.h\"\n #include \"exec/cpu-common.h\"\n+#include \"exec/exec-all.h\"\n #include \"instrument/control.h\"\n #include \"instrument/events.h\"\n #include \"instrument/load.h\"\n@@ -127,6 +129,13 @@ out:\n return res;\n }\n \n+\n+static void instr_unload__cb(CPUState *cpu, void *data)\n+{\n+ tb_flush_sync(cpu);\n+ instr_guest_cpu_exit(cpu);\n+}\n+\n InstrUnloadError instr_unload(const char *id)\n {\n InstrUnloadError res;\n@@ -139,6 +148,10 @@ InstrUnloadError instr_unload(const char *id)\n goto out;\n }\n \n+ InstrCPUStop info;\n+ cpu_list_lock();\n+ instr_cpu_stop_all_begin(&info, instr_unload__cb, NULL);\n+\n qi_fini_fn fini_fn = instr_get_event(fini_fn);\n if (fini_fn) {\n void *fini_data = instr_get_event(fini_data);\n@@ -147,6 +160,10 @@ InstrUnloadError instr_unload(const char *id)\n \n instr_set_event(fini_fn, NULL);\n instr_set_event(guest_cpu_enter, NULL);\n+ instr_set_event(guest_cpu_exit, NULL);\n+\n+ instr_cpu_stop_all_end(&info);\n+ cpu_list_unlock();\n \n /* this should never fail */\n if (dlclose(handle->dlhandle) < 0) {\ndiff --git a/instrument/qemu-instr/control.h b/instrument/qemu-instr/control.h\nindex f61e7a2b6e..107ee8afe0 100644\n--- a/instrument/qemu-instr/control.h\n+++ b/instrument/qemu-instr/control.h\n@@ -85,6 +85,17 @@ void qi_set_fini(qi_fini_fn fn, void *data);\n */\n void qi_event_set_guest_cpu_enter(void (*fn)(QICPU vcpu));\n \n+/*\n+ * Hot-unplug a virtual (guest) CPU.\n+ *\n+ * Also triggered on each CPU when an instrumentation library is unloaded.\n+ *\n+ * Mode: user, softmmu\n+ * Targets: all\n+ * Time: exec\n+ */\n+void qi_event_set_guest_cpu_exit(void (*fn)(QICPU vcpu));\n+\n #ifdef __cplusplus\n }\n #endif\ndiff --git a/stubs/instrument.c b/stubs/instrument.c\nindex 6b59ba9a7a..c4b1c791d9 100644\n--- a/stubs/instrument.c\n+++ b/stubs/instrument.c\n@@ -47,3 +47,4 @@ void qmp_instr_unload(const char *id, Error **errp)\n \n __thread InstrState instr_cur_state;\n void (*instr_event__guest_cpu_enter)(QICPU *vcpu);\n+void (*instr_event__guest_cpu_exit)(QICPU *vcpu);\ndiff --git a/trace/control.c b/trace/control.c\nindex 82d8989c4d..946a0af818 100644\n--- a/trace/control.c\n+++ b/trace/control.c\n@@ -1,13 +1,14 @@\n /*\n * Interface for configuring and controlling the state of tracing events.\n *\n- * Copyright (C) 2011-2016 Lluís Vilanova <vilanova@ac.upc.edu>\n+ * Copyright (C) 2011-2017 Lluís Vilanova <vilanova@ac.upc.edu>\n *\n * This work is licensed under the terms of the GNU GPL, version 2 or later.\n * See the COPYING file in the top-level directory.\n */\n \n #include \"qemu/osdep.h\"\n+#include \"instrument/events.h\"\n #include \"trace/control.h\"\n #include \"qemu/help_option.h\"\n #ifdef CONFIG_TRACE_SIMPLE\n@@ -272,6 +273,7 @@ void trace_fini_vcpu(CPUState *vcpu)\n TraceEventIter iter;\n TraceEvent *ev;\n \n+ instr_guest_cpu_exit(vcpu);\n trace_guest_cpu_exit(vcpu);\n \n trace_event_iter_init(&iter, NULL);\n", "prefixes": [ "v5", "15/22" ] }