Add --omit-name and --omit-output options to the save command
authorJérémie Galarneau <jeremie.galarneau@efficios.com>
Tue, 14 Jun 2016 16:42:01 +0000 (12:42 -0400)
committerJonathan Rajotte <jonathan.rajotte-julien@efficios.com>
Wed, 29 Jun 2016 15:47:19 +0000 (11:47 -0400)
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
src/bin/lttng/commands/save.c
src/common/config/config-session-abi.h
src/common/config/session-config.c
src/common/mi-lttng-3.0.xsd

index ee3e17c66e2b3fe89dc921348aeb5005a12f1dc9..7370af01e3e3032409c962a483d6b8a3d431f8c1 100644 (file)
@@ -31,6 +31,8 @@
 static char *opt_output_path;
 static bool opt_force;
 static bool opt_save_all;
+static bool opt_omit_name;
+static bool opt_omit_output;
 static struct mi_writer *writer;
 
 enum {
@@ -38,6 +40,8 @@ enum {
        OPT_ALL,
        OPT_FORCE,
        OPT_LIST_OPTIONS,
+       OPT_OMIT_NAME,
+       OPT_OMIT_OUTPUT,
 };
 
 static struct poptOption save_opts[] = {
@@ -47,6 +51,8 @@ static struct poptOption save_opts[] = {
        {"output-path", 'o', POPT_ARG_STRING, &opt_output_path, 0, NULL, NULL},
        {"force",       'f', POPT_ARG_NONE, NULL, OPT_FORCE, NULL, NULL},
        {"list-options",  0, POPT_ARG_NONE, NULL, OPT_LIST_OPTIONS, NULL, NULL},
+       {"omit-name",     0, POPT_ARG_NONE, NULL, OPT_OMIT_NAME, NULL, NULL},
+       {"omit-output",   0, POPT_ARG_NONE, NULL, OPT_OMIT_OUTPUT, NULL, NULL},
        {0, 0, 0, 0, 0, 0, 0}
 };
 
@@ -108,6 +114,26 @@ static int mi_save_print(const char *session_name)
                }
        }
 
+       /* Omit session name. */
+       if (opt_omit_name) {
+               /* Only print if true; assume default value otherwise. */
+               ret = mi_lttng_writer_write_element_bool(writer,
+                               config_element_omit_name, opt_omit_name);
+               if (ret) {
+                       goto end;
+               }
+       }
+
+       /* Omit session output. */
+       if (opt_omit_output) {
+               /* Only print if true; assume default value otherwise. */
+               ret = mi_lttng_writer_write_element_bool(writer,
+                               config_element_omit_output, opt_omit_output);
+               if (ret) {
+                       goto end;
+               }
+       }
+
        /* Close save element */
        ret = mi_lttng_writer_close_element(writer);
 end:
@@ -142,6 +168,12 @@ int cmd_save(int argc, const char **argv)
                case OPT_LIST_OPTIONS:
                        list_cmd_options(stdout, save_opts);
                        goto end;
+               case OPT_OMIT_NAME:
+                       opt_omit_name = true;
+                       break;
+               case OPT_OMIT_OUTPUT:
+                       opt_omit_output = true;
+                       break;
                default:
                        ret = CMD_UNDEFINED;
                        goto end;
@@ -179,6 +211,20 @@ int cmd_save(int argc, const char **argv)
                goto end_destroy;
        }
 
+       if (opt_omit_name) {
+               if (lttng_save_session_attr_set_omit_name(attr, true)) {
+                       ret = CMD_ERROR;
+                       goto end_destroy;
+               }
+       }
+
+       if (opt_omit_output) {
+               if (lttng_save_session_attr_set_omit_output(attr, true)) {
+                       ret = CMD_ERROR;
+                       goto end_destroy;
+               }
+       }
+
        /* Mi check */
        if (lttng_opt_mi) {
                writer = mi_lttng_writer_create(fileno(stdout), lttng_opt_mi);
index 66d9cca73d4405084c264f215ed4b5247d411ca5..00757363fb7dc0bed3b3f2522b5d8f1590774837 100644 (file)
@@ -78,6 +78,8 @@ extern const char * const config_element_pid_tracker;
 extern const char * const config_element_trackers;
 extern const char * const config_element_targets;
 extern const char * const config_element_target_pid;
+extern const char * const config_element_omit_name;
+extern const char * const config_element_omit_output;
 
 extern const char * const config_domain_type_kernel;
 extern const char * const config_domain_type_ust;
index 6c639af440143ab00d31631257a311b51160f8f6..f032e1a34c558fa682feb3ab2a62d684052811d5 100644 (file)
@@ -128,6 +128,8 @@ const char * const config_element_pid_tracker = "pid_tracker";
 const char * const config_element_trackers = "trackers";
 const char * const config_element_targets = "targets";
 const char * const config_element_target_pid = "pid_target";
+const char * const config_element_omit_name = "omit_name";
+const char * const config_element_omit_output = "omit_output";
 
 const char * const config_domain_type_kernel = "KERNEL";
 const char * const config_domain_type_ust = "UST";
index 436a9893b3698cafeb8a87eeb2da97a8d26ec6ed..2c29c9cea815c6b7ffdd37bed32f0768d31d8ba8 100644 (file)
@@ -417,6 +417,8 @@ THE SOFTWARE.
                <xs:all>
                        <xs:element name="session" type="tns:session_type" />
                        <xs:element name="path" type="xs:string" />
+                       <xs:element name="omit_name" type="xs:boolean" minOccurs="0" />
+                       <xs:element name="omit_output" type="xs:boolean" minOccurs="0" />
                </xs:all>
        </xs:complexType>
 
This page took 0.02935 seconds and 5 git commands to generate.