<cmdsynopsis>
<command>lxc-info</command>
<arg choice="req">-n <replaceable>name</replaceable></arg>
- <arg choice="req">-s</arg>
- <arg choice="req">-p</arg>
- <arg choice="req">-t <replaceable>state</replaceable></arg>
+ <arg choice="opt">-c <replaceable>KEY</replaceable></arg>
+ <arg choice="opt">-s</arg>
+ <arg choice="opt">-p</arg>
+ <arg choice="opt">-t <replaceable>state</replaceable></arg>
</cmdsynopsis>
</refsynopsisdiv>
</listitem>
</varlistentry>
+ <varlistentry>
+ <term>
+ <option><optional>-c <replaceable>KEY</replaceable></optional></option>
+ </term>
+ <listitem>
+ <para>
+ Print a configuration key from the running container. This option
+ may be given mulitple times to print out multiple key = value pairs.
+ </para>
+ </listitem>
+ </varlistentry>
+
<varlistentry>
<term>
<option><optional>-s</optional></option>
</listitem>
</varlistentry>
+ <varlistentry>
+ <term>lxc-info -n foo -c lxc.network.0.veth.pair</term>
+ <listitem>
+ <para>
+ prints the veth pair name of foo.
+ </para>
+ </listitem>
+ </varlistentry>
+
</variablelist>
</refsect1>
static bool state;
static bool pid;
static char *test_state = NULL;
+static char **key = NULL;
+static int keys = 0;
static int my_parser(struct lxc_arguments* args, int c, char* arg)
{
switch (c) {
+ case 'c':
+ key = realloc(key, keys+1 * sizeof(key[0]));
+ key[keys] = arg;
+ keys++;
+ break;
case 's': state = true; break;
case 'p': pid = true; break;
case 't': test_state = arg; break;
}
static const struct option my_longopts[] = {
+ {"config", required_argument, 0, 'c'},
{"state", no_argument, 0, 's'},
{"pid", no_argument, 0, 'p'},
{"state-is", required_argument, 0, 't'},
\n\
Options :\n\
-n, --name=NAME NAME for name of the container\n\
- -s, --state shows the state of the container\n\
+ -c, --config=KEY show configuration variable KEY from running container\n\
-p, --pid shows the process id of the init container\n\
+ -s, --state shows the state of the container\n\
-t, --state-is=STATE test if current state is STATE\n\
returns success if it matches, false otherwise\n",
.options = my_longopts,
int main(int argc, char *argv[])
{
- int ret;
+ int ret,i;
ret = lxc_arguments_parse(&my_args, argc, argv);
if (ret)
my_args.progname, my_args.quiet, my_args.lxcpath[0]))
return 1;
- if (!state && !pid)
+ if (!state && !pid && keys <= 0)
state = pid = true;
if (state || test_state) {
printf("pid:%10d\n", initpid);
}
+ for(i = 0; i < keys; i++) {
+ char *val;
+
+ val = lxc_cmd_get_config_item(my_args.name, key[i], my_args.lxcpath[0]);
+ if (val) {
+ printf("%s = %s\n", key[i], val);
+ free(val);
+ } else {
+ fprintf(stderr, "%s unset or invalid\n", key[i]);
+ }
+ }
+
return 0;
}