Add initial support for profile specific options
[fio.git] / profile.c
index e56ca29b8060fa84f8ea414a8418992d6f2ead07..9f588a17bfc75e9f91db53ec1ae8a44cff02cba2 100644 (file)
--- a/profile.c
+++ b/profile.c
@@ -2,6 +2,7 @@
 #include "profile.h"
 #include "debug.h"
 #include "flist.h"
+#include "options.h"
 
 static FLIST_HEAD(profile_list);
 
@@ -29,14 +30,34 @@ int load_profile(const char *profile)
        return 1;
 }
 
+static void add_profile_options(struct profile_ops *ops)
+{
+       struct fio_option *fo;
+       struct ext_option *eo;
+       
+       if (!ops->options)
+               return;
+
+       fo = ops->options;
+       while (fo->name) {
+               eo = malloc(sizeof(*eo));
+               eo->prof_name = ops->name;
+               memcpy(&eo->o, fo, sizeof(*fo));
+               register_ext_option(eo);
+               fo++;
+       }
+}
+
 void register_profile(struct profile_ops *ops)
 {
        dprint(FD_PROFILE, "register profile '%s'\n", ops->name);
        flist_add_tail(&ops->list, &profile_list);
+       add_profile_options(ops);
 }
 
 void unregister_profile(struct profile_ops *ops)
 {
        dprint(FD_PROFILE, "unregister profile '%s'\n", ops->name);
        flist_del(&ops->list);
+       prune_profile_options(ops->name);
 }