{"id":810751,"url":"http://patchwork.ozlabs.org/api/patches/810751/?format=json","web_url":"http://patchwork.ozlabs.org/project/qemu-devel/patch/150472195416.24907.15859962605541218107.stgit@frigg.lan/","project":{"id":14,"url":"http://patchwork.ozlabs.org/api/projects/14/?format=json","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":"<150472195416.24907.15859962605541218107.stgit@frigg.lan>","list_archive_url":null,"date":"2017-09-06T18:19:14","name":"[v4,14/20] instrument: Add event 'guest_cpu_reset'","commit_ref":null,"pull_url":null,"state":"new","archived":false,"hash":"980f710083eac5d34bdeb7033ad0aa3256a3f535","submitter":{"id":9099,"url":"http://patchwork.ozlabs.org/api/people/9099/?format=json","name":"Lluís Vilanova","email":"vilanova@ac.upc.edu"},"delegate":null,"mbox":"http://patchwork.ozlabs.org/project/qemu-devel/patch/150472195416.24907.15859962605541218107.stgit@frigg.lan/mbox/","series":[{"id":1859,"url":"http://patchwork.ozlabs.org/api/series/1859/?format=json","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/810751/comments/","check":"pending","checks":"http://patchwork.ozlabs.org/api/patches/810751/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 3xnX1T6MHZz9s8J\n\tfor <incoming@patchwork.ozlabs.org>;\n\tThu,  7 Sep 2017 04:19:57 +1000 (AEST)","from localhost ([::1]:37405 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 1dpevc-0003iT-1p\n\tfor incoming@patchwork.ozlabs.org; Wed, 06 Sep 2017 14:19:56 -0400","from eggs.gnu.org ([2001:4830:134:3::10]:49769)\n\tby lists.gnu.org with esmtp (Exim 4.71)\n\t(envelope-from <vilanova@ac.upc.edu>) id 1dpevA-0003i3-Tx\n\tfor qemu-devel@nongnu.org; Wed, 06 Sep 2017 14:19:33 -0400","from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)\n\t(envelope-from <vilanova@ac.upc.edu>) id 1dpev6-0005w3-Sr\n\tfor qemu-devel@nongnu.org; Wed, 06 Sep 2017 14:19:28 -0400","from roura.ac.upc.es ([147.83.33.10]:39560)\n\tby eggs.gnu.org with esmtp (Exim 4.71)\n\t(envelope-from <vilanova@ac.upc.edu>) id 1dpev6-0005vr-Hn\n\tfor qemu-devel@nongnu.org; Wed, 06 Sep 2017 14:19:24 -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 v86IJLWp005042;\n\tWed, 6 Sep 2017 20:19:21 +0200","from localhost (unknown [31.210.187.58])\n\tby correu-2.ac.upc.es (Postfix) with ESMTPSA id A8DFF1DF;\n\tWed,  6 Sep 2017 20:19:15 +0200 (CEST)"],"From":"=?utf-8?b?TGx1w61z?= Vilanova <vilanova@ac.upc.edu>","To":"qemu-devel@nongnu.org","Date":"Wed,  6 Sep 2017 21:19:14 +0300","Message-Id":"<150472195416.24907.15859962605541218107.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\tv86IJLWp005042","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 14/20] instrument: Add event\n\t'guest_cpu_reset'","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             |    3 +++\n instrument/events.inc.h         |   11 +++++++++++\n instrument/load.c               |    1 +\n instrument/qemu-instr/control.h |    9 +++++++++\n qom/cpu.c                       |    2 ++\n stubs/instrument.c              |    1 +\n 7 files changed, 36 insertions(+)","diff":"diff --git a/instrument/control.c b/instrument/control.c\nindex 09ba682483..3cec1028e5 100644\n--- a/instrument/control.c\n+++ b/instrument/control.c\n@@ -66,3 +66,12 @@ QI_VPUBLIC void qi_event_set_guest_cpu_exit(void (*fn)(QICPU vcpu))\n     ERROR_IF(!instr_get_state(), \"called outside instrumentation\");\n     instr_set_event(guest_cpu_exit, fn);\n }\n+\n+\n+void (*instr_event__guest_cpu_reset)(QICPU vcpu);\n+\n+QI_VPUBLIC void qi_event_set_guest_cpu_reset(void (*fn)(QICPU vcpu))\n+{\n+    ERROR_IF(!instr_get_state(), \"called outside instrumentation\");\n+    instr_set_event(guest_cpu_reset, fn);\n+}\ndiff --git a/instrument/events.h b/instrument/events.h\nindex c743cb8180..4a0560490a 100644\n--- a/instrument/events.h\n+++ b/instrument/events.h\n@@ -39,6 +39,9 @@ static inline void instr_guest_cpu_enter(CPUState *vcpu);\n extern void (*instr_event__guest_cpu_exit)(QICPU vcpu);\n static inline void instr_guest_cpu_exit(CPUState *vcpu);\n \n+extern void (*instr_event__guest_cpu_reset)(QICPU vcpu);\n+static inline void instr_guest_cpu_reset(CPUState *vcpu);\n+\n \n #include \"instrument/events.inc.h\"\n \ndiff --git a/instrument/events.inc.h b/instrument/events.inc.h\nindex bcbf0cb32a..2f2cd324aa 100644\n--- a/instrument/events.inc.h\n+++ b/instrument/events.inc.h\n@@ -31,3 +31,14 @@ static inline void instr_guest_cpu_exit(CPUState *vcpu)\n         instr_set_state(INSTR_STATE_DISABLE);\n     }\n }\n+\n+static inline void instr_guest_cpu_reset(CPUState *vcpu)\n+{\n+    void (*cb)(QICPU vcpu) = instr_get_event(guest_cpu_reset);\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 63b7d564ec..d9310d1979 100644\n--- a/instrument/load.c\n+++ b/instrument/load.c\n@@ -150,6 +150,7 @@ InstrUnloadError instr_unload(int64_t handle_id)\n     instr_set_event(fini_fn, NULL);\n     instr_set_event(guest_cpu_enter, NULL);\n     instr_set_event(guest_cpu_exit, NULL);\n+    instr_set_event(guest_cpu_reset, 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 c37a380ab0..238ea63301 100644\n--- a/instrument/qemu-instr/control.h\n+++ b/instrument/qemu-instr/control.h\n@@ -89,6 +89,15 @@ void qi_event_set_guest_cpu_enter(void (*fn)(QICPU vcpu));\n  */\n void qi_event_set_guest_cpu_exit(void (*fn)(QICPU vcpu));\n \n+/*\n+ * Reset the state of a virtual (guest) CPU.\n+ *\n+ * Mode: user, softmmu\n+ * Targets: all\n+ * Time: exec\n+ */\n+void qi_event_set_guest_cpu_reset(void (*fn)(QICPU vcpu));\n+\n #ifdef __cplusplus\n }\n #endif\ndiff --git a/qom/cpu.c b/qom/cpu.c\nindex 4f38db0dac..d09cf583eb 100644\n--- a/qom/cpu.c\n+++ b/qom/cpu.c\n@@ -19,6 +19,7 @@\n  */\n \n #include \"qemu/osdep.h\"\n+#include \"instrument/events.h\"\n #include \"qapi/error.h\"\n #include \"qemu-common.h\"\n #include \"qom/cpu.h\"\n@@ -271,6 +272,7 @@ void cpu_reset(CPUState *cpu)\n         (*klass->reset)(cpu);\n     }\n \n+    instr_guest_cpu_reset(cpu);\n     trace_guest_cpu_reset(cpu);\n }\n \ndiff --git a/stubs/instrument.c b/stubs/instrument.c\nindex ea8df6d467..74935975da 100644\n--- a/stubs/instrument.c\n+++ b/stubs/instrument.c\n@@ -13,3 +13,4 @@\n __thread InstrState instr_cur_state;\n void (*instr_event__guest_cpu_enter)(QICPU *vcpu);\n void (*instr_event__guest_cpu_exit)(QICPU *vcpu);\n+void (*instr_event__guest_cpu_reset)(QICPU *vcpu);\n","prefixes":["v4","14/20"]}