> You are changing API. That is a strict no-no. Oops, sorry about that. Added new API call to pass the option.
--- Kernel may be configured with different options (like swap) and may or may not have some group variables. This commit adds possibility to use common cgconfig.conf between these machines with different compiled options. Add new option (-T, --tolerate) which lets cgconfigparser skip failed group variables. Signed-off-by: Stanislav Fomichev <stfomic...@yandex-team.ru> --- include/libcgroup/init.h | 8 ++++++++ src/api.c | 2 +- src/config.c | 16 ++++++++++++++++ src/libcgroup.map | 4 ++++ src/tools/cgconfig.c | 9 ++++++++- 5 files changed, 37 insertions(+), 2 deletions(-) diff --git a/include/libcgroup/init.h b/include/libcgroup/init.h index 5150f2fc38eb..8b5471d606cd 100644 --- a/include/libcgroup/init.h +++ b/include/libcgroup/init.h @@ -55,6 +55,14 @@ int cgroup_init(void); int cgroup_get_subsys_mount_point(const char *controller, char **mount_point); /** + * This routine lets user specify whether he wants to tolerate some non-fatal + * errors while processing config. + * @param tolerate Parameter which indicates whether to tolerate (1) errors + * or not (0). + */ +int cgroup_tolerate_errors(int tolerate); + +/** * @} * @} */ diff --git a/src/api.c b/src/api.c index cd4e5b096b41..a252d0f99d67 100644 --- a/src/api.c +++ b/src/api.c @@ -1660,7 +1660,7 @@ int cgroup_create_cgroup(struct cgroup *cgroup, int ignore_ownership) * ignore it specifically if they wish. */ if (error) { - cgroup_warn("Warning: failed to set %s: %s (%d)\n", + cgroup_err("Error: failed to set %s: %s (%d)\n", path, cgroup_strerror(error), error); retval = ECGCANTSETVALUE; continue; diff --git a/src/config.c b/src/config.c index ac844a7ae30c..06e9ac0d9c2d 100644 --- a/src/config.c +++ b/src/config.c @@ -55,6 +55,7 @@ extern int yyparse(void); static struct cgroup default_group; static int default_group_set = 0; +static int cgroup_tolerate; /* * The basic global data structures. @@ -733,6 +734,14 @@ static int cgroup_config_create_groups(void) error = cgroup_create_cgroup(cgroup, 0); cgroup_dbg("creating group %s, error %d\n", cgroup->name, error); + + /* if for some reason we couldn't set group value, just + * skip it with a warning */ + if (cgroup_tolerate && error == ECGCANTSETVALUE) { + error = 0; + continue; + } + if (error) return error; } @@ -1676,3 +1685,10 @@ int cgroup_config_create_template_group(struct cgroup *cgroup, end: return ret; } + +int cgroup_tolerate_errors(int tolerate) +{ + cgroup_tolerate = !!tolerate; + + return 0; +} diff --git a/src/libcgroup.map b/src/libcgroup.map index b0c162c2581c..c7f1fb5b1588 100644 --- a/src/libcgroup.map +++ b/src/libcgroup.map @@ -117,3 +117,7 @@ CGROUP_0.39 { cgroup_log; cgroup_parse_log_level_str; } CGROUP_0.38; + +CGROUP_0.40 { + cgroup_tolerate_errors; +} CGROUP_0.39; diff --git a/src/tools/cgconfig.c b/src/tools/cgconfig.c index e8bb5a2e553b..9592043eda8c 100644 --- a/src/tools/cgconfig.c +++ b/src/tools/cgconfig.c @@ -61,6 +61,7 @@ static void usage(int status, char *progname) "permissions\n"); printf(" -t <tuid>:<tgid> Default owner of the tasks "\ "file\n"); + printf(" -T, --tolerate Tolerate non-fatal errors\n"); } int main(int argc, char *argv[]) @@ -72,6 +73,7 @@ int main(int argc, char *argv[]) {"load", 1, 0, 'l'}, {"load-directory", 1, 0, 'L'}, {"task", required_argument, NULL, 't'}, + {"tolerate", 0, NULL, 'T' }, {"admin", required_argument, NULL, 'a'}, {"dperm", required_argument, NULL, 'd'}, {"fperm", required_argument, NULL, 'f' }, @@ -98,7 +100,7 @@ int main(int argc, char *argv[]) if (error) goto err; - while ((c = getopt_long(argc, argv, "hl:L:t:a:d:f:s:", options, + while ((c = getopt_long(argc, argv, "hl:L:t:Ta:d:f:s:", options, NULL)) > 0) { switch (c) { case 'h': @@ -141,6 +143,11 @@ int main(int argc, char *argv[]) if (error) goto err; break; + case 'T': + error = cgroup_tolerate_errors(1); + if (error) + goto err; + break; case 's': filem_change = 1; error = parse_mode(optarg, &tasks_mode, argv[0]); -- 1.8.3.2 ------------------------------------------------------------------------------ October Webinars: Code for Performance Free Intel webinars can help you accelerate application performance. Explore tips for MPI, OpenMP, advanced profiling, and more. Get the most from the latest Intel processors and coprocessors. See abstracts and register > http://pubads.g.doubleclick.net/gampad/clk?id=60135991&iu=/4140/ostg.clktrk _______________________________________________ Libcg-devel mailing list Libcg-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/libcg-devel