Patch Detail
get:
Show a patch.
patch:
Update a patch.
put:
Update a patch.
GET /api/patches/810749/?format=api
{ "id": 810749, "url": "http://patchwork.ozlabs.org/api/patches/810749/?format=api", "web_url": "http://patchwork.ozlabs.org/project/qemu-devel/patch/150472146893.24907.1040882648962239022.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": "<150472146893.24907.1040882648962239022.stgit@frigg.lan>", "list_archive_url": null, "date": "2017-09-06T18:11:09", "name": "[v4,12/20] instrument: Add event 'guest_cpu_enter'", "commit_ref": null, "pull_url": null, "state": "new", "archived": false, "hash": "b6ca82bebf205ea1ba2969fd5d32d125b6971aba", "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/150472146893.24907.1040882648962239022.stgit@frigg.lan/mbox/", "series": [ { "id": 1859, "url": "http://patchwork.ozlabs.org/api/series/1859/?format=api", "web_url": "http://patchwork.ozlabs.org/project/qemu-devel/list/?series=1859", "date": "2017-09-06T17:22:41", "name": "instrument: Add basic event instrumentation", "version": 4, "mbox": "http://patchwork.ozlabs.org/series/1859/mbox/" } ], "comments": "http://patchwork.ozlabs.org/api/patches/810749/comments/", "check": "pending", "checks": "http://patchwork.ozlabs.org/api/patches/810749/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 3xnWrB2PsKz9t2W\n\tfor <incoming@patchwork.ozlabs.org>;\n\tThu, 7 Sep 2017 04:11:54 +1000 (AEST)", "from localhost ([::1]:37382 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 1dpeno-0000Aa-6E\n\tfor incoming@patchwork.ozlabs.org; Wed, 06 Sep 2017 14:11:52 -0400", "from eggs.gnu.org ([2001:4830:134:3::10]:47442)\n\tby lists.gnu.org with esmtp (Exim 4.71)\n\t(envelope-from <vilanova@ac.upc.edu>) id 1dpenK-00008f-Ti\n\tfor qemu-devel@nongnu.org; Wed, 06 Sep 2017 14:11:24 -0400", "from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)\n\t(envelope-from <vilanova@ac.upc.edu>) id 1dpenG-0002iC-TL\n\tfor qemu-devel@nongnu.org; Wed, 06 Sep 2017 14:11:22 -0400", "from roura.ac.upc.es ([147.83.33.10]:33722)\n\tby eggs.gnu.org with esmtp (Exim 4.71)\n\t(envelope-from <vilanova@ac.upc.edu>) id 1dpenG-0002hn-EG\n\tfor qemu-devel@nongnu.org; Wed, 06 Sep 2017 14:11:18 -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 v86IBFXr004859;\n\tWed, 6 Sep 2017 20:11:15 +0200", "from localhost (unknown [31.210.187.58])\n\tby correu-1.ac.upc.es (Postfix) with ESMTPSA id 7BDFF7FD;\n\tWed, 6 Sep 2017 20:11:10 +0200 (CEST)" ], "From": "=?utf-8?b?TGx1w61z?= Vilanova <vilanova@ac.upc.edu>", "To": "qemu-devel@nongnu.org", "Date": "Wed, 6 Sep 2017 21:11:09 +0300", "Message-Id": "<150472146893.24907.1040882648962239022.stgit@frigg.lan>", "X-Mailer": "git-send-email 2.14.1", "In-Reply-To": "<150471856141.24907.274176769201097378.stgit@frigg.lan>", "References": "<150471856141.24907.274176769201097378.stgit@frigg.lan>", "User-Agent": "StGit/0.17.1-dirty", "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\tv86IBFXr004859", "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 v4 12/20] instrument: Add event\n\t'guest_cpu_enter'", "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": "Paolo Bonzini <pbonzini@redhat.com>, \"Emilio G. Cota\" <cota@braap.org>,\n\t=?utf-8?q?Llu=C3=ADs_Vilanova?= <vilanova@ac.upc.edu>,\n\tStefan Hajnoczi <stefanha@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: Lluís Vilanova <vilanova@ac.upc.edu>\n---\n instrument/control.c | 9 ++++++++\n instrument/events.h | 5 ++++\n instrument/events.inc.h | 11 ++++++++++\n instrument/load.c | 1 +\n instrument/qemu-instr/control.h | 44 +++++++++++++++++++++++++++++++++++++++\n stubs/instrument.c | 1 +\n trace/control-target.c | 2 ++\n 7 files changed, 73 insertions(+)", "diff": "diff --git a/instrument/control.c b/instrument/control.c\nindex 83453ea561..ed0d537b88 100644\n--- a/instrument/control.c\n+++ b/instrument/control.c\n@@ -48,3 +48,12 @@ QI_VPUBLIC void qi_set_fini(qi_fini_fn fn, void *data)\n instr_set_event(fini_fn, fn);\n instr_set_event(fini_data, data);\n }\n+\n+\n+void (*instr_event__guest_cpu_enter)(QICPU vcpu);\n+\n+QI_VPUBLIC void qi_event_set_guest_cpu_enter(void (*fn)(QICPU vcpu))\n+{\n+ ERROR_IF(!instr_get_state(), \"called outside instrumentation\");\n+ instr_set_event(guest_cpu_enter, fn);\n+}\ndiff --git a/instrument/events.h b/instrument/events.h\nindex 82ad0bd827..947f120aa9 100644\n--- a/instrument/events.h\n+++ b/instrument/events.h\n@@ -11,6 +11,7 @@\n #define INSTRUMENT__EVENTS_H\n \n #include \"instrument/qemu-instr/control.h\"\n+#include \"instrument/qemu-instr/types.h\"\n \n /**\n * instr_get_event:\n@@ -32,6 +33,10 @@\n extern qi_fini_fn instr_event__fini_fn;\n extern void *instr_event__fini_data;\n \n+extern void (*instr_event__guest_cpu_enter)(QICPU vcpu);\n+static inline void instr_guest_cpu_enter(CPUState *vcpu);\n+\n+\n #include \"instrument/events.inc.h\"\n \n #endif /* INSTRUMENT__EVENTS_H */\ndiff --git a/instrument/events.inc.h b/instrument/events.inc.h\nindex 8b1ce7fcb2..238cce9855 100644\n--- a/instrument/events.inc.h\n+++ b/instrument/events.inc.h\n@@ -7,5 +7,16 @@\n * See the COPYING file in the top-level directory.\n */\n \n+#include \"instrument/control.h\"\n \n \n+static inline void instr_guest_cpu_enter(CPUState *vcpu)\n+{\n+ void (*cb)(QICPU vcpu) = instr_get_event(guest_cpu_enter);\n+ if (cb) {\n+ QICPU vcpu_ = instr_cpu_set(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 e180f03429..0fe878afa8 100644\n--- a/instrument/load.c\n+++ b/instrument/load.c\n@@ -148,6 +148,7 @@ InstrUnloadError instr_unload(int64_t handle_id)\n }\n \n instr_set_event(fini_fn, NULL);\n+ instr_set_event(guest_cpu_enter, NULL);\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 f6e289daa0..26d8aa976d 100644\n--- a/instrument/qemu-instr/control.h\n+++ b/instrument/qemu-instr/control.h\n@@ -16,6 +16,7 @@ extern \"C\" {\n \n #include <stdbool.h>\n #include <stddef.h>\n+#include <qemu-instr/types.h>\n \n \n /**\n@@ -36,6 +37,49 @@ typedef void (*qi_fini_fn)(void *arg);\n */\n void qi_set_fini(qi_fini_fn fn, void *data);\n \n+\n+/*\n+ * Set callbacks for available events. Each event has a short description and\n+ * various indicators of when it can be triggered:\n+ *\n+ * - Mode :: user\n+ * Triggered in QEMU user application emulation (e.g., linux-user).\n+ *\n+ * - Mode :: softmmy\n+ * Triggered in QEMU full-system emulation.\n+ *\n+ *\n+ * - Targets :: all\n+ * Triggered on all targets, both using TCG or native hardware virtualization\n+ * (e.g., KVM).\n+ *\n+ * - Targets :: TCG(<arch>)\n+ * Triggered on the given guest target architectures when executing with TCG\n+ * (no native hardware virtualization).\n+ *\n+ *\n+ * - Time :: exec\n+ * Triggered when the guest executes the described operation.\n+ *\n+ * - Time :: trans\n+ * Triggered when QEMU translates a guest operation. This is only available\n+ * when executing with TCG. Guest instructions are decompiled and translated\n+ * into the intermediate TCG language (when \"Time: trans\" events are\n+ * triggered). Then, the TCG compiler translates TCG code into the native host\n+ * code that QEMU will execute to emulate the guest (when \"Time: exec\" events\n+ * are triggered). As QEMU uses a cache of translated code, the same\n+ * instruction might be translated more than once (when the cache overflows).\n+ */\n+\n+/*\n+ * Hot-plug a new virtual (guest) CPU.\n+ *\n+ * Mode: user, softmmu\n+ * Targets: all\n+ * Time: exec\n+ */\n+void qi_event_set_guest_cpu_enter(void (*fn)(QICPU vcpu));\n+\n #ifdef __cplusplus\n }\n #endif\ndiff --git a/stubs/instrument.c b/stubs/instrument.c\nindex 6731710fd5..658a872e1c 100644\n--- a/stubs/instrument.c\n+++ b/stubs/instrument.c\n@@ -11,3 +11,4 @@\n \n \n __thread InstrState instr_cur_state;\n+void (*instr_event__guest_cpu_enter)(QICPU *vcpu);\ndiff --git a/trace/control-target.c b/trace/control-target.c\nindex 0056da6a46..e47361cef8 100644\n--- a/trace/control-target.c\n+++ b/trace/control-target.c\n@@ -9,6 +9,7 @@\n \n #include \"qemu/osdep.h\"\n #include \"cpu.h\"\n+#include \"instrument/events.h\"\n #include \"trace-root.h\"\n #include \"trace/control.h\"\n #include \"translate-all.h\"\n@@ -147,5 +148,6 @@ void trace_init_vcpu(CPUState *vcpu)\n }\n }\n }\n+ instr_guest_cpu_enter(vcpu);\n trace_guest_cpu_enter(vcpu);\n }\n", "prefixes": [ "v4", "12/20" ] }