[lxc-devel] [PATCH] introduce lxc_config

Serge Hallyn serge.hallyn at ubuntu.com
Mon Apr 29 23:38:20 UTC 2013


Quoting Dwight Engen (dwight.engen at oracle.com):
> > +struct lxc_config_items items[] =
> > +{
> > +	{ .name = "default_path", .fn =
> 
> Should this be "lxcpath" instead of "default_path" so it matches the
> field in the file? (or change default_lxc_path() to "default_path" but
> that would break users' files).

The name in lxc.conf was original default_path, but I'll change it to
lxcpath and, if I happen to see default_path in lxc.conf, honor that as
well.  'default' makes sense in the code, but in a configuration file
it's a bit redundant :)

> > &lxc_get_default_config_path, },
> > +	{ .name = "lvm_vg", .fn = &lxc_get_default_lvm_vg, },
> > +	{ .name = "zfsroot", .fn = &lxc_get_default_zfs_root, },
> > +	{ .name = NULL, },
> > +};
> > +
> > +void usage(char *me)
> > +{
> > +	printf("Usage: %s -l: list all available configuration
> > items\n", me);
> > +	printf("       %s item: print configuration item\n", me);
> > +	exit(1);
> > +}
> > +
> > +void list_config_items(void)
> > +{
> > +	struct lxc_config_items *i;
> > +
> > +	for (i = &items[0]; i->name; i++)
> > +		printf("%s\n", i->name);
> > +	exit(0);
> > +}
> > +
> > +int main(int argc, char *argv[])
> > +{
> > +	struct lxc_config_items *i;
> > +
> > +	if (argc < 2)
> > +		usage(argv[0]);
> > +	if (strcmp(argv[1], "-l") == 0)
> > +		list_config_items();
> > +	for (i = &items[0]; i->name; i++) {
> > +		if (strcmp(argv[1], i->name) == 0) {
> > +			printf("%s\n", i->fn());
> > +			exit(0);
> > +		}
> > +	}
> > +	printf("Unknown configuration item: %s\n", argv[1]);
> > +	return 0;
> 
> Should we return 1 or EXIT_FAILURE here?

Oops, yeah.

Thanks, Dwight.




More information about the lxc-devel mailing list