lxc-cgroup: use correct terminology

lxc-cgroup gets or sets the value of a state object (such as
'cpuset.cpus'), not the value of a subsystem (which would be
just 'cpuset').

Signed-off-by: David Ward <david.ward@ll.mit.edu>
Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
This commit is contained in:
David Ward 2012-05-04 00:50:15 +02:00 committed by Daniel Lezcano
parent 257e5824e4
commit f10e7166ab
3 changed files with 30 additions and 27 deletions

View File

@ -48,8 +48,8 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
<refsynopsisdiv> <refsynopsisdiv>
<cmdsynopsis> <cmdsynopsis>
<command>lxc-start <replaceable>-n name</replaceable> <command>lxc-cgroup -n <replaceable>name</replaceable>
<replaceable>subsystem</replaceable> <optional>value</optional> <replaceable>state-object</replaceable> <optional>value</optional>
</command> </command>
</cmdsynopsis> </cmdsynopsis>
</refsynopsisdiv> </refsynopsisdiv>
@ -58,17 +58,20 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
<title>Description</title> <title>Description</title>
<para> <para>
<command>lxc-cgroup</command> get or set value from the control <command>lxc-cgroup</command> gets or sets the value of a
group associated with the <replaceable>state-object</replaceable> (e.g., 'cpuset.cpus')
container <replaceable>name</replaceable>. If in the container's cgroup for the corresponding subsystem (e.g.,
no <optional>value</optional> is specified, the value of 'cpuset'). If no <optional>value</optional> is specified, the
the <replaceable>subsystem</replaceable> is displayed, otherwise current value of the <replaceable>state-object</replaceable> is
it is set. The <command>lxc-cgroup</command> does not assume the displayed; otherwise it is set.
correctness of the <replaceable>subsystem</replaceable> name, it
is up to the user to specify the
right <replaceable>subsystem</replaceable> name.
</para> </para>
<para>
Note that <command>lxc-cgroup</command> does not check that the
<replaceable>state-object</replaceable> is valid for the running
kernel, or that the corresponding subsystem is contained in any
mounted cgroup hierarchy.
</para>
</refsect1> </refsect1>
<refsect1> <refsect1>
@ -77,11 +80,11 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
<varlistentry> <varlistentry>
<term> <term>
<option><replaceable>subsystem</replaceable></option> <option><replaceable>state-object</replaceable></option>
</term> </term>
<listitem> <listitem>
<para> <para>
Specify the subsystem control group name. Specify the state object name.
</para> </para>
</listitem> </listitem>
</varlistentry> </varlistentry>
@ -92,7 +95,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
</term> </term>
<listitem> <listitem>
<para> <para>
Specify the subsystem control group value to be set. Specify the value to assign to the state object.
</para> </para>
</listitem> </listitem>
</varlistentry> </varlistentry>

View File

@ -531,8 +531,8 @@ int lxc_cgroup_path_get(char **path, const char *subsystem, const char *name)
static char buf[MAXPATHLEN]; static char buf[MAXPATHLEN];
static char retbuf[MAXPATHLEN]; static char retbuf[MAXPATHLEN];
/* what lxc_cgroup_set calls subsystem is actually the filename, i.e. /* lxc_cgroup_set passes a state object for the subsystem,
'devices.allow'. So for our purposee we trim it */ * so trim it to just the subsystem part */
if (subsystem) { if (subsystem) {
snprintf(retbuf, MAXPATHLEN, "%s", subsystem); snprintf(retbuf, MAXPATHLEN, "%s", subsystem);
char *s = index(retbuf, '.'); char *s = index(retbuf, '.');

View File

@ -36,7 +36,7 @@ lxc_log_define(lxc_cgroup_ui, lxc_cgroup);
static int my_checker(const struct lxc_arguments* args) static int my_checker(const struct lxc_arguments* args)
{ {
if (!args->argc) { if (!args->argc) {
lxc_error(args, "missing cgroup subsystem"); lxc_error(args, "missing state object");
return -1; return -1;
} }
return 0; return 0;
@ -49,13 +49,13 @@ static const struct option my_longopts[] = {
static struct lxc_arguments my_args = { static struct lxc_arguments my_args = {
.progname = "lxc-cgroup", .progname = "lxc-cgroup",
.help = "\ .help = "\
--name=NAME subsystem [value]\n\ --name=NAME state-object [value]\n\
\n\ \n\
lxc-cgroup get or set subsystem value of cgroup\n\ Get or set the value of a state object (for example, 'cpuset.cpus')\n\
associated with the NAME container\n\ in the container's cgroup for the corresponding subsystem.\n\
\n\ \n\
Options :\n\ Options :\n\
-n, --name=NAME NAME for name of the container", -n, --name=NAME container name",
.options = my_longopts, .options = my_longopts,
.parser = NULL, .parser = NULL,
.checker = my_checker, .checker = my_checker,
@ -63,7 +63,7 @@ Options :\n\
int main(int argc, char *argv[]) int main(int argc, char *argv[])
{ {
char *subsystem = NULL, *value = NULL; char *state_object = NULL, *value = NULL;
if (lxc_arguments_parse(&my_args, argc, argv)) if (lxc_arguments_parse(&my_args, argc, argv))
return -1; return -1;
@ -72,15 +72,15 @@ int main(int argc, char *argv[])
my_args.progname, my_args.quiet)) my_args.progname, my_args.quiet))
return -1; return -1;
subsystem = my_args.argv[0]; state_object = my_args.argv[0];
if ((argc) > 1) if ((argc) > 1)
value = my_args.argv[1]; value = my_args.argv[1];
if (value) { if (value) {
if (lxc_cgroup_set(my_args.name, subsystem, value)) { if (lxc_cgroup_set(my_args.name, state_object, value)) {
ERROR("failed to assign '%s' value to '%s' for '%s'", ERROR("failed to assign '%s' value to '%s' for '%s'",
value, subsystem, my_args.name); value, state_object, my_args.name);
return -1; return -1;
} }
} else { } else {
@ -88,10 +88,10 @@ int main(int argc, char *argv[])
int ret; int ret;
char buffer[len]; char buffer[len];
ret = lxc_cgroup_get(my_args.name, subsystem, buffer, len); ret = lxc_cgroup_get(my_args.name, state_object, buffer, len);
if (ret < 0) { if (ret < 0) {
ERROR("failed to retrieve value of '%s' for '%s'", ERROR("failed to retrieve value of '%s' for '%s'",
subsystem, my_args.name); state_object, my_args.name);
return -1; return -1;
} }