From: Stefan Hajnoczi <stefanha@gmail.com>
To: "Lluís Vilanova" <vilanova@ac.upc.edu>
Cc: Blue Swirl <blauwirbel@gmail.com>,
Zhi Yong Wu <zwu.kernel@gmail.com>,
qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] [PATCH v2 0/5] backdoor: lightweight guest-to-QEMU backdoor channel
Date: Fri, 9 Dec 2011 11:23:56 +0000 [thread overview]
Message-ID: <CAJSP0QUQho2d56BkjfyYdz0TkgY7x5baifChLHFVyrusPipUWg@mail.gmail.com> (raw)
In-Reply-To: <87hb1a28oh.fsf@ginnungagap.bsc.es>
2011/12/8 Lluís Vilanova <vilanova@ac.upc.edu>:
> Stefan Hajnoczi writes:
> [...]
>>> * Support for tracing guest code through TCG.
>
>> I'm not clear on whether a backdoor mechanism is needed or not. A
>> backdoor mechanism allows a modified guest to participate in tracing.
>
>> Depending on the type of analysis you are doing it might be possible
>> to achieve the same thing by emitting calls to custom instrumentation
>> in TCG (or is this too low-level for what you're trying to trace in
>> the guest?). The advantage is also that you can do this to unmodified
>> guests.
>
> You're right with the first; it exists for two reasons:
>
> * simplicity: it's easier to have, for example, a backdoor + linux tracepoints
> than obtaining the IP of an "interesting" function (think of the
> multiprogramming on a full system)
>
> * performance: it's faster to let the guest tell you rather than (ab)using
> breakpoints or checking the IP of every instruction
>
> The main use of this is to get semanticful events on the guest (my previous
> example was about knowing when linux changes the current process, but you could
> use anything else as well - e.g., a certain function of a specific thread on the
> guest -).
I misunderstood the layer you were tracing. A backdoor into the guest
indeed makes high-level events easy.
My thoughts were more along the lines of TCG planting calls to custom
functions when it translates an instruction of interest, which is much
lower level and would be more appropriate for code execution
statistics (branches, counters, etc).
>> So I'm suggesting that we don't *need* explicit support for
>> instrumenting trace events. Instead add plain old functions where you
>> need them. You may decide to invoke trace events from your
>> instrumentation function, but that's already covered today by
>> docs/tracing.txt.
>
>> Am I missing the point of instrumentation tracing events or do you
>> agree that we can work well without it?
>
> The point is to avoid diving into QEMU's code and instead use the current
> out-of-the-box tracing points as the instrumentation hooks, which can be
> achieved both through the current approach or an unofficial tracing backend.
>
> The nice thing about the current approach is that the user can do some extra
> checks on the tracing event and then (maybe) call the original backend-generated
> tracing routine (as a quick and easy way to extend what to actually trace).
The workflow with an instrumentation layer and trace events as API:
1. Look at available trace events.
2. Write function against trace event interface without using QEMU internals.
3. If you want tracing output make sure to invoke trace_*_backend()
after any processing/filtering.
The workflow in my mind is:
1. Look at QEMU source for a place to insert instrumentation.
2. Write a plain old function (nothing to do with QEMU tracing) to
perform your instrumentation.
3. If you want tracing output make sure to invoke trace_*() after any
processing/filtering.
Although I now understand the purpose of the instrumentation layer
better - it insulates from QEMU's guts - I'm not really of fan of this
approach because I don't see trace events as an API. They are not
documented and require looking at call sites in QEMU source code to
understand their meaning. My argument is that once you need to look
inside QEMU to understand how to instrument there is no benefit from
having an instrumentation layer.
We have no API on which to build the instrumentation interface. Can
you give details about the APIs you'd like and how you use them (e.g.
mem_read()/mem_write() for instrumenting guest memory accesses)?
Stefan
next prev parent reply other threads:[~2011-12-09 11:23 UTC|newest]
Thread overview: 39+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-12-05 22:22 [Qemu-devel] [PATCH v2 0/5] backdoor: lightweight guest-to-QEMU backdoor channel Lluís Vilanova
2011-12-05 22:22 ` [Qemu-devel] [PATCH v2 1/5] backdoor: Add documentation Lluís Vilanova
2011-12-06 22:36 ` Peter Maydell
2011-12-06 22:51 ` Anthony Liguori
2011-12-06 22:50 ` Anthony Liguori
2011-12-05 22:22 ` [Qemu-devel] [PATCH v2 2/5] backdoor: Add build infrastructure Lluís Vilanova
2011-12-05 22:22 ` [Qemu-devel] [PATCH v2 3/5] backdoor: [*-user] Add QEMU-side proxy to "libbackdoor.a" Lluís Vilanova
2011-12-05 22:23 ` [Qemu-devel] [PATCH v2 4/5] backdoor: [softmmu] " Lluís Vilanova
2011-12-06 19:55 ` Anthony Liguori
2011-12-06 22:30 ` Lluís Vilanova
2011-12-06 22:35 ` Anthony Liguori
2011-12-06 22:37 ` Peter Maydell
2011-12-07 8:21 ` [Qemu-devel] Insane virtio-serial semantics (was: [PATCH v2 4/5] backdoor: [softmmu] Add QEMU-side proxy to "libbackdoor.a") Markus Armbruster
2011-12-07 13:49 ` [Qemu-devel] Insane virtio-serial semantics Anthony Liguori
2011-12-07 19:44 ` Michael Roth
2011-12-07 19:53 ` Anthony Liguori
2011-12-08 10:11 ` Markus Armbruster
2011-12-08 14:37 ` Anthony Liguori
2011-12-06 22:39 ` [Qemu-devel] [PATCH v2 4/5] backdoor: [softmmu] Add QEMU-side proxy to "libbackdoor.a" Lluís Vilanova
2011-12-05 22:23 ` [Qemu-devel] [PATCH v2 5/5] backdoor: Add guest-side library Lluís Vilanova
2011-12-06 22:52 ` [Qemu-devel] [PATCH v2 0/5] backdoor: lightweight guest-to-QEMU backdoor channel Anthony Liguori
2011-12-07 12:21 ` Lluís Vilanova
2011-12-07 13:55 ` Anthony Liguori
2011-12-07 15:23 ` Lluís Vilanova
2011-12-07 15:48 ` Anthony Liguori
2011-12-07 16:59 ` Lluís Vilanova
2011-12-07 17:48 ` Anthony Liguori
2011-12-07 18:35 ` Lluís Vilanova
2011-12-07 18:51 ` Peter Maydell
2011-12-07 18:54 ` Anthony Liguori
2011-12-07 20:13 ` Lluís Vilanova
2011-12-07 22:03 ` Lluís Vilanova
2011-12-08 20:45 ` Blue Swirl
2011-12-08 14:05 ` Stefan Hajnoczi
2011-12-08 18:57 ` Lluís Vilanova
2011-12-08 20:57 ` Blue Swirl
2011-12-08 22:16 ` Lluís Vilanova
2011-12-09 11:23 ` Stefan Hajnoczi [this message]
2011-12-09 20:55 ` Lluís Vilanova
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=CAJSP0QUQho2d56BkjfyYdz0TkgY7x5baifChLHFVyrusPipUWg@mail.gmail.com \
--to=stefanha@gmail.com \
--cc=blauwirbel@gmail.com \
--cc=qemu-devel@nongnu.org \
--cc=vilanova@ac.upc.edu \
--cc=zwu.kernel@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).