<div dir="ltr">We will also provide patches for snapshot + regression test.<div><br></div><div>Could you send me the minor modifications? I wouldn't like to make the same mistakes twice.</div><div><br></div><div>Thanks </div>
</div><div class="gmail_extra"><br><br><div class="gmail_quote">On Mon, Apr 14, 2014 at 11:26 AM, David Goulet <span dir="ltr"><<a href="mailto:dgoulet@efficios.com" target="_blank">dgoulet@efficios.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">I've fixed some minor things and prepared this one for a merge.<br>
<br>
Once the full patch set is ready to be merged, I'll be pushing them all<br>
at once.<br>
<br>
Thanks!<br>
David<br>
<div><div class="h5"><br>
On 06 Apr (15:30:32), Jonathan Rajotte wrote:<br>
> Hi,<br>
><br>
> These patches add machine interface functionality to command version and list.<br>
> At the same time they procure a base architecture of the machine<br>
> interface.<br>
><br>
> The first patch cover the version command and add the base for the<br>
> machine interface.(mostly the same as last week mi patch)<br>
> p.s: David if you want to pull this one [1].<br>
><br>
> The second patch provide full machine interface functionality to the list<br>
> command. You will find attached a little script that demonstrate the mi<br>
> functionality of list. The script need a root sessiond and need to be<br>
> at the base of lttng-tool directory. Outputs will be generated in<br>
> ./mi_test_output/ .<br>
><br>
> The third patch provide an xsd to validate the mi output of list and<br>
> version command.<br>
><br>
> Voilà!<br>
><br>
> Jonathan<br>
><br>
> [1] <a href="https://github.com/PSRCode/lttng-tools-dev/commits/list_release" target="_blank">https://github.com/PSRCode/lttng-tools-dev/commits/list_release</a><br>
> commit: add4aa1a79247749cb823ec68ab1067beda937d0<br>
> --Patch--<br>
><br>
> The machine interface option is now available for version.<br>
> Other commands will shortly follow.<br>
> Mi backend is expected to grow with addition of mi support<br>
> to other commands.<br>
><br>
> How to use:<br>
> lttng --mi <mi_output_type> <command><br>
><br>
> This syntax will be the same for all commands.<br>
> Currently *only xml is supported as machine interface output.*<br>
><br>
> As for errors handling, if an error/warning occurs while using mi it will be<br>
> reported on stderr as normal. The integrity of the mi output cannot be<br>
> guaranteed if an error/warning occurs.<br>
> The error output format is consistent and easy for a machine client to parse.<br>
> Thus no mi output format is required for error output.<br>
><br>
> Example:<br>
> lttng --mi xml version<br>
> Output:<br>
> <?xml version="1.0" encoding="UTF-8"?><br>
> <command><br>
> <name>version</name><br>
> <output><br>
> <string>2.4.0-rc2</string><br>
> <major>2</major><br>
> <minor>4</minor><br>
> <patchLevel>0</patchLevel><br>
> <name>Époque Opaque</name><br>
> <description>The Époque Opaque is a black IPA from Trou du Diable<br>
> brewery. The nose is eerily reminiscent of the coffee crisp candy from<br>
> of our childhood. These strong mocha accents are present on the palate,<br>
> which are quickly subdued by Japanese and Australian hops leading to a<br>
> final state of satisfaction enjoyable for any fan of bitter<br>
> beer.</description><br>
> <url><a href="http://lttng.org" target="_blank">http://lttng.org</a></url><br>
> <license>lttng is free software and under the GPL license and part<br>
> LGPL</license><br>
> </output><br>
> </command><br>
><br>
> Signed-off-by: Olivier Cotte <<a href="mailto:olivier.cotte@polymtl.ca">olivier.cotte@polymtl.ca</a>><br>
> Signed-off-by: Jonathan Rajotte <<a href="mailto:jonathan.r.julien@gmail.com">jonathan.r.julien@gmail.com</a>><br>
> ---<br>
> include/lttng/lttng-error.h | 6 +-<br>
> include/lttng/lttng.h | 5 +<br>
> src/bin/lttng-consumerd/lttng-consumerd.c | 2 +<br>
> src/bin/lttng/commands/add_context.c | 7 +<br>
> src/bin/lttng/commands/calibrate.c | 7 +<br>
> src/bin/lttng/commands/create.c | 7 +<br>
> src/bin/lttng/commands/destroy.c | 7 +<br>
> src/bin/lttng/commands/disable_channels.c | 7 +<br>
> src/bin/lttng/commands/disable_events.c | 7 +<br>
> src/bin/lttng/commands/enable_channels.c | 7 +<br>
> src/bin/lttng/commands/enable_events.c | 7 +<br>
> src/bin/lttng/commands/list.c | 7 +<br>
> src/bin/lttng/commands/load.c | 7 +<br>
> src/bin/lttng/commands/save.c | 7 +<br>
> src/bin/lttng/commands/set_session.c | 7 +<br>
> src/bin/lttng/commands/snapshot.c | 7 +<br>
> src/bin/lttng/commands/start.c | 7 +<br>
> src/bin/lttng/commands/stop.c | 7 +<br>
> src/bin/lttng/commands/version.c | 88 ++++++++-<br>
> src/bin/lttng/commands/view.c | 4 +<br>
> src/bin/lttng/lttng.c | 32 +++-<br>
> src/common/Makefile.am | 5 +-<br>
> src/common/error.h | 11 +-<br>
> src/common/mi-lttng.c | 284 ++++++++++++++++++++++++++++++<br>
> src/common/mi-lttng.h | 230 ++++++++++++++++++++++++<br>
> src/lib/lttng-ctl/lttng-ctl.c | 1 +<br>
> tests/unit/ini_config/ini_config.c | 1 +<br>
> tests/unit/test_kernel_data.c | 1 +<br>
> tests/unit/test_session.c | 1 +<br>
> tests/unit/test_uri.c | 1 +<br>
> tests/unit/test_ust_data.c | 1 +<br>
> tests/unit/test_utils_expand_path.c | 1 +<br>
> tests/unit/test_utils_parse_size_suffix.c | 1 +<br>
> 33 files changed, 769 insertions(+), 11 deletions(-)<br>
> create mode 100644 src/common/mi-lttng.c<br>
> create mode 100644 src/common/mi-lttng.h<br>
><br>
> diff --git a/include/lttng/lttng-error.h b/include/lttng/lttng-error.h<br>
> index 06baa04..1594ba9 100644<br>
> --- a/include/lttng/lttng-error.h<br>
> +++ b/include/lttng/lttng-error.h<br>
> @@ -120,9 +120,9 @@ enum lttng_error_code {<br>
> LTTNG_ERR_LOAD_INVALID_CONFIG = 87, /* Invalid session configuration */<br>
> LTTNG_ERR_LOAD_IO_FAIL = 88, /* IO error while reading a session configuration */<br>
> LTTNG_ERR_LOAD_SESSION_NOENT = 89, /* Session file not found */<br>
> - /* 90 */<br>
> - /* 91 */<br>
> - /* 92 */<br>
> + LTTNG_ERR_MI_OUTPUT_TYPE = 90, /* Invalid MI output format */<br>
> + LTTNG_ERR_MI_IO_FAIL = 91, /* IO error while writing machine interface output */<br>
> + LTTNG_ERR_MI_NOT_IMPLEMENTED = 92, /* Mi feature not implemented */<br>
> /* 93 */<br>
> /* 94 */<br>
> /* 95 */<br>
> diff --git a/include/lttng/lttng.h b/include/lttng/lttng.h<br>
> index f0be224..9449161 100644<br>
> --- a/include/lttng/lttng.h<br>
> +++ b/include/lttng/lttng.h<br>
> @@ -170,6 +170,11 @@ enum lttng_buffer_type {<br>
> LTTNG_BUFFER_GLOBAL, /* Only supported by the Kernel. */<br>
> };<br>
><br>
> +/* Machine interface output type */<br>
> +enum lttng_mi_output_type {<br>
> + LTTNG_MI_XML = 1 /* XML output */<br>
> +};<br>
> +<br>
> /*<br>
> * The structures should be initialized to zero before use.<br>
> */<br>
> diff --git a/src/bin/lttng-consumerd/lttng-consumerd.c b/src/bin/lttng-consumerd/lttng-consumerd.c<br>
> index e226ebc..0ce163e 100644<br>
> --- a/src/bin/lttng-consumerd/lttng-consumerd.c<br>
> +++ b/src/bin/lttng-consumerd/lttng-consumerd.c<br>
> @@ -65,6 +65,8 @@ static int sigintcount = 0;<br>
> /* Argument variables */<br>
> int lttng_opt_quiet; /* not static in error.h */<br>
> int lttng_opt_verbose; /* not static in error.h */<br>
> +int lttng_opt_mi; /* not static in error.h */<br>
> +<br>
> static int opt_daemon;<br>
> static const char *progname;<br>
> static char command_sock_path[PATH_MAX]; /* Global command socket path */<br>
> diff --git a/src/bin/lttng/commands/add_context.c b/src/bin/lttng/commands/add_context.c<br>
> index 6483c98..2eb0e90 100644<br>
> --- a/src/bin/lttng/commands/add_context.c<br>
> +++ b/src/bin/lttng/commands/add_context.c<br>
> @@ -446,6 +446,13 @@ int cmd_add_context(int argc, const char **argv)<br>
> goto end;<br>
> }<br>
><br>
> + /* TODO: mi support */<br>
> + if (lttng_opt_mi) {<br>
> + ret = -LTTNG_ERR_MI_NOT_IMPLEMENTED;<br>
> + ERR("mi option not supported");<br>
> + goto end;<br>
> + }<br>
> +<br>
> pc = poptGetContext(NULL, argc, argv, long_options, 0);<br>
> poptReadDefaultConfig(pc, 0);<br>
><br>
> diff --git a/src/bin/lttng/commands/calibrate.c b/src/bin/lttng/commands/calibrate.c<br>
> index 092632c..7d4de29 100644<br>
> --- a/src/bin/lttng/commands/calibrate.c<br>
> +++ b/src/bin/lttng/commands/calibrate.c<br>
> @@ -133,6 +133,13 @@ static int calibrate_lttng(void)<br>
> goto error;<br>
> }<br>
><br>
> + /* TODO: mi support */<br>
> + if (lttng_opt_mi) {<br>
> + ret = -LTTNG_ERR_MI_NOT_IMPLEMENTED;<br>
> + ERR("mi option not supported");<br>
> + goto error;<br>
> + }<br>
> +<br>
> handle = lttng_create_handle(NULL, &dom);<br>
> if (handle == NULL) {<br>
> ret = CMD_ERROR;<br>
> diff --git a/src/bin/lttng/commands/create.c b/src/bin/lttng/commands/create.c<br>
> index e02b141..c43ce59 100644<br>
> --- a/src/bin/lttng/commands/create.c<br>
> +++ b/src/bin/lttng/commands/create.c<br>
> @@ -515,6 +515,13 @@ int cmd_create(int argc, const char **argv)<br>
> }<br>
> }<br>
><br>
> + /* TODO: mi support */<br>
> + if (lttng_opt_mi) {<br>
> + ret = -LTTNG_ERR_MI_NOT_IMPLEMENTED;<br>
> + ERR("mi option not supported");<br>
> + goto end;<br>
> + }<br>
> +<br>
> if (opt_no_consumer) {<br>
> MSG("The option --no-consumer is obsolete. Use --no-output now.");<br>
> ret = CMD_WARNING;<br>
> diff --git a/src/bin/lttng/commands/destroy.c b/src/bin/lttng/commands/destroy.c<br>
> index 3fb5fb2..26548b9 100644<br>
> --- a/src/bin/lttng/commands/destroy.c<br>
> +++ b/src/bin/lttng/commands/destroy.c<br>
> @@ -148,6 +148,13 @@ int cmd_destroy(int argc, const char **argv)<br>
> goto end;<br>
> }<br>
><br>
> + /* TODO: mi support */<br>
> + if (lttng_opt_mi) {<br>
> + ret = -LTTNG_ERR_MI_NOT_IMPLEMENTED;<br>
> + ERR("mi option not supported");<br>
> + goto end;<br>
> + }<br>
> +<br>
> /* Ignore session name in case all sessions are to be destroyed */<br>
> if (opt_destroy_all) {<br>
> ret = destroy_all_sessions();<br>
> diff --git a/src/bin/lttng/commands/disable_channels.c b/src/bin/lttng/commands/disable_channels.c<br>
> index 1aa3916..da53d25 100644<br>
> --- a/src/bin/lttng/commands/disable_channels.c<br>
> +++ b/src/bin/lttng/commands/disable_channels.c<br>
> @@ -167,6 +167,13 @@ int cmd_disable_channels(int argc, const char **argv)<br>
> }<br>
> }<br>
><br>
> + /* TODO: mi support */<br>
> + if (lttng_opt_mi) {<br>
> + ret = -LTTNG_ERR_MI_NOT_IMPLEMENTED;<br>
> + ERR("mi option not supported");<br>
> + goto end;<br>
> + }<br>
> +<br>
> opt_channels = (char*) poptGetArg(pc);<br>
> if (opt_channels == NULL) {<br>
> ERR("Missing channel name(s).\n");<br>
> diff --git a/src/bin/lttng/commands/disable_events.c b/src/bin/lttng/commands/disable_events.c<br>
> index e712343..fb96b80 100644<br>
> --- a/src/bin/lttng/commands/disable_events.c<br>
> +++ b/src/bin/lttng/commands/disable_events.c<br>
> @@ -212,6 +212,13 @@ int cmd_disable_events(int argc, const char **argv)<br>
> }<br>
> }<br>
><br>
> + /* TODO: mi support */<br>
> + if (lttng_opt_mi) {<br>
> + ret = -LTTNG_ERR_MI_NOT_IMPLEMENTED;<br>
> + ERR("mi option not supported");<br>
> + goto end;<br>
> + }<br>
> +<br>
> opt_event_list = (char*) poptGetArg(pc);<br>
> if (opt_event_list == NULL && opt_disable_all == 0) {<br>
> ERR("Missing event name(s).\n");<br>
> diff --git a/src/bin/lttng/commands/enable_channels.c b/src/bin/lttng/commands/enable_channels.c<br>
> index 55fbae6..8ea405e 100644<br>
> --- a/src/bin/lttng/commands/enable_channels.c<br>
> +++ b/src/bin/lttng/commands/enable_channels.c<br>
> @@ -327,6 +327,13 @@ int cmd_enable_channels(int argc, const char **argv)<br>
> pc = poptGetContext(NULL, argc, argv, long_options, 0);<br>
> poptReadDefaultConfig(pc, 0);<br>
><br>
> + /* TODO: mi support */<br>
> + if (lttng_opt_mi) {<br>
> + ret = -LTTNG_ERR_MI_NOT_IMPLEMENTED;<br>
> + ERR("mi option not supported");<br>
> + goto end;<br>
> + }<br>
> +<br>
> while ((opt = poptGetNextOpt(pc)) != -1) {<br>
> switch (opt) {<br>
> case OPT_HELP:<br>
> diff --git a/src/bin/lttng/commands/enable_events.c b/src/bin/lttng/commands/enable_events.c<br>
> index bd2d997..8c7a73e 100644<br>
> --- a/src/bin/lttng/commands/enable_events.c<br>
> +++ b/src/bin/lttng/commands/enable_events.c<br>
> @@ -968,6 +968,13 @@ int cmd_enable_events(int argc, const char **argv)<br>
> pc = poptGetContext(NULL, argc, argv, long_options, 0);<br>
> poptReadDefaultConfig(pc, 0);<br>
><br>
> + /* TODO: mi support */<br>
> + if (lttng_opt_mi) {<br>
> + ret = -LTTNG_ERR_MI_NOT_IMPLEMENTED;<br>
> + ERR("mi option not supported");<br>
> + goto end;<br>
> + }<br>
> +<br>
> /* Default event type */<br>
> opt_event_type = LTTNG_EVENT_ALL;<br>
><br>
> diff --git a/src/bin/lttng/commands/list.c b/src/bin/lttng/commands/list.c<br>
> index f69b3ba..bbd674c 100644<br>
> --- a/src/bin/lttng/commands/list.c<br>
> +++ b/src/bin/lttng/commands/list.c<br>
> @@ -850,6 +850,13 @@ int cmd_list(int argc, const char **argv)<br>
> pc = poptGetContext(NULL, argc, argv, long_options, 0);<br>
> poptReadDefaultConfig(pc, 0);<br>
><br>
> + /* TODO: mi support */<br>
> + if (lttng_opt_mi) {<br>
> + ret = -LTTNG_ERR_MI_NOT_IMPLEMENTED;<br>
> + ERR("mi option not supported");<br>
> + goto end;<br>
> + }<br>
> +<br>
> while ((opt = poptGetNextOpt(pc)) != -1) {<br>
> switch (opt) {<br>
> case OPT_HELP:<br>
> diff --git a/src/bin/lttng/commands/load.c b/src/bin/lttng/commands/load.c<br>
> index e732baa..2cfc698 100644<br>
> --- a/src/bin/lttng/commands/load.c<br>
> +++ b/src/bin/lttng/commands/load.c<br>
> @@ -77,6 +77,13 @@ int cmd_load(int argc, const char **argv)<br>
> pc = poptGetContext(NULL, argc, argv, load_opts, 0);<br>
> poptReadDefaultConfig(pc, 0);<br>
><br>
> + /* TODO: mi support */<br>
> + if (lttng_opt_mi) {<br>
> + ret = -LTTNG_ERR_MI_NOT_IMPLEMENTED;<br>
> + ERR("mi option not supported");<br>
> + goto end;<br>
> + }<br>
> +<br>
> while ((opt = poptGetNextOpt(pc)) != -1) {<br>
> switch (opt) {<br>
> case OPT_HELP:<br>
> diff --git a/src/bin/lttng/commands/save.c b/src/bin/lttng/commands/save.c<br>
> index e8a4565..1aeb9f2 100644<br>
> --- a/src/bin/lttng/commands/save.c<br>
> +++ b/src/bin/lttng/commands/save.c<br>
> @@ -73,6 +73,13 @@ int cmd_save(int argc, const char **argv)<br>
> pc = poptGetContext(NULL, argc, argv, save_opts, 0);<br>
> poptReadDefaultConfig(pc, 0);<br>
><br>
> + /* TODO: mi support */<br>
> + if (lttng_opt_mi) {<br>
> + ret = -LTTNG_ERR_MI_NOT_IMPLEMENTED;<br>
> + ERR("mi option not supported");<br>
> + goto end;<br>
> + }<br>
> +<br>
> while ((opt = poptGetNextOpt(pc)) != -1) {<br>
> switch (opt) {<br>
> case OPT_HELP:<br>
> diff --git a/src/bin/lttng/commands/set_session.c b/src/bin/lttng/commands/set_session.c<br>
> index 4238016..54320df 100644<br>
> --- a/src/bin/lttng/commands/set_session.c<br>
> +++ b/src/bin/lttng/commands/set_session.c<br>
> @@ -92,6 +92,13 @@ int cmd_set_session(int argc, const char **argv)<br>
> pc = poptGetContext(NULL, argc, argv, long_options, 0);<br>
> poptReadDefaultConfig(pc, 0);<br>
><br>
> + /* TODO: mi support */<br>
> + if (lttng_opt_mi) {<br>
> + ret = -LTTNG_ERR_MI_NOT_IMPLEMENTED;<br>
> + ERR("mi option not supported");<br>
> + goto end;<br>
> + }<br>
> +<br>
> while ((opt = poptGetNextOpt(pc)) != -1) {<br>
> switch (opt) {<br>
> case OPT_HELP:<br>
> diff --git a/src/bin/lttng/commands/snapshot.c b/src/bin/lttng/commands/snapshot.c<br>
> index c704eee..21b5a05 100644<br>
> --- a/src/bin/lttng/commands/snapshot.c<br>
> +++ b/src/bin/lttng/commands/snapshot.c<br>
> @@ -446,6 +446,13 @@ int cmd_snapshot(int argc, const char **argv)<br>
> pc = poptGetContext(NULL, argc, argv, snapshot_opts, 0);<br>
> poptReadDefaultConfig(pc, 0);<br>
><br>
> + /* TODO: mi support */<br>
> + if (lttng_opt_mi) {<br>
> + ret = -LTTNG_ERR_MI_NOT_IMPLEMENTED;<br>
> + ERR("mi option not supported");<br>
> + goto end;<br>
> + }<br>
> +<br>
> while ((opt = poptGetNextOpt(pc)) != -1) {<br>
> switch (opt) {<br>
> case OPT_HELP:<br>
> diff --git a/src/bin/lttng/commands/start.c b/src/bin/lttng/commands/start.c<br>
> index 82122cc..82b3f5f 100644<br>
> --- a/src/bin/lttng/commands/start.c<br>
> +++ b/src/bin/lttng/commands/start.c<br>
> @@ -118,6 +118,13 @@ int cmd_start(int argc, const char **argv)<br>
> pc = poptGetContext(NULL, argc, argv, long_options, 0);<br>
> poptReadDefaultConfig(pc, 0);<br>
><br>
> + /* TODO: mi support */<br>
> + if (lttng_opt_mi) {<br>
> + ret = -LTTNG_ERR_MI_NOT_IMPLEMENTED;<br>
> + ERR("mi option not supported");<br>
> + goto end;<br>
> + }<br>
> +<br>
> while ((opt = poptGetNextOpt(pc)) != -1) {<br>
> switch (opt) {<br>
> case OPT_HELP:<br>
> diff --git a/src/bin/lttng/commands/stop.c b/src/bin/lttng/commands/stop.c<br>
> index 60a1dac..5de96d8 100644<br>
> --- a/src/bin/lttng/commands/stop.c<br>
> +++ b/src/bin/lttng/commands/stop.c<br>
> @@ -122,6 +122,13 @@ int cmd_stop(int argc, const char **argv)<br>
> pc = poptGetContext(NULL, argc, argv, long_options, 0);<br>
> poptReadDefaultConfig(pc, 0);<br>
><br>
> + /* TODO: mi support */<br>
> + if (lttng_opt_mi) {<br>
> + ret = -LTTNG_ERR_MI_NOT_IMPLEMENTED;<br>
> + ERR("mi option not supported");<br>
> + goto end;<br>
> + }<br>
> +<br>
> while ((opt = poptGetNextOpt(pc)) != -1) {<br>
> switch (opt) {<br>
> case OPT_HELP:<br>
> diff --git a/src/bin/lttng/commands/version.c b/src/bin/lttng/commands/version.c<br>
> index 7f69de3..5c7ebbf 100644<br>
> --- a/src/bin/lttng/commands/version.c<br>
> +++ b/src/bin/lttng/commands/version.c<br>
> @@ -25,6 +25,8 @@<br>
> #include <unistd.h><br>
> #include <config.h><br>
><br>
> +#include <common/mi-lttng.h><br>
> +<br>
> #include "../command.h"<br>
><br>
> enum {<br>
> @@ -32,6 +34,8 @@ enum {<br>
> OPT_LIST_OPTIONS,<br>
> };<br>
><br>
> +static const char *lttng_license = "lttng is free software and under the GPL license and part LGPL";<br>
> +<br>
> static struct poptOption long_options[] = {<br>
> /* longName, shortName, argInfo, argPtr, value, descrip, argDesc */<br>
> {"help", 'h', POPT_ARG_NONE, 0, OPT_HELP, 0, 0},<br>
> @@ -53,6 +57,78 @@ static void usage(FILE *ofp)<br>
> }<br>
><br>
> /*<br>
> + * create_version<br>
> + */<br>
> +static void create_version(struct mi_lttng_version *version)<br>
> +{<br>
> + strncpy(version->version, VERSION, NAME_MAX);<br>
> + version->version_major = VERSION_MAJOR;<br>
> + version->version_minor = VERSION_MINOR;<br>
> + version->version_patchlevel = VERSION_PATCHLEVEL;<br>
> + strncpy(version->version_name, VERSION_NAME, NAME_MAX);<br>
> + strncpy(version->package_url, PACKAGE_URL, NAME_MAX);<br>
> +}<br>
> +<br>
> +/*<br>
> + * print_mi<br>
> + */<br>
> +static int print_mi()<br>
> +{<br>
> + int ret;<br>
> + struct mi_writer *writer = NULL;<br>
> + struct mi_lttng_version version;<br>
> +<br>
> + create_version(&version);<br>
> +<br>
> + writer = mi_lttng_writer_create(fileno(stdout), lttng_opt_mi);<br>
> +<br>
> + if (!writer) {<br>
> + ret = -LTTNG_ERR_NOMEM;<br>
> + goto end;<br>
> + }<br>
> +<br>
> + /* Open the command element */<br>
> + ret = mi_lttng_writer_command_open(writer,<br>
> + mi_lttng_element_command_version);<br>
> + if (ret) {<br>
> + goto error;<br>
> + }<br>
> +<br>
> + /* Beginning of output */<br>
> + ret = mi_lttng_writer_open_element(writer,<br>
> + mi_lttng_element_command_output);<br>
> + if (ret) {<br>
> + goto error;<br>
> + }<br>
> +<br>
> + /* Print the machine interface of version */<br>
> + ret = mi_lttng_version(writer, &version,<br>
> + VERSION_DESCRIPTION, lttng_license);<br>
> + if (ret) {<br>
> + goto error;<br>
> + }<br>
> +<br>
> + /* Close the output element */<br>
> + ret = mi_lttng_writer_close_element(writer);<br>
> + if (ret) {<br>
> + goto error;<br>
> + }<br>
> +<br>
> + /* Close the command */<br>
> + ret = mi_lttng_writer_command_close(writer);<br>
> +<br>
> +error:<br>
> + /* Cleanup */<br>
> + if (writer && mi_lttng_writer_destroy(writer)) {<br>
> + /* Preserve original error code */<br>
> + ret = ret ? ret : LTTNG_ERR_MI_IO_FAIL;<br>
> + }<br>
> +<br>
> +end:<br>
> + return ret;<br>
> +}<br>
> +<br>
> +/*<br>
> * cmd_version<br>
> */<br>
> int cmd_version(int argc, const char **argv)<br>
> @@ -78,10 +154,14 @@ int cmd_version(int argc, const char **argv)<br>
> }<br>
> }<br>
><br>
> - MSG("lttng version " VERSION " - " VERSION_NAME);<br>
> - MSG("\n" VERSION_DESCRIPTION "\n");<br>
> - MSG("Web site: <a href="http://lttng.org" target="_blank">http://lttng.org</a>");<br>
> - MSG("\nlttng is free software and under the GPL license and part LGPL");<br>
> + if (lttng_opt_mi) {<br>
> + ret = print_mi();<br>
> + } else {<br>
> + MSG("lttng version " VERSION " - " VERSION_NAME);<br>
> + MSG("\n" VERSION_DESCRIPTION "\n");<br>
> + MSG("Web site: <a href="http://lttng.org" target="_blank">http://lttng.org</a>");<br>
> + MSG("\n%s", lttng_license);<br>
> + }<br>
><br>
> end:<br>
> poptFreeContext(pc);<br>
> diff --git a/src/bin/lttng/commands/view.c b/src/bin/lttng/commands/view.c<br>
> index adedf29..dcd4d66 100644<br>
> --- a/src/bin/lttng/commands/view.c<br>
> +++ b/src/bin/lttng/commands/view.c<br>
> @@ -445,6 +445,10 @@ int cmd_view(int argc, const char **argv)<br>
> pc = poptGetContext(NULL, argc, argv, long_options, 0);<br>
> poptReadDefaultConfig(pc, 0);<br>
><br>
> + if (lttng_opt_mi) {<br>
> + WARN("mi does not apply to view command");<br>
> + }<br>
> +<br>
> while ((opt = poptGetNextOpt(pc)) != -1) {<br>
> switch (opt) {<br>
> case OPT_HELP:<br>
> diff --git a/src/bin/lttng/lttng.c b/src/bin/lttng/lttng.c<br>
> index bc7577d..4510057 100644<br>
> --- a/src/bin/lttng/lttng.c<br>
> +++ b/src/bin/lttng/lttng.c<br>
> @@ -55,6 +55,7 @@ static struct option long_options[] = {<br>
> {"group", 1, NULL, 'g'},<br>
> {"verbose", 0, NULL, 'v'},<br>
> {"quiet", 0, NULL, 'q'},<br>
> + {"mi", 1, NULL, 'm'},<br>
> {"no-sessiond", 0, NULL, 'n'},<br>
> {"sessiond-path", 1, NULL, OPT_SESSION_PATH},<br>
> {"relayd-path", 1, NULL, OPT_RELAYD_PATH},<br>
> @@ -99,6 +100,8 @@ static void usage(FILE *ofp)<br>
> fprintf(ofp, " --list-commands Simple listing of lttng commands\n");<br>
> fprintf(ofp, " -v, --verbose Increase verbosity\n");<br>
> fprintf(ofp, " -q, --quiet Quiet mode\n");<br>
> + fprintf(ofp, " -m, --mi TYPE Machine Interface mode.\n");<br>
> + fprintf(ofp, " Type: xml\n");<br>
> fprintf(ofp, " -g, --group NAME Unix tracing group name. (default: tracing)\n");<br>
> fprintf(ofp, " -n, --no-sessiond Don't spawn a session daemon\n");<br>
> fprintf(ofp, " --sessiond-path PATH Session daemon full path\n");<br>
> @@ -136,6 +139,26 @@ static void version(FILE *ofp)<br>
> }<br>
><br>
> /*<br>
> + * mi_output_type<br>
> + *<br>
> + * Find the MI output type enum from a string<br>
> + * This function is for the support of<br>
> + * new output language.<br>
> + */<br>
> +static int mi_output_type(const char *output_type)<br>
> +{<br>
> + int ret = 0;<br>
> + if (!strncasecmp("xml", output_type, 3)) {<br>
> + ret = LTTNG_MI_XML;<br>
> + } else {<br>
> + /* Invalid output format */<br>
> + ERR("MI output format not supported");<br>
> + ret = -LTTNG_ERR_MI_OUTPUT_TYPE;<br>
> + }<br>
> + return ret;<br>
> +}<br>
> +<br>
> +/*<br>
> * list_options<br>
> *<br>
> * List options line by line. This is mostly for bash auto completion and to<br>
> @@ -426,7 +449,7 @@ static int parse_args(int argc, char **argv)<br>
> clean_exit(EXIT_FAILURE);<br>
> }<br>
><br>
> - while ((opt = getopt_long(argc, argv, "+Vhnvqg:", long_options, NULL)) != -1) {<br>
> + while ((opt = getopt_long(argc, argv, "+Vhnvqg:m:", long_options, NULL)) != -1) {<br>
> switch (opt) {<br>
> case 'V':<br>
> version(stdout);<br>
> @@ -442,6 +465,13 @@ static int parse_args(int argc, char **argv)<br>
> case 'q':<br>
> lttng_opt_quiet = 1;<br>
> break;<br>
> + case 'm':<br>
> + lttng_opt_mi = mi_output_type(optarg);<br>
> + if (lttng_opt_mi < 0) {<br>
> + ret = lttng_opt_mi;<br>
> + goto error;<br>
> + }<br>
> + break;<br>
> case 'g':<br>
> lttng_set_tracing_group(optarg);<br>
> break;<br>
> diff --git a/src/common/Makefile.am b/src/common/Makefile.am<br>
> index 1a764ae..dffab06 100644<br>
> --- a/src/common/Makefile.am<br>
> +++ b/src/common/Makefile.am<br>
> @@ -16,8 +16,11 @@ noinst_LTLIBRARIES = <a href="http://libcommon.la" target="_blank">libcommon.la</a><br>
> libcommon_la_SOURCES = error.h error.c utils.c utils.h runas.c runas.h \<br>
> common.h futex.c futex.h uri.c uri.h defaults.c \<br>
> pipe.c pipe.h readwrite.c readwrite.h \<br>
> + mi-lttng.h mi-lttng.c \<br>
> daemonize.c daemonize.h<br>
> -libcommon_la_LIBADD = -luuid<br>
> +libcommon_la_LIBADD = \<br>
> + -luuid \<br>
> + $(top_builddir)/src/common/config/<a href="http://libconfig.la" target="_blank">libconfig.la</a><br>
><br>
> # Consumer library<br>
> noinst_LTLIBRARIES += <a href="http://libconsumer.la" target="_blank">libconsumer.la</a><br>
> diff --git a/src/common/error.h b/src/common/error.h<br>
> index f8c0a1d..4e096b3 100644<br>
> --- a/src/common/error.h<br>
> +++ b/src/common/error.h<br>
> @@ -36,6 +36,7 @@<br>
><br>
> extern int lttng_opt_quiet;<br>
> extern int lttng_opt_verbose;<br>
> +extern int lttng_opt_mi;<br>
><br>
> /* Error type. */<br>
> #define PRINT_ERR 0x1<br>
> @@ -48,12 +49,18 @@ extern int lttng_opt_verbose;<br>
><br>
> /*<br>
> * Macro for printing message depending on command line option and verbosity.<br>
> + *<br>
> + * Machine interface:<br>
> + * We use lttng_opt_mi to suppress all normal msg to stdout. We don't<br>
> + * want any nested msg to show up when printing mi to stdout(if it's the case).<br>
> + * All warnings and errors should be printed to stderr as normal.<br>
> */<br>
> #define __lttng_print(type, fmt, args...) \<br>
> do { \<br>
> - if (lttng_opt_quiet == 0 && type == PRINT_MSG) { \<br>
> + if (lttng_opt_quiet == 0 && lttng_opt_mi == 0 && \<br>
> + type == PRINT_MSG) { \<br>
> fprintf(stdout, fmt, ## args); \<br>
> - } else if (lttng_opt_quiet == 0 && \<br>
> + } else if (lttng_opt_quiet == 0 && lttng_opt_mi == 0 && \<br>
> (((type & PRINT_DBG) && lttng_opt_verbose == 1) || \<br>
> ((type & (PRINT_DBG | PRINT_DBG2)) && \<br>
> lttng_opt_verbose == 2) || \<br>
> diff --git a/src/common/mi-lttng.c b/src/common/mi-lttng.c<br>
> new file mode 100644<br>
> index 0000000..bbec2c5<br>
> --- /dev/null<br>
> +++ b/src/common/mi-lttng.c<br>
> @@ -0,0 +1,284 @@<br>
> +/*<br>
> + * Copyright (C) 2014 - Jonathan Rajotte <<a href="mailto:jonathan.r.julien@gmail.com">jonathan.r.julien@gmail.com</a>><br>
> + * - Olivier Cotte <<a href="mailto:olivier.cotte@polymtl.ca">olivier.cotte@polymtl.ca</a>><br>
> + *<br>
> + * This program is free software; you can redistribute it and/or modify it<br>
> + * under the terms of the GNU General Public License, version 2 only, as<br>
> + * published by the Free Software Foundation.<br>
> + *<br>
> + * This program is distributed in the hope that it will be useful, but WITHOUT<br>
> + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or<br>
> + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for<br>
> + * more details.<br>
> + *<br>
> + * You should have received a copy of the GNU General Public License along with<br>
> + * this program; if not, write to the Free Software Foundation, Inc., 51<br>
> + * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.<br>
> + */<br>
> +<br>
> +#include <include/config.h><br>
> +#include <common/config/config.h><br>
> +#include "mi-lttng.h"<br>
> +<br>
> +/* Strings related to command */<br>
> +const char * const mi_lttng_element_command = "command";<br>
> +const char * const mi_lttng_element_command_version = "version";<br>
> +const char * const mi_lttng_element_command_list = "list";<br>
> +const char * const mi_lttng_element_command_name = "name";<br>
> +const char * const mi_lttng_element_command_output = "output";<br>
> +<br>
> +/* Strings related to command: version */<br>
> +const char * const mi_lttng_element_version = "version";<br>
> +const char * const mi_lttng_element_version_str = "string";<br>
> +const char * const mi_lttng_element_version_web = "url";<br>
> +const char * const mi_lttng_element_version_major = "major";<br>
> +const char * const mi_lttng_element_version_minor = "minor";<br>
> +const char * const mi_lttng_element_version_license = "license";<br>
> +const char * const mi_lttng_element_version_patch_level = "patchLevel";<br>
> +const char * const mi_lttng_element_version_description = "description";<br>
> +<br>
> +LTTNG_HIDDEN<br>
> +struct mi_writer *mi_lttng_writer_create(int fd_output, int mi_output_type)<br>
> +{<br>
> + struct mi_writer *mi_writer;<br>
> +<br>
> + mi_writer = zmalloc(sizeof(struct mi_writer));<br>
> + if (!mi_writer) {<br>
> + PERROR("zmalloc mi_writer_create");<br>
> + goto end;<br>
> + }<br>
> + if (mi_output_type == LTTNG_MI_XML) {<br>
> + mi_writer->writer = config_writer_create(fd_output);<br>
> + if (!mi_writer->writer) {<br>
> + goto err_destroy;<br>
> + }<br>
> + mi_writer->type = LTTNG_MI_XML;<br>
> + } else {<br>
> + goto err_destroy;<br>
> + }<br>
> +<br>
> +end:<br>
> + return mi_writer;<br>
> +<br>
> +err_destroy:<br>
> + free(mi_writer);<br>
> + return NULL;<br>
> +}<br>
> +<br>
> +LTTNG_HIDDEN<br>
> +int mi_lttng_writer_destroy(struct mi_writer *writer)<br>
> +{<br>
> + int ret;<br>
> +<br>
> + if (!writer) {<br>
> + ret = -EINVAL;<br>
> + goto end;<br>
> + }<br>
> +<br>
> + ret = config_writer_destroy(writer->writer);<br>
> + if (ret < 0) {<br>
> + goto end;<br>
> + }<br>
> +<br>
> + free(writer);<br>
> +end:<br>
> + return ret;<br>
> +}<br>
> +<br>
> +LTTNG_HIDDEN<br>
> +int mi_lttng_writer_command_open(struct mi_writer *writer, const char *command)<br>
> +{<br>
> + int ret;<br>
> + ret = mi_lttng_writer_open_element(writer, mi_lttng_element_command);<br>
> + if (ret) {<br>
> + goto end;<br>
> + }<br>
> + ret = mi_lttng_writer_write_element_string(writer,<br>
> + mi_lttng_element_command_name, command);<br>
> +end:<br>
> + return ret;<br>
> +}<br>
> +<br>
> +LTTNG_HIDDEN<br>
> +int mi_lttng_writer_command_close(struct mi_writer *writer)<br>
> +{<br>
> + return mi_lttng_writer_close_element(writer);<br>
> +}<br>
> +<br>
> +LTTNG_HIDDEN<br>
> +int mi_lttng_writer_open_element(struct mi_writer *writer,<br>
> + const char *element_name)<br>
> +{<br>
> + return config_writer_open_element(writer->writer, element_name);<br>
> +}<br>
> +<br>
> +LTTNG_HIDDEN<br>
> +int mi_lttng_writer_close_element(struct mi_writer *writer)<br>
> +{<br>
> + return config_writer_close_element(writer->writer);<br>
> +}<br>
> +<br>
> +LTTNG_HIDDEN<br>
> +int mi_lttng_writer_write_element_unsigned_int(struct mi_writer *writer,<br>
> + const char *element_name, uint64_t value)<br>
> +{<br>
> + return config_writer_write_element_unsigned_int(writer->writer,<br>
> + element_name, value);<br>
> +}<br>
> +<br>
> +LTTNG_HIDDEN<br>
> +int mi_lttng_writer_write_element_signed_int(struct mi_writer *writer,<br>
> + const char *element_name, int64_t value)<br>
> +{<br>
> + return config_writer_write_element_signed_int(writer->writer,<br>
> + element_name, value);<br>
> +}<br>
> +<br>
> +LTTNG_HIDDEN<br>
> +int mi_lttng_writer_write_element_bool(struct mi_writer *writer,<br>
> + const char *element_name, int value)<br>
> +{<br>
> + return config_writer_write_element_bool(writer->writer,<br>
> + element_name, value);<br>
> +}<br>
> +<br>
> +LTTNG_HIDDEN<br>
> +int mi_lttng_writer_write_element_string(struct mi_writer *writer,<br>
> + const char *element_name, const char *value)<br>
> +{<br>
> + return config_writer_write_element_string(writer->writer,<br>
> + element_name, value);<br>
> +}<br>
> +<br>
> +LTTNG_HIDDEN<br>
> +int mi_lttng_version(struct mi_writer *writer, struct mi_lttng_version *version,<br>
> + const char *lttng_description, const char *lttng_license)<br>
> +{<br>
> + int ret;<br>
> +<br>
> + /* Open version */<br>
> + ret = mi_lttng_writer_open_element(writer, mi_lttng_element_version);<br>
> + if (ret) {<br>
> + goto end;<br>
> + }<br>
> +<br>
> + /* Version string (contain info like rc etc.) */<br>
> + ret = mi_lttng_writer_write_element_string(writer,<br>
> + mi_lttng_element_version_str, VERSION);<br>
> + if (ret) {<br>
> + goto end;<br>
> + }<br>
> +<br>
> + /* Major version number */<br>
> + ret = mi_lttng_writer_write_element_unsigned_int(writer,<br>
> + mi_lttng_element_version_major, version->version_major);<br>
> + if (ret) {<br>
> + goto end;<br>
> + }<br>
> +<br>
> + /* Minor version number */<br>
> + ret = mi_lttng_writer_write_element_unsigned_int(writer,<br>
> + mi_lttng_element_version_minor, version->version_minor);<br>
> + if (ret) {<br>
> + goto end;<br>
> + }<br>
> +<br>
> + /* Patch number */<br>
> + ret = mi_lttng_writer_write_element_unsigned_int(writer,<br>
> + mi_lttng_element_version_patch_level, version->version_patchlevel);<br>
> + if (ret) {<br>
> + goto end;<br>
> + }<br>
> +<br>
> + /* Name of the version */<br>
> + ret = mi_lttng_writer_write_element_string(writer,<br>
> + config_element_name, version->version_name);<br>
> + if (ret) {<br>
> + goto end;<br>
> + }<br>
> +<br>
> + /* Description mostly related to beer... */<br>
> + ret = mi_lttng_writer_write_element_string(writer,<br>
> + mi_lttng_element_version_description, lttng_description);<br>
> + if (ret) {<br>
> + goto end;<br>
> + }<br>
> +<br>
> + /* url */<br>
> + ret = mi_lttng_writer_write_element_string(writer,<br>
> + mi_lttng_element_version_web, version->package_url);<br>
> + if (ret) {<br>
> + goto end;<br>
> + }<br>
> +<br>
> + /* License: free as in free beer...no...*speech* */<br>
> + ret = mi_lttng_writer_write_element_string(writer,<br>
> + mi_lttng_element_version_license, lttng_license);<br>
> + if (ret) {<br>
> + goto end;<br>
> + }<br>
> +<br>
> + /* Close version element */<br>
> + ret = mi_lttng_writer_close_element(writer);<br>
> +<br>
> +end:<br>
> + return ret;<br>
> +}<br>
> +<br>
> +LTTNG_HIDDEN<br>
> +int mi_lttng_session(struct mi_writer *writer,<br>
> + struct lttng_session *session, int is_open)<br>
> +{<br>
> + int ret;<br>
> +<br>
> + /* open sessions element */<br>
> + ret = mi_lttng_writer_open_element(writer,<br>
> + config_element_session);<br>
> + if (ret) {<br>
> + goto end;<br>
> + }<br>
> +<br>
> + /* Name of the session */<br>
> + ret = mi_lttng_writer_write_element_string(writer,<br>
> + config_element_name, session->name);<br>
> + if (ret) {<br>
> + goto end;<br>
> + }<br>
> +<br>
> + /* path */<br>
> + ret = mi_lttng_writer_write_element_string(writer,<br>
> + config_element_path, session->path);<br>
> + if (ret) {<br>
> + goto end;<br>
> + }<br>
> +<br>
> + /* enabled ? */<br>
> + ret = mi_lttng_writer_write_element_unsigned_int(writer,<br>
> + config_element_enabled, session->enabled);<br>
> + if (ret) {<br>
> + goto end;<br>
> + }<br>
> +<br>
> + /* snapshot mode */<br>
> + ret = mi_lttng_writer_write_element_unsigned_int(writer,<br>
> + config_element_snapshot_mode, session->snapshot_mode);<br>
> + if (ret) {<br>
> + goto end;<br>
> + }<br>
> +<br>
> + /* live timer interval in usec */<br>
> + ret = mi_lttng_writer_write_element_unsigned_int(writer,<br>
> + config_element_live_timer_interval,<br>
> + session->live_timer_interval);<br>
> + if (ret) {<br>
> + goto end;<br>
> + }<br>
> +<br>
> + if (!is_open) {<br>
> + /* Closing session element */<br>
> + ret = mi_lttng_writer_close_element(writer);<br>
> + }<br>
> +end:<br>
> + return ret;<br>
> +<br>
> +}<br>
> diff --git a/src/common/mi-lttng.h b/src/common/mi-lttng.h<br>
> new file mode 100644<br>
> index 0000000..69ec0f5<br>
> --- /dev/null<br>
> +++ b/src/common/mi-lttng.h<br>
> @@ -0,0 +1,230 @@<br>
> +/*<br>
> + * Copyright (C) 2014 - Jonathan Rajotte <<a href="mailto:jonathan.r.julien@gmail.com">jonathan.r.julien@gmail.com</a>><br>
> + * - Olivier Cotte <<a href="mailto:olivier.cotte@polymtl.ca">olivier.cotte@polymtl.ca</a>><br>
> + *<br>
> + * This program is free software; you can redistribute it and/or modify it<br>
> + * under the terms of the GNU General Public License, version 2 only, as<br>
> + * published by the Free Software Foundation.<br>
> + *<br>
> + * This program is distributed in the hope that it will be useful, but WITHOUT<br>
> + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or<br>
> + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for<br>
> + * more details.<br>
> + *<br>
> + * You should have received a copy of the GNU General Public License along with<br>
> + * this program; if not, write to the Free Software Foundation, Inc., 51<br>
> + * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.<br>
> + */<br>
> +<br>
> +#ifndef _MI_LTTNG_H<br>
> +#define _MI_LTTNG_H<br>
> +<br>
> +#include <common/error.h><br>
> +#include <common/macros.h><br>
> +#include <common/config/config.h><br>
> +<br>
> +#include <lttng/lttng.h><br>
> +<br>
> +#include <stdint.h><br>
> +<br>
> +<br>
> +/* Instance of a machine interface writer. */<br>
> +struct mi_writer {<br>
> + struct config_writer *writer;<br>
> + enum lttng_mi_output_type type;<br>
> +};<br>
> +<br>
> +/*<br>
> + * Version information for the machine interface.<br>
> + */<br>
> +struct mi_lttng_version {<br>
> + char version[NAME_MAX]; /* Version number of package */<br>
> + uint32_t version_major; /* LTTng-Tools major version number */<br>
> + uint32_t version_minor; /* LTTng-Tools minor version number */<br>
> + uint32_t version_patchlevel; /* LTTng-Tools patchlevel version number */<br>
> + char version_name[NAME_MAX];<br>
> + char package_url[NAME_MAX]; /* Define to the home page for this package. */<br>
> +};<br>
> +<br>
> +/* Strings related to command */<br>
> +const char * const mi_lttng_element_command;<br>
> +const char * const mi_lttng_element_command_version;<br>
> +const char * const mi_lttng_element_command_list;<br>
> +const char * const mi_lttng_element_command_name;<br>
> +const char * const mi_lttng_element_command_output;<br>
> +<br>
> +/* Strings related to command: version */<br>
> +const char * const mi_lttng_element_version;<br>
> +const char * const mi_lttng_element_version_str;<br>
> +const char * const mi_lttng_element_version_web;<br>
> +const char * const mi_lttng_element_version_major;<br>
> +const char * const mi_lttng_element_version_minor;<br>
> +const char * const mi_lttng_element_version_license;<br>
> +const char * const mi_lttng_element_version_patch_level;<br>
> +const char * const mi_lttng_element_version_description;<br>
> +<br>
> +/*<br>
> + * Create an instance of a machine interface writer.<br>
> + *<br>
> + * fd_output File to which the XML content must be written. The file will be<br>
> + * closed once the mi_writer has been destroyed.<br>
> + *<br>
> + * Returns an instance of a machine interface writer on success, NULL on<br>
> + * error.<br>
> + */<br>
> +struct mi_writer *mi_lttng_writer_create(int fd_output, int mi_output_type);<br>
> +<br>
> +/*<br>
> + * Destroy an instance of a machine interface writer.<br>
> + *<br>
> + * writer An instance of a machine interface writer.<br>
> + *<br>
> + * Returns zero if the XML document could be closed cleanly. Negative values<br>
> + * indicate an error.<br>
> + */<br>
> +int mi_lttng_writer_destroy(struct mi_writer *writer);<br>
> +<br>
> +/*<br>
> + * Open a command tag and add it's name node.<br>
> + *<br>
> + * writer An instance of a machine interface writer.<br>
> + *<br>
> + * command The command name.<br>
> + *<br>
> + * Returns zero if the XML document could be closed cleanly.<br>
> + * Negative values indicate an error.<br>
> + */<br>
> +int mi_lttng_writer_command_open(struct mi_writer *writer, const char *command);<br>
> +<br>
> +/*<br>
> + * Close a command tag.<br>
> + *<br>
> + * writer An instance of a machine interface writer.<br>
> + *<br>
> + * Returns zero if the XML document could be closed cleanly.<br>
> + * Negative values indicate an error.<br>
> + */<br>
> +int mi_lttng_writer_command_close(struct mi_writer *writer);<br>
> +<br>
> +/*<br>
> + * Open an element tag.<br>
> + *<br>
> + * writer An instance of a machine interface writer.<br>
> + *<br>
> + * element_name Element tag name.<br>
> + *<br>
> + * Returns zero if the XML document could be closed cleanly.<br>
> + * Negative values indicate an error.<br>
> + */<br>
> +int mi_lttng_writer_open_element(struct mi_writer *writer,<br>
> + const char *element_name);<br>
> +<br>
> +/*<br>
> + * Close the current element tag.<br>
> + *<br>
> + * writer An instance of a machine interface writer.<br>
> + *<br>
> + * Returns zero if the XML document could be closed cleanly.<br>
> + * Negative values indicate an error.<br>
> + */<br>
> +int mi_lttng_writer_close_element(struct mi_writer *writer);<br>
> +<br>
> +/*<br>
> + * Write an element of type unsigned int.<br>
> + *<br>
> + * writer An instance of a machine interface writer.<br>
> + *<br>
> + * element_name Element name.<br>
> + *<br>
> + * value Unsigned int value of the element<br>
> + *<br>
> + * Returns zero if the element's value could be written.<br>
> + * Negative values indicate an error.<br>
> + */<br>
> +int mi_lttng_writer_write_element_unsigned_int(struct mi_writer *writer,<br>
> + const char *element_name, uint64_t value);<br>
> +<br>
> +/*<br>
> + * Write an element of type signed int.<br>
> + *<br>
> + * writer An instance of a machine interface writer.<br>
> + *<br>
> + * element_name Element name.<br>
> + *<br>
> + * value Signed int value of the element<br>
> + *<br>
> + * Returns zero if the element's value could be written.<br>
> + * Negative values indicate an error.<br>
> + */<br>
> +int mi_lttng_writer_write_element_signed_int(struct mi_writer *writer,<br>
> + const char *element_name, int64_t value);<br>
> +<br>
> +/*<br>
> + * Write an element of type boolean.<br>
> + *<br>
> + * writer An instance of a machine interface writer.<br>
> + *<br>
> + * element_name Element name.<br>
> + *<br>
> + * value Boolean value of the element<br>
> + *<br>
> + * Returns zero if the element's value could be written.<br>
> + * Negative values indicate an error.<br>
> + */<br>
> +int mi_lttng_writer_write_element_bool(struct mi_writer *writer,<br>
> + const char *element_name, int value);<br>
> +<br>
> +/*<br>
> + * Write an element of type string.<br>
> + *<br>
> + * writer An instance of a machine interface writer.<br>
> + *<br>
> + * element_name Element name.<br>
> + *<br>
> + * value String value of the element<br>
> + *<br>
> + * Returns zero if the element's value could be written.<br>
> + * Negative values indicate an error.<br>
> + */<br>
> +int mi_lttng_writer_write_element_string(struct mi_writer *writer,<br>
> + const char *element_name, const char *value);<br>
> +<br>
> +/*<br>
> + * Machine interface of struct version.<br>
> + *<br>
> + * writer An instance of a machine interface writer.<br>
> + *<br>
> + * version Version struct.<br>
> + *<br>
> + * lttng_description String value of the version description.<br>
> + *<br>
> + * lttng_license String value of the version license.<br>
> + *<br>
> + * Returns zero if the element's value could be written.<br>
> + * Negative values indicate an error.<br>
> + */<br>
> +int mi_lttng_version(struct mi_writer *writer, struct mi_lttng_version *version,<br>
> + const char *lttng_description, const char *lttng_license);<br>
> +<br>
> +/*<br>
> + * Machine interface of struct session.<br>
> + *<br>
> + * writer An instance of a machine interface writer<br>
> + *<br>
> + * session An instance of a session<br>
> + *<br>
> + * isOpen Define if we close the session element<br>
> + * This should be use carefully and the client<br>
> + * need to close the session element.<br>
> + * Use case: nested addition information on a session<br>
> + * ex: domain,channel event.<br>
> + * 0-> False<br>
> + * 1-> True<br>
> + *<br>
> + * Returns zero if the element's value could be written.<br>
> + * Negative values indicate an error.<br>
> + */<br>
> +int mi_lttng_session(struct mi_writer *writer,<br>
> + struct lttng_session *session, int isOpen);<br>
> +<br>
> +#endif /* _MI_LTTNG_H */<br>
> diff --git a/src/lib/lttng-ctl/lttng-ctl.c b/src/lib/lttng-ctl/lttng-ctl.c<br>
> index 100e587..7dd9828 100644<br>
> --- a/src/lib/lttng-ctl/lttng-ctl.c<br>
> +++ b/src/lib/lttng-ctl/lttng-ctl.c<br>
> @@ -74,6 +74,7 @@ static int connected;<br>
> */<br>
> int lttng_opt_quiet;<br>
> int lttng_opt_verbose;<br>
> +int lttng_opt_mi;<br>
><br>
> /*<br>
> * Copy string from src to dst and enforce null terminated byte.<br>
> diff --git a/tests/unit/ini_config/ini_config.c b/tests/unit/ini_config/ini_config.c<br>
> index 38fe5f4..29935ef 100644<br>
> --- a/tests/unit/ini_config/ini_config.c<br>
> +++ b/tests/unit/ini_config/ini_config.c<br>
> @@ -31,6 +31,7 @@ struct state {<br>
><br>
> int lttng_opt_quiet = 1;<br>
> int lttng_opt_verbose = 0;<br>
> +int lttng_opt_mi;<br>
><br>
> int entry_handler(const struct config_entry *entry,<br>
> struct state *state)<br>
> diff --git a/tests/unit/test_kernel_data.c b/tests/unit/test_kernel_data.c<br>
> index e2182e9..2639be4 100644<br>
> --- a/tests/unit/test_kernel_data.c<br>
> +++ b/tests/unit/test_kernel_data.c<br>
> @@ -38,6 +38,7 @@<br>
> /* For error.h */<br>
> int lttng_opt_quiet = 1;<br>
> int lttng_opt_verbose;<br>
> +int lttng_opt_mi;<br>
><br>
> int ust_consumerd32_fd;<br>
> int ust_consumerd64_fd;<br>
> diff --git a/tests/unit/test_session.c b/tests/unit/test_session.c<br>
> index a0e84e9..4f90c33 100644<br>
> --- a/tests/unit/test_session.c<br>
> +++ b/tests/unit/test_session.c<br>
> @@ -46,6 +46,7 @@ static struct ltt_session_list *session_list;<br>
> /* For error.h */<br>
> int lttng_opt_quiet = 1;<br>
> int lttng_opt_verbose = 0;<br>
> +int lttng_opt_mi;<br>
><br>
> int ust_consumerd32_fd;<br>
> int ust_consumerd64_fd;<br>
> diff --git a/tests/unit/test_uri.c b/tests/unit/test_uri.c<br>
> index 7cac95d..432e2b3 100644<br>
> --- a/tests/unit/test_uri.c<br>
> +++ b/tests/unit/test_uri.c<br>
> @@ -25,6 +25,7 @@<br>
> /* For error.h */<br>
> int lttng_opt_quiet = 1;<br>
> int lttng_opt_verbose = 3;<br>
> +int lttng_opt_mi;<br>
><br>
> /* Number of TAP tests in this file */<br>
> #define NUM_TESTS 11<br>
> diff --git a/tests/unit/test_ust_data.c b/tests/unit/test_ust_data.c<br>
> index 150d5da..dd00089 100644<br>
> --- a/tests/unit/test_ust_data.c<br>
> +++ b/tests/unit/test_ust_data.c<br>
> @@ -44,6 +44,7 @@<br>
> /* For error.h */<br>
> int lttng_opt_quiet = 1;<br>
> int lttng_opt_verbose;<br>
> +int lttng_opt_mi;<br>
><br>
> int ust_consumerd32_fd;<br>
> int ust_consumerd64_fd;<br>
> diff --git a/tests/unit/test_utils_expand_path.c b/tests/unit/test_utils_expand_path.c<br>
> index fe709ac..f863b5d 100644<br>
> --- a/tests/unit/test_utils_expand_path.c<br>
> +++ b/tests/unit/test_utils_expand_path.c<br>
> @@ -31,6 +31,7 @@<br>
> /* For error.h */<br>
> int lttng_opt_quiet = 1;<br>
> int lttng_opt_verbose = 3;<br>
> +int lttng_opt_mi;<br>
><br>
> struct valid_test_input {<br>
> char *input;<br>
> diff --git a/tests/unit/test_utils_parse_size_suffix.c b/tests/unit/test_utils_parse_size_suffix.c<br>
> index 990aa1b..f81278d 100644<br>
> --- a/tests/unit/test_utils_parse_size_suffix.c<br>
> +++ b/tests/unit/test_utils_parse_size_suffix.c<br>
> @@ -26,6 +26,7 @@<br>
> /* For error.h */<br>
> int lttng_opt_quiet = 1;<br>
> int lttng_opt_verbose = 3;<br>
> +int lttng_opt_mi;<br>
><br>
> struct valid_test_input {<br>
> char *input;<br>
> --<br>
> 1.8.3.2<br>
><br>
<br>
<br>
</div></div>> _______________________________________________<br>
> lttng-dev mailing list<br>
> <a href="mailto:lttng-dev@lists.lttng.org">lttng-dev@lists.lttng.org</a><br>
> <a href="http://lists.lttng.org/cgi-bin/mailman/listinfo/lttng-dev" target="_blank">http://lists.lttng.org/cgi-bin/mailman/listinfo/lttng-dev</a><br>
<br>
</blockquote></div><br><br clear="all"><div><br></div>-- <br><div dir="ltr">Jonathan Rajotte Julien<div>Chargé de laboratoire, INF1995<br><div>Polytechnique Montréal</div></div></div>
</div>