On 5/22/25 08:21, Stefan Kober wrote:
Allow a user to set the verbosity of the cloud hypervisor instances
by
specifying it in the ch.conf configuration file.
---
src/ch/ch_conf.c | 10 ++++++++++
src/ch/ch_conf.h | 15 +++++++++++++++
src/ch/ch_monitor.c | 6 ++++++
3 files changed, 31 insertions(+)
Here you'd add some rules to the augeas file, example with comment into
ch.conf and maybe a test case.
diff --git a/src/ch/ch_conf.c b/src/ch/ch_conf.c
index 7d3f600707..3e700586ca 100644
--- a/src/ch/ch_conf.c
+++ b/src/ch/ch_conf.c
@@ -98,6 +98,16 @@ int virCHDriverConfigLoadFile(virCHDriverConfig *cfg,
if (!(conf = virConfReadFile(filename, 0)))
return -1;
+ if (virConfGetValueUInt(conf, "log_level", &cfg->logLevel) < 0)
+ return -1;
+
+ if (!(cfg->logLevel < VIR_CH_LOGLEVEL_LAST)) {
+ VIR_WARN("Invalid log level %u. Using default %u instead.",
+ cfg->logLevel,
+ VIR_CH_LOGLEVEL_DEFAULT);
+ cfg->logLevel = VIR_CH_LOGLEVEL_DEFAULT;
I think we should just reject invalid values from the beginning. If user
requests invalid value they should fix their config file instead of us
falling back onto some default, albeit sensible. For instance, if I'd
provide "log_level" as a float the virConfGetValueUInt() above would
reject parsing anyways.
+ }
+
return 0;
}
Michal