# Master configuration file for the CH driver.
# All settings described here are optional - if omitted, sensible
# defaults are used.
+
+# By default, Cloud Hypervisor only emits warning and error messages. By using
+# the log_level configuration option, the logging verbosity can be increased.
+#
+# Using log_level = 1 configures Cloud Hypervisor to also show info messages.
+# Using log_level = 2 configures Cloud Hypervisor to also show debug messages.
+#
+#log_level = 0
return g_steal_pointer(&caps);
}
-int virCHDriverConfigLoadFile(virCHDriverConfig *cfg G_GNUC_UNUSED,
+int virCHDriverConfigLoadFile(virCHDriverConfig *cfg,
const char *filename)
{
g_autoptr(virConf) conf = NULL;
if (!(conf = virConfReadFile(filename, 0)))
return -1;
+ if (virConfGetValueUInt(conf, "log_level", &cfg->logLevel) < 0)
+ return -1;
+
+ if (!(cfg->logLevel < VIR_CH_LOGLEVEL_LAST)) {
+ virReportError(VIR_ERR_INTERNAL_ERROR, _("Invalid log_level %1$u"),
+ cfg->logLevel);
+ return -1;
+ }
+
return 0;
}
typedef struct _virCHDriverConfig virCHDriverConfig;
+typedef enum {
+ /* Standard log level only showing warning and error messages. */
+ VIR_CH_LOGLEVEL_DEFAULT = 0,
+
+ /* Additional info messages are shown. Will not spam the log. */
+ VIR_CH_LOGLEVEL_INFO,
+
+ /* Additional debug messages are shown. Will be very verbose. */
+ VIR_CH_LOGLEVEL_DEBUG,
+
+ VIR_CH_LOGLEVEL_LAST
+} virCHLogLevel;
+
struct _virCHDriverConfig {
GObject parent;
gid_t group;
bool stdioLogD;
+
+ virCHLogLevel logLevel;
};
G_DEFINE_AUTOPTR_CLEANUP_FUNC(virCHDriverConfig, virObjectUnref);
return NULL;
}
+ if (cfg->logLevel == VIR_CH_LOGLEVEL_INFO) {
+ virCommandAddArg(cmd, "-v");
+ } else if (cfg->logLevel == VIR_CH_LOGLEVEL_DEBUG) {
+ virCommandAddArg(cmd, "-vv");
+ }
+
virCommandAddArg(cmd, "--api-socket");
virCommandAddArgFormat(cmd, "fd=%d", socket_fd);
virCommandPassFD(cmd, socket_fd, VIR_COMMAND_PASS_FD_CLOSE_PARENT);
let str_array_entry (kw:string) = [ key kw . value_sep . str_array_val ]
(* Config entry grouped by function - same order as example config *)
- let config_entry = bool_entry "placeholder"
+ let config_entry = int_entry "log_level"
(* Each entry in the config is one of the following three ... *)
let entry = config_entry
],
}
+ ch_conf = files('ch.conf')
+ virt_conf_files += ch_conf
+ virt_aug_files += files('libvirtd_ch.aug')
+ virt_test_aug_files += {
+ 'name': 'test_libvirtd_ch.aug',
+ 'aug': files('test_libvirtd_ch.aug.in'),
+ 'conf': ch_conf,
+ 'test_name': 'libvirtd_ch',
+ 'test_srcdir': meson.current_source_dir(),
+ 'test_builddir': meson.current_build_dir(),
+ }
+
virt_install_dirs += [
localstatedir / 'lib' / 'libvirt' / 'ch',
localstatedir / 'log' / 'libvirt' / 'ch',
--- /dev/null
+module Test_libvirtd_ch =
+ @CONFIG@
+
+ test Libvirtd_ch.lns get conf =
+{ "log_level" = "0" }