[CRIU] [PATCH 1/4] cg: Add ability to dump custom cgroup properties
Cyrill Gorcunov
gorcunov at gmail.com
Tue May 3 08:32:01 PDT 2016
On Tue, May 03, 2016 at 09:39:41AM -0500, Tycho Andersen wrote:
> On Tue, May 03, 2016 at 02:30:16PM +0300, Cyrill Gorcunov wrote:
> > We have some common predefined properties such as "cpuset.cpus" and etc gathered
> > in @cgp_predefined set, but there might be situation when only predefined ones
> > are not enough, so add ability to specify properties via --cgroup-props
> > and/or --cgroup-props-file options.
> >
> > For example one may pass file with content
> >
> > "cpu":
> > - "strategy": "merge"
> > - "properties": ["cpu.shares", "cpu.cfs_period_us"]
> >
> > to dump custom properties for cpu controller.
> >
> > The description is implemented in almost valid yaml, probably we will
> > need to support the various forms, but oneline is enough for now.
> >
...
> > +
> > +static int cgp_parse_stream(char *stream, size_t len)
> > +{
...
> > +
> > + if (!strcmp(p, "merge")) {
> > + strategy = CGP_MERGE;
> > + } else if (!strcmp(p, "replace")) {
> > + strategy = CGP_REPLACE;
> > + } else {
> > + xfree(p);
> > + pr_err("Unknown strategy \"%s\" in controller's %s stream\n",
> > + p, cgp_entry->cgp.name);
> > + goto err_parse;
> > + }
...
> > +
> > + if (strategy == CGP_MERGE) {
> > + if (cgp_merge_props(cgp_entry)) {
> > + pr_err("Can't merge controller \'%s\'\n",
> > + cgp_entry->cgp.name);
> > + goto out;
> > + }
> > + } else if (strategy == CGP_REPLACE) {
> > + if (cgp_replace_props(cgp_entry)) {
> > + pr_err("Can't replace controller \'%s\'\n",
> > + cgp_entry->cgp.name);
> > + goto out;
> > + }
> > + } else
> > + BUG();
>
> This isn't a BUG(), it's invalid user input right?
Nope, we should have handled it already. So bug here just in case
if some new enum entered but forgot to ajust this code.
More information about the CRIU
mailing list