Skip to content
Browse files

vzctl: do report unknown parameters in config

When we are parsing configuration files, unknown parameters are ignored,
and this behaviour is documented at least in vz.conf(5) and ctid.conf{5}
man pages. It makes sense because it is possible to add some additional
parameters to config which are to be used by tools other than vzctl.

Nevertheless, sometimes it makes sense to report unknown parameters
(for example, if there is a typo).

This commit makes vzctl report such unrecognized parameters, but it does
that with a log level of 1, so it is not shown by default. In order to see
it, one have to increase log level or verbosity (for example, by running
vzctl --verbose).

While at it, add a comment in parse_opt() that ERR_UNK is not expected here.

Signed-off-by: Kir Kolyshkin <kir@openvz.org>
  • Loading branch information...
1 parent 5981721 commit e0edb7ccba9e4066d6843ac5ca0dbfc15c6ade46 @kolyshkin kolyshkin committed May 17, 2011
Showing with 11 additions and 7 deletions.
  1. +7 −3 src/lib/config.c
  2. +1 −4 src/lib/modules.c
  3. +3 −0 src/vzctl-actions.c
View
10 src/lib/config.c
@@ -2139,8 +2139,12 @@ int vps_parse_config(envid_t veid, char *path, vps_param *vps_p,
ret = parse(veid, vps_p, rtoken, conf->id);
} else if (action != NULL)
ret = mod_parse(veid, action, ltoken, -1, rtoken);
- else
+ else {
+ logger(1, 0, "Warning at %s:%d: unknown parameter "
+ "%s (\"%s\"), ignored",
+ path, line, ltoken, rtoken);
continue;
+ }
if (!ret) {
continue;
} else if (ret == ERR_INVAL_SKIP) {
@@ -2159,8 +2163,8 @@ int vps_parse_config(envid_t veid, char *path, vps_param *vps_p,
"for %s (\"%s\"), skipped",
path, line, ltoken, rtoken);
} else if (ret == ERR_UNK) {
- logger(-1, 0, "Warning at %s:%d: unknown parameter "
- "%s (\"%s\"), skipped",
+ logger(1, 0, "Warning at %s:%d: unknown parameter "
+ "%s (\"%s\"), ignored",
path, line, ltoken, rtoken);
} else if (ret == ERR_NOMEM) {
logger(-1, ENOMEM, "Error while parsing %s:%d",
View
5 src/lib/modules.c
@@ -32,10 +32,7 @@ int mod_parse(envid_t veid, struct mod_action *action, const char *name,
if (action == NULL)
return 0;
- if (name == NULL)
- ret = ERR_UNK; // unknown option
- else
- ret = 0; // skip unknown parameters in config
+ ret = ERR_UNK;
for (i = 0, mod = action->mod_list; i < action->mod_count; i++, mod++) {
mod_info = mod->mod_info;
if (mod_info == NULL)
View
3 src/vzctl-actions.c
@@ -172,6 +172,9 @@ int parse_opt(envid_t veid, int argc, char *argv[], struct option *opt,
return VZ_INVALID_PARAMETER_VALUE;
}
case ERR_UNK:
+ /* This shouldn't happen -- getopt_long()
+ * should have catched this already
+ */
if (option_index < 0)
logger(-1, 0, "Invalid option -%c", c);
else

0 comments on commit e0edb7c

Please sign in to comment.
Something went wrong with that request. Please try again.