Ensure that command line options also end up in json output
authorJens Axboe <axboe@fb.com>
Thu, 17 Dec 2015 15:32:15 +0000 (08:32 -0700)
committerJens Axboe <axboe@fb.com>
Thu, 17 Dec 2015 15:32:15 +0000 (08:32 -0700)
Signed-off-by: Jens Axboe <axboe@fb.com>
options.c
parse.c
parse.h

index 964e2634b5dd16c1af4cd1233019d9a1a63bd752..33cc6fe6c47a69fd21f786e7d1e904f5acd1c25b 100644 (file)
--- a/options.c
+++ b/options.c
@@ -4143,7 +4143,7 @@ int fio_cmd_option_parse(struct thread_data *td, const char *opt, char *val)
 {
        int ret;
 
-       ret = parse_cmd_option(opt, val, fio_options, td);
+       ret = parse_cmd_option(opt, val, fio_options, td, &td->opt_list);
        if (!ret) {
                struct fio_option *o;
 
@@ -4158,7 +4158,8 @@ int fio_cmd_option_parse(struct thread_data *td, const char *opt, char *val)
 int fio_cmd_ioengine_option_parse(struct thread_data *td, const char *opt,
                                char *val)
 {
-       return parse_cmd_option(opt, val, td->io_ops->options, td->eo);
+       return parse_cmd_option(opt, val, td->io_ops->options, td->eo,
+                                       &td->opt_list);
 }
 
 void fio_fill_default_options(struct thread_data *td)
diff --git a/parse.c b/parse.c
index 0ef00b81cda60ffb6209a0c3b305b370aeee8810..ac1bee9c296ece240613d8759725aa2efe2b4233 100644 (file)
--- a/parse.c
+++ b/parse.c
@@ -960,8 +960,27 @@ void sort_options(char **opts, struct fio_option *options, int num_opts)
        __fio_options = NULL;
 }
 
+static void add_to_dump_list(struct fio_option *o, struct flist_head *dump_list,
+                            const char *post)
+{
+       struct print_option *p;
+
+       if (!dump_list)
+               return;
+
+       p = malloc(sizeof(*p));
+       p->name = strdup(o->name);
+       if (post)
+               p->value = strdup(post);
+       else
+               p->value = NULL;
+
+       flist_add_tail(&p->list, dump_list);
+}
+
 int parse_cmd_option(const char *opt, const char *val,
-                    struct fio_option *options, void *data)
+                    struct fio_option *options, void *data,
+                    struct flist_head *dump_list)
 {
        struct fio_option *o;
 
@@ -971,11 +990,13 @@ int parse_cmd_option(const char *opt, const char *val,
                return 1;
        }
 
-       if (!handle_option(o, val, data))
-               return 0;
+       if (handle_option(o, val, data)) {
+               log_err("fio: failed parsing %s=%s\n", opt, val);
+               return 1;
+       }
 
-       log_err("fio: failed parsing %s=%s\n", opt, val);
-       return 1;
+       add_to_dump_list(o, dump_list, val);
+       return 0;
 }
 
 int parse_option(char *opt, const char *input,
@@ -1006,18 +1027,7 @@ int parse_option(char *opt, const char *input,
                return 1;
        }
 
-       if (dump_list) {
-               struct print_option *p = malloc(sizeof(*p));
-
-               p->name = strdup((*o)->name);
-               if (post)
-                       p->value = strdup(post);
-               else
-                       p->value = NULL;
-
-               flist_add_tail(&p->list, dump_list);
-       }
-
+       add_to_dump_list(*o, dump_list, post);
        return 0;
 }
 
diff --git a/parse.h b/parse.h
index 188281050b1138835dbdc212e688309e8098e8de..3ba804797fe1c23658fc1f51bdd82ac8d2287a51 100644 (file)
--- a/parse.h
+++ b/parse.h
@@ -82,7 +82,7 @@ typedef int (str_cb_fn)(void *, char *);
 
 extern int parse_option(char *, const char *, struct fio_option *, struct fio_option **, void *, struct flist_head *);
 extern void sort_options(char **, struct fio_option *, int);
-extern int parse_cmd_option(const char *t, const char *l, struct fio_option *, void *);
+extern int parse_cmd_option(const char *t, const char *l, struct fio_option *, void *, struct flist_head *);
 extern int show_cmd_help(struct fio_option *, const char *);
 extern void fill_default_options(void *, struct fio_option *);
 extern void option_init(struct fio_option *);