Commit e5e9cc99 authored by Cédric Bosdonnat's avatar Cédric Bosdonnat

Pass verbose values to init-common

libvirt-sandbox-init-common is expecting -v parameter to set it in
verbose mode... but it will never be passed by the launcher program.
Writing the core.verbose parameter in the sandbox configuration
makes that values actually usable from the init.

While at it, add and set a core.debug value to the sandbox configuration
to allow setting only the common init in debug mode, not the
virtualization specific one.
parent 67a6116a
......@@ -273,6 +273,9 @@ int main(int argc, char **argv) {
if (shell)
gvir_sandbox_config_set_shell(cfg, TRUE);
gvir_sandbox_config_set_debug(cfg, debug);
gvir_sandbox_config_set_verbose(cfg, verbose);
if (isatty(STDIN_FILENO))
gvir_sandbox_config_interactive_set_tty(icfg, TRUE);
......
......@@ -68,6 +68,9 @@ struct _GVirSandboxConfigPrivate
gchar *secLabel;
gboolean secDynamic;
gboolean debug;
gboolean verbose;
};
G_DEFINE_ABSTRACT_TYPE(GVirSandboxConfig, gvir_sandbox_config, G_TYPE_OBJECT);
......@@ -1926,6 +1929,59 @@ gboolean gvir_sandbox_config_set_security_opts(GVirSandboxConfig *config,
return ret;
}
/**
* gvir_sandbox_config_set_debug:
* @config: (transfer none): the sandbox config
* @debug: true if the container init should print debugging messages
*
* Set whether the container init should print debugging messages.
*/
void gvir_sandbox_config_set_debug(GVirSandboxConfig *config, gboolean debug)
{
GVirSandboxConfigPrivate *priv = config->priv;
priv->debug = debug;
}
/**
* gvir_sandbox_config_get_debug:
* @config: (transfer none): the sandbox config
*
* Retrieves the sandbox debug flag
*
* Returns: the debug flag
*/
gboolean gvir_sandbox_config_get_debug(GVirSandboxConfig *config)
{
GVirSandboxConfigPrivate *priv = config->priv;
return priv->debug;
}
/**
* gvir_sandbox_config_set_verbose:
* @config: (transfer none): the sandbox config
* @verbose: true if the container init should be verbose
*
* Set whether the container init should be verbose.
*/
void gvir_sandbox_config_set_verbose(GVirSandboxConfig *config, gboolean verbose)
{
GVirSandboxConfigPrivate *priv = config->priv;
priv->verbose = verbose;
}
/**
* gvir_sandbox_config_get_verbose:
* @config: (transfer none): the sandbox config
*
* Retrieves the sandbox verbose flag
*
* Returns: the verbose flag
*/
gboolean gvir_sandbox_config_get_verbose(GVirSandboxConfig *config)
{
GVirSandboxConfigPrivate *priv = config->priv;
return priv->verbose;
}
static GVirSandboxConfigMount *gvir_sandbox_config_load_config_mount(GKeyFile *file,
guint i,
......@@ -2415,6 +2471,22 @@ static gboolean gvir_sandbox_config_load_config(GVirSandboxConfig *config,
priv->secDynamic = b;
}
b = g_key_file_get_boolean(file, "core", "debug", &e);
if (e) {
g_error_free(e);
e = NULL;
} else {
priv->debug = b;
}
b = g_key_file_get_boolean(file, "core", "verbose", &e);
if (e) {
g_error_free(e);
e = NULL;
} else {
priv->verbose = b;
}
ret = TRUE;
cleanup:
return ret;
......@@ -2677,6 +2749,9 @@ static void gvir_sandbox_config_save_config(GVirSandboxConfig *config,
if (priv->secLabel)
g_key_file_set_string(file, "security", "label", priv->secLabel);
g_key_file_set_boolean(file, "security", "dynamic", priv->secDynamic);
g_key_file_set_boolean(file, "core", "debug", priv->debug);
g_key_file_set_boolean(file, "core", "verbose", priv->verbose);
}
......
......@@ -180,6 +180,12 @@ gboolean gvir_sandbox_config_set_security_opts(GVirSandboxConfig *config,
const gchar *optstr,
GError**error);
void gvir_sandbox_config_set_debug(GVirSandboxConfig *config, gboolean debug);
gboolean gvir_sandbox_config_get_debug(GVirSandboxConfig *config);
void gvir_sandbox_config_set_verbose(GVirSandboxConfig *config, gboolean verbose);
gboolean gvir_sandbox_config_get_verbose(GVirSandboxConfig *config);
gchar **gvir_sandbox_config_get_command(GVirSandboxConfig *config);
G_END_DECLS
......
......@@ -1442,6 +1442,9 @@ int main(int argc, char **argv) {
goto cleanup;
}
debug = gvir_sandbox_config_get_debug(config);
verbose = gvir_sandbox_config_get_verbose(config);
setenv("PATH", "/bin:/usr/bin:/usr/local/bin:/sbin/:/usr/sbin", 1);
unsetenv("LD_LIBRARY_PATH");
......
......@@ -120,6 +120,8 @@ LIBVIRT_SANDBOX_0.6.0 {
gvir_sandbox_config_get_userid;
gvir_sandbox_config_get_username;
gvir_sandbox_config_get_uuid;
gvir_sandbox_config_get_debug;
gvir_sandbox_config_get_verbose;
gvir_sandbox_config_find_mount;
gvir_sandbox_config_has_networks;
gvir_sandbox_config_has_mounts;
......@@ -143,6 +145,8 @@ LIBVIRT_SANDBOX_0.6.0 {
gvir_sandbox_config_set_security_label;
gvir_sandbox_config_set_security_opts;
gvir_sandbox_config_set_uuid;
gvir_sandbox_config_set_debug;
gvir_sandbox_config_set_verbose;
gvir_sandbox_config_initrd_add_module;
gvir_sandbox_config_initrd_get_init;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment