Add initial support for profile specific options
[fio.git] / options.c
index 1c07982d41cf23497862289d814b294a6e1edcb8..2f38b4ae75edddd208d16b2624dac3cf40b4203a 100644 (file)
--- a/options.c
+++ b/options.c
@@ -14,8 +14,9 @@
 #include "verify.h"
 #include "parse.h"
 #include "lib/fls.h"
+#include "options.h"
 
-#define td_var_offset(var)     ((size_t) &((struct thread_options *)0)->var)
+static FLIST_HEAD(ext_opt_list);
 
 /*
  * Check if mmap/mmaphuge has a :/foo/bar/file at the end. If so, return that.
@@ -1725,14 +1726,8 @@ static struct fio_option options[] = {
        },
        {
                .name   = "profile",
-               .type   = FIO_OPT_STR,
+               .type   = FIO_OPT_STR_STORE,
                .off1   = td_var_offset(profile),
-               .posval = {
-                         { .ival = "tiobench",
-                           .oval = PROFILE_TIOBENCH,
-                           .help = "Perform tiobench like test",
-                         },
-               },
                .help   = "Select a specific builtin performance test",
        },
        {
@@ -1946,7 +1941,7 @@ int fio_options_parse(struct thread_data *td, char **opts, int num_opts)
 
        for (ret = 0, i = 0; i < num_opts; i++) {
                opts[i] = fio_keyword_replace(opts[i]);
-               ret |= parse_option(opts[i], options, td);
+               ret |= parse_option(opts[i], options, &ext_opt_list, td);
        }
 
        return ret;
@@ -1954,7 +1949,7 @@ int fio_options_parse(struct thread_data *td, char **opts, int num_opts)
 
 int fio_cmd_option_parse(struct thread_data *td, const char *opt, char *val)
 {
-       return parse_cmd_option(opt, val, options, td);
+       return parse_cmd_option(opt, val, options, &ext_opt_list, td);
 }
 
 void fio_fill_default_options(struct thread_data *td)
@@ -1964,7 +1959,7 @@ void fio_fill_default_options(struct thread_data *td)
 
 int fio_show_option_help(const char *opt)
 {
-       return show_cmd_help(options, opt);
+       return show_cmd_help(options, &ext_opt_list, opt);
 }
 
 static void __options_mem(struct thread_data *td, int alloc)
@@ -2017,3 +2012,24 @@ unsigned int fio_get_kb_base(void *data)
 
        return kb_base;
 }
+
+void register_ext_option(struct ext_option *eopt)
+{
+       dprint(FD_PARSE, "register option '%s'\n", eopt->o.name);
+       option_init(&eopt->o);
+       flist_add_tail(&eopt->list, &ext_opt_list);
+}
+
+void prune_profile_options(const char *prof_name)
+{
+       struct ext_option *eo;
+       struct flist_head *n, *tmp;
+
+       flist_for_each_safe(n, tmp, &ext_opt_list) {
+               eo = flist_entry(n, struct ext_option, list);
+               if (strcmp(eo->prof_name, prof_name))
+                       continue;
+               flist_del(&eo->list);
+               free(eo);
+       }
+}