On Mon, 2021-05-17 at 08:14 +0900, QI Fuli wrote:
> From: QI Fuli <[email protected]>
>
> Rename monitor.conf to ndctl.conf, and make it a ndclt global
> configuration file that all commands can refer to.
> Refactor monitor to make it work with ndctl.conf.
>
> Signed-off-by: QI Fuli <[email protected]>
> ---
> configure.ac | 8 +-
> ndctl/Makefile.am | 9 +-
> ndctl/monitor.c | 127 +++++------------------------
> ndctl/{monitor.conf => ndctl.conf} | 16 +++-
> 4 files changed, 40 insertions(+), 120 deletions(-)
> rename ndctl/{monitor.conf => ndctl.conf} (82%)
>
[snip]
> @@ -601,6 +496,19 @@ int cmd_monitor(int argc, const char **argv, struct
> ndctl_ctx *ctx)
> "ndctl monitor [<options>]",
> NULL
> };
> + const struct config configs[] = {
> + CONF_STR("core:bus", ¶m.bus, NULL),
> + CONF_STR("core:region", ¶m.region, NULL),
> + CONF_STR("core:dimm", ¶m.dimm, NULL),
> + CONF_STR("core:namespace", ¶m.namespace, NULL),
> + CONF_STR("monitor:bus", ¶m.bus, NULL),
> + CONF_STR("monitor:region", ¶m.region, NULL),
> + CONF_STR("monitor:dimm", ¶m.dimm, NULL),
> + CONF_STR("monitor:namespace", ¶m.namespace, NULL),
> + CONF_STR("monitor:dimm-event", &monitor.dimm_event, NULL),
> + //CONF_FILE("monitor:log", &monitor.log, NULL),
> + CONF_END(),
> + };
> const char *prefix = "./";
> struct util_filter_ctx fctx = { 0 };
> struct monitor_filter_arg mfa = { 0 };
> @@ -621,7 +529,10 @@ int cmd_monitor(int argc, const char **argv, struct
> ndctl_ctx *ctx)
> else
> monitor.ctx.log_priority = LOG_INFO;
>
> - rc = read_config_file(ctx, &monitor, ¶m);
> + if (monitor.config_file)
> + rc = parse_configs(monitor.config_file, configs);
> + else
> + rc = parse_configs(NDCTL_CONF_FILE, configs);
> if (rc)
> goto out;
If I'm reading this right, it looks like this is set up so that params
from the config file will override any params from the command line,
which I think can be surprising behavior. The command line should
always override anything in the config file.
I suspect we'll need to collect CLI params in a 'param_cli' structure,
config params in a 'param_config' structure, and then consolidate them
to create the final 'param' structure that gets passed to
util_filter_walk etc.