mirror of
git://sourceware.org/git/lvm2.git
synced 2025-02-10 17:57:54 +03:00
config: add override_config_tree_from_profile fn to add the profile to a configuration cascade
When placing the profile in a configuration cascade, this sequence is used exactly: CONFIG_STRING -> CONFIG_PROFILE -> CONFIG_FILE/MERGED_FILES So if the profile is used, it overloads the lvm.conf (and any existing tag configs). However, if "--config" is used to define a custom configuration on command line, this overloads even the profile config!
This commit is contained in:
parent
ebc236d085
commit
bfde83eb34
@ -301,7 +301,7 @@ int override_config_tree_from_string(struct cmd_context *cmd,
|
||||
|
||||
/*
|
||||
* Follow this sequence:
|
||||
* CONFIG_STRING -> CONFIG_FILE/CONFIG_MERGED_FILES
|
||||
* CONFIG_STRING -> CONFIG_PROFILE -> CONFIG_FILE/CONFIG_MERGED_FILES
|
||||
*/
|
||||
|
||||
if (cs->type == CONFIG_STRING) {
|
||||
@ -329,6 +329,39 @@ int override_config_tree_from_string(struct cmd_context *cmd,
|
||||
return 1;
|
||||
}
|
||||
|
||||
int override_config_tree_from_profile(struct cmd_context *cmd,
|
||||
struct profile *profile)
|
||||
{
|
||||
struct dm_config_tree *cft = cmd->cft, *cft_string = NULL;
|
||||
struct config_source *cs = dm_config_get_custom(cft);
|
||||
|
||||
/*
|
||||
* Follow this sequence:
|
||||
* CONFIG_STRING -> CONFIG_PROFILE -> CONFIG_FILE/CONFIG_MERGED_FILES
|
||||
*/
|
||||
|
||||
if (!profile->cft && !load_profile(cmd, profile))
|
||||
return_0;
|
||||
|
||||
if (cs->type == CONFIG_STRING) {
|
||||
cft_string = cft;
|
||||
cft = cft->cascade;
|
||||
cs = dm_config_get_custom(cft);
|
||||
if (cs->type == CONFIG_PROFILE) {
|
||||
log_error(INTERNAL_ERROR "override_config_tree_from_profile: "
|
||||
"config cascade already contains a profile config.");
|
||||
return 0;
|
||||
}
|
||||
dm_config_insert_cascaded_tree(cft_string, profile->cft);
|
||||
}
|
||||
|
||||
cmd->cft = dm_config_insert_cascaded_tree(profile->cft, cft);
|
||||
|
||||
cmd->cft = cft_string ? : profile->cft;
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
int config_file_read_fd(struct dm_config_tree *cft, struct device *dev,
|
||||
off_t offset, size_t size, off_t offset2, size_t size2,
|
||||
checksum_fn_t checksum_fn, uint32_t checksum)
|
||||
|
@ -135,6 +135,7 @@ int config_def_get_path(char *buf, size_t buf_size, int id);
|
||||
int config_def_check(struct cmd_context *cmd, int force, int skip, int suppress_messages);
|
||||
|
||||
int override_config_tree_from_string(struct cmd_context *cmd, const char *config_settings);
|
||||
int override_config_tree_from_profile(struct cmd_context *cmd, struct profile *profile);
|
||||
struct dm_config_tree *remove_config_tree_by_source(struct cmd_context *cmd, config_source_t source);
|
||||
config_source_t config_get_source_type(struct dm_config_tree *cft);
|
||||
|
||||
|
@ -1099,6 +1099,10 @@ int lvm_run_command(struct cmd_context *cmd, int argc, char **argv)
|
||||
log_debug("Setting global configuration profile \"%s\".", profile->name);
|
||||
/* This profile will override any VG/LV-based profile if present */
|
||||
cmd->profile_params->global_profile = profile;
|
||||
if (!override_config_tree_from_profile(cmd, profile)) {
|
||||
log_error("Failed to apply configuration profile.");
|
||||
return ECMD_FAILED;
|
||||
}
|
||||
}
|
||||
|
||||
if ((ret = _get_settings(cmd)))
|
||||
|
Loading…
x
Reference in New Issue
Block a user