Received: from eggs.gnu.org ([208.118.235.92]:36152) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UKVyK-0004AA-Pq for qemu-devel@nongnu.org; Tue, 26 Mar 2013 11:39:39 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UKVyI-0000xN-SD for qemu-devel@nongnu.org; Tue, 26 Mar 2013 11:39:36 -0400 Received: from roura.ac.upc.edu ([147.83.33.10]:43634 helo=roura.ac.upc.es) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UKVyI-0000wa-Hm for qemu-devel@nongnu.org; Tue, 26 Mar 2013 11:39:34 -0400 From: =?utf-8?Q?Llu=C3=ADs_Vilanova?= References: <20130326140021.4471.99597.stgit@fimbulvetr.bsc.es> <20130326140139.4471.51043.stgit@fimbulvetr.bsc.es> <5151B647.6070900@redhat.com> Date: Tue, 26 Mar 2013 16:39:30 +0100 In-Reply-To: <5151B647.6070900@redhat.com> (Eric Blake's message of "Tue, 26 Mar 2013 08:52:55 -0600") Message-ID: <87ehf2xj9p.fsf@fimbulvetr.bsc.es> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Subject: Re: [Qemu-devel] [PATCH 14/22] instrument: [qmp, qapi] Add control interface List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Eric Blake Cc: qemu-devel@nongnu.org Eric Blake writes: > On 03/26/2013 08:01 AM, Llu=C3=ADs Vilanova wrote: >> Add QMP commands to control (un)loading of dynamic instrumentation libra= ry. >>=20 >> Signed-off-by: Llu=C3=ADs Vilanova >> --- >> include/qapi/qmp/qerror.h | 9 +++++ >> instrument/Makefile.objs | 1 + >> instrument/qapi-schema.json | 33 ++++++++++++++++++++ >> instrument/qmp.c | 59 ++++++++++++++++++++++++++++++++++++ >> qapi-schema.json | 2 + >> qmp-commands.hx | 71 +++++++++++++++++++++++++++++++++++++= ++++++ >> qmp.c | 4 ++ >> 7 files changed, 179 insertions(+) >> create mode 100644 instrument/qapi-schema.json >> create mode 100644 instrument/qmp.c >>=20 >> +++ b/instrument/qapi-schema.json >> @@ -0,0 +1,33 @@ >> +# *-*- Mode: Python -*-* >> + >> +## >> +# @instr-dynamic: >> +# >> +# Whether dynamic trace instrumentation is available. >> +# >> +# Since: 1.4 > 1.5 >> +## >> +{ 'command': 'instr-dynamic', >> + 'returns': 'bool' } >> + >> +## >> +# @instr-load: >> +# >> +# Load a dynamic instrumentation library. >> +# >> +# @path: path to the dynamic instrumentation library >> +# @args: arguments to the dynamic instrumentation library > No trailing underscore here... >> +# >> +# Since: 1.4 > 1.5 >> +## >> +{ 'command': 'instr-load', >> + 'data': { 'path': 'str', 'args_': 'str' } } > ...but there is one here. Something is wrong. Maybe there was a problem with using the word "args"? I honestly do not rem= ember the reason for this, so I'll just remove the underscore. > Furthermore, this is > gross - how does the receiver know how to break args into chunks? This > should be '*args':['str'], taking an optional array of args (omitting is > the same as a 0-length array). Ha! Looks like I was really lazy when I implemented this... I'll see if I c= an find some time to properly implement it and pass an array of strings to the instrumentation library. >> +## >> +# @instr-unload: >> +# >> +# Unload the current dynamic instrumentation library. >> +# >> +# Since: 1.4 > 1.5 >> +## >> +{ 'command': 'instr-unload' } > Is it possible to load more than one library at a time? If so, then > instr-load needs to return a handle, and instr-unload needs to take a > handle as an argument. Also, a query-instr command might be useful for > showing which library (or libraries) are loaded. It's not. Right now you'll get an error if that happens. The rationale behi= nd this is that for multiple libraries to be supported you would need to imple= ment an instrumentation "driver" that loops through a list of callbacks, which is slower than just calling into a single function pointer. I actually thought about writing an "auto-optimizing" version. The idea was= to assign the client's callback to the per-event pointer if only one library requested that event, and otherwise assign a pointer to a per-event auto-generated routine that loops through all assigned callbacks when multi= ple clients have registered for that event. But this looked like too much troub= le for an initial implementation. Besides, a single top-level instrumentation library could then provide an interface to load multiple "child" libraries, if that is necessary. >> +++ b/instrument/qmp.c >> @@ -0,0 +1,59 @@ >> +/* >> + * QMP interface for dynamic trace instrumentation control commands. >> + * >> + * Copyright (C) 2012 Llu=C3=ADs Vilanova > It's 2013, now. >> +++ b/qapi-schema.json >> @@ -2360,6 +2360,8 @@ >> ## >> { 'command': 'device_del', 'data': {'id': 'str'} } >>=20 >> +input("instrument/qapi-schema.json") >> + >> ## >> # @dump-guest-memory > Unusual placement, having it in the middle of the file in no particular > alphabetic ordering. I would typically expect to see includes done at > the beginning, or maybe at the end, or at least in alphabetical order > where the 'instr-*' commands would fall (but the file is already messy, > so not entirely your fault). This is probably the result of merges, or that I just changed the instrumentation command names and did not update the position; thanks. BTW, I think that this "input" primitive should be used wherever possible to split the files by subsystem and also have each part in the directory where= the implementation resides. >> +instr-load >> +---------- >> + >> +Load a dynamic instrumentation library. >> + >> +Arguments: >> + >> +- path: path to the dynamic instrumentation library > Missing out on args documentation. Is this one also able to handle a list of strings for "args"? If so, then I'm just missing how to expose it in the command-line (maybe as= an "accumulable" argument), and we'll be set for having proper argument suppor= t. Thanks, Lluis --=20 "And it's much the same thing with knowledge, for whenever you learn something new, the whole world becomes that much richer." -- The Princess of Pure Reason, as told by Norton Juster in The Phantom Tollbooth