7 static FLIST_HEAD(profile_list);
9 struct profile_ops *find_profile(const char *profile)
11 struct profile_ops *ops = NULL;
14 flist_for_each(n, &profile_list) {
15 ops = flist_entry(n, struct profile_ops, list);
16 if (!strcmp(profile, ops->name))
25 int load_profile(const char *profile)
27 struct profile_ops *ops;
29 dprint(FD_PROFILE, "loading profile '%s'\n", profile);
31 ops = find_profile(profile);
33 if (ops->prep_cmd()) {
34 log_err("fio: profile %s prep failed\n", profile);
37 add_job_opts(ops->cmdline, FIO_CLIENT_TYPE_CLI);
41 log_err("fio: profile '%s' not found\n", profile);
45 static int add_profile_options(struct profile_ops *ops)
54 o->prof_name = ops->name;
55 o->prof_opts = ops->opt_data;
64 int register_profile(struct profile_ops *ops)
68 dprint(FD_PROFILE, "register profile '%s'\n", ops->name);
70 ret = add_profile_options(ops);
72 flist_add_tail(&ops->list, &profile_list);
73 add_opt_posval("profile", ops->name, ops->desc);
77 invalidate_profile_options(ops->name);
81 void unregister_profile(struct profile_ops *ops)
83 dprint(FD_PROFILE, "unregister profile '%s'\n", ops->name);
84 flist_del(&ops->list);
85 invalidate_profile_options(ops->name);
86 del_opt_posval("profile", ops->name);
89 void profile_add_hooks(struct thread_data *td)
91 struct profile_ops *ops;
96 ops = find_profile(exec_profile);
101 td->prof_io_ops = *ops->io_ops;
102 td->flags |= TD_F_PROFILE_OPS;
106 int profile_td_init(struct thread_data *td)
108 struct prof_io_ops *ops = &td->prof_io_ops;
111 return ops->td_init(td);
116 void profile_td_exit(struct thread_data *td)
118 struct prof_io_ops *ops = &td->prof_io_ops;