[lvm-devel] master - config: add profile arg to find_config_tree_str_allow_empty

Peter Rajnoha prajnoha at fedoraproject.org
Tue Jul 2 13:32:41 UTC 2013


Gitweb:        http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=8ac4fcf8ffa4af3ee8d524add632f0f3139b929d
Commit:        8ac4fcf8ffa4af3ee8d524add632f0f3139b929d
Parent:        06dd66af546dfc18a80b6ee574ce91e5d512d2f2
Author:        Peter Rajnoha <prajnoha at redhat.com>
AuthorDate:    Tue Jun 25 12:30:08 2013 +0200
Committer:     Peter Rajnoha <prajnoha at redhat.com>
CommitterDate: Tue Jul 2 15:19:09 2013 +0200

config: add profile arg to find_config_tree_str_allow_empty

---
 lib/activate/dev_manager.c |    2 +-
 lib/commands/toolcontext.c |    2 +-
 lib/config/config.c        |   14 ++++++++++++--
 lib/config/config.h        |    2 +-
 4 files changed, 15 insertions(+), 5 deletions(-)

diff --git a/lib/activate/dev_manager.c b/lib/activate/dev_manager.c
index 7054656..d07e04a 100644
--- a/lib/activate/dev_manager.c
+++ b/lib/activate/dev_manager.c
@@ -1560,7 +1560,7 @@ static int _thin_pool_callback(struct dm_tree_node *node,
 	const struct dm_config_node *cn;
 	const struct dm_config_value *cv;
 	const char *thin_check =
-		find_config_tree_str_allow_empty(data->pool_lv->vg->cmd, global_thin_check_executable_CFG);
+		find_config_tree_str_allow_empty(data->pool_lv->vg->cmd, global_thin_check_executable_CFG, NULL);
 	const struct logical_volume *mlv = first_seg(data->pool_lv)->metadata_lv;
 	size_t len = strlen(dmdir) + 2 * (strlen(mlv->vg->name) + strlen(mlv->name)) + 3;
 	char meta_path[len];
diff --git a/lib/commands/toolcontext.c b/lib/commands/toolcontext.c
index c593f5e..f5b8d48 100644
--- a/lib/commands/toolcontext.c
+++ b/lib/commands/toolcontext.c
@@ -202,7 +202,7 @@ static void _init_logging(struct cmd_context *cmd)
 	init_indent(find_config_tree_bool(cmd, log_indent_CFG));
 	init_abort_on_internal_errors(find_config_tree_bool(cmd, global_abort_on_internal_errors_CFG));
 
-	cmd->default_settings.msg_prefix = find_config_tree_str_allow_empty(cmd, log_prefix_CFG);
+	cmd->default_settings.msg_prefix = find_config_tree_str_allow_empty(cmd, log_prefix_CFG, NULL);
 	init_msg_prefix(cmd->default_settings.msg_prefix);
 
 	cmd->default_settings.cmd_name = find_config_tree_bool(cmd, log_command_names_CFG);
diff --git a/lib/config/config.c b/lib/config/config.c
index 5267424..1576153 100644
--- a/lib/config/config.c
+++ b/lib/config/config.c
@@ -821,17 +821,27 @@ const char *find_config_tree_str(struct cmd_context *cmd, int id, struct profile
 	return str;
 }
 
-const char *find_config_tree_str_allow_empty(struct cmd_context *cmd, int id)
+const char *find_config_tree_str_allow_empty(struct cmd_context *cmd, int id, struct profile *profile)
 {
 	cfg_def_item_t *item = cfg_def_get_item_p(id);
 	const char *path = cfg_def_get_path(item);
+	int profile_applied = 0;
+	const char *str;
 
 	if (item->type != CFG_TYPE_STRING)
 		log_error(INTERNAL_ERROR "%s cfg tree element not declared as string.", path);
 	if (!(item->flags & CFG_ALLOW_EMPTY))
 		log_error(INTERNAL_ERROR "%s cfg tree element not declared to allow empty values.", path);
 
-	return dm_config_tree_find_str_allow_empty(cmd->cft, path, cfg_def_get_default_value(item, CFG_TYPE_STRING));
+	if (profile && !cmd->profile_params->global_profile)
+		profile_applied = override_config_tree_from_profile(cmd, profile);
+
+	str = dm_config_tree_find_str_allow_empty(cmd->cft, path, cfg_def_get_default_value(item, CFG_TYPE_STRING));
+
+	if (profile_applied)
+		remove_config_tree_by_source(cmd, CONFIG_PROFILE);
+
+	return str;
 }
 
 int find_config_tree_int(struct cmd_context *cmd, int id)
diff --git a/lib/config/config.h b/lib/config/config.h
index 6c6089e..56ed4ea 100644
--- a/lib/config/config.h
+++ b/lib/config/config.h
@@ -166,7 +166,7 @@ int merge_config_tree(struct cmd_context *cmd, struct dm_config_tree *cft,
  */
 const struct dm_config_node *find_config_tree_node(struct cmd_context *cmd, int id, struct profile *profile);
 const char *find_config_tree_str(struct cmd_context *cmd, int id, struct profile *profile);
-const char *find_config_tree_str_allow_empty(struct cmd_context *cmd, int id);
+const char *find_config_tree_str_allow_empty(struct cmd_context *cmd, int id, struct profile *profile);
 int find_config_tree_int(struct cmd_context *cmd, int id);
 int64_t find_config_tree_int64(struct cmd_context *cmd, int id);
 float find_config_tree_float(struct cmd_context *cmd, int id);




More information about the lvm-devel mailing list