master - config: fix incorrect profile initialization on cmd context refresh
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=9a324df3b329f1a28462f246219522da62a022ce Commit: 9a324df3b329f1a28462f246219522da62a022ce Parent: c42f72867a653974f07e6e1db52f41691356e5b7 Author: Peter Rajnoha <[email protected]> AuthorDate: Mon May 19 13:59:23 2014 +0200 Committer: Peter Rajnoha <[email protected]> CommitterDate: Mon May 19 15:39:55 2014 +0200
config: fix incorrect profile initialization on cmd context refresh
When cmd refresh is called, we need to move any already loaded profiles to profiles_to_load list which will cause their reload on subsequent use. In addition to that, we need to take into account any change in config/profile configuration setting on cmd context refresh since this setting could be overriden with --config.
Also, when running commands in the shell, we need to remove the global profile used from the configuration cascade so the profile is not incorrectly reused next time when the --profile option is not specified anymore for the next command in the shell.
This bug only affected profile specified by --profile cmd line arg, not profiles referenced from LVM metadata.
--- WHATS_NEW | 1 + lib/commands/toolcontext.c | 50 ++++++++++++++++++++++++++++++++++--------- lib/config/config.h | 2 +- tools/lvmcmdline.c | 18 +++++++++------ 4 files changed, 52 insertions(+), 19 deletions(-)
WHATS_NEW +1 -0
@@ -1,5 +1,6 @@ Version 2.02.107 - ================================== + Fix wrong profile reuse from previous run if another cmd is run in lvm shell. Move cache description from lvm(8) to lvmcache(7) man page. Display skipped prompt in silent mode. Make reporting commands show help about possible sort keys on '-O help'.
lib/commands/toolcontext.c +39 -11
102 lines not on this page · raw message
lib/config/config.h +1 -1
@@ -41,7 +41,7 @@ struct profile { };struct profile_params { -const char *dir;/* subdir in LVM_SYSTEM_DIR where LVM looks for profiles */ +char dir[PATH_MAX ];/* subdir in LVM_SYSTEM_DIR where LVM looks for profiles */ struct profile *global_profile;/* profile that overrides any other VG/LV-based profile ('--profile' cmd line arg) */ struct dm_list profiles_to_load;/* list of profiles which are only added, but still need to be loaded for any use */ struct dm_list profiles;/* list of profiles which are loaded already and which are ready for use */
tools/lvmcmdline.c +11 -7
@@ -1081,11 +1081,11 @@ static const char *_copy_command_line(struct cmd_context *cmd, int argc, char **int lvm_run_command (struct cmd_context *cmd,int argc,char **argv) { +struct dm_config_tree *config_string_cft, *config_profile_cft; +struct profile *profile;int ret =0 ;int locking_type;int monitoring; -struct dm_config_tree *old_cft; -struct profile *profile;init_error_message_produced (0 );
@@ -1124,9 +1124,8 @@ int lvm_run_command(struct cmd_context *cmd, int argc, char **argv)if (arg_count (cmd, config_ARG) || !cmd->config_initialized ||config_files_changed (cmd)) {/* Reinitialise various settings inc. logging, filters */ if (!refresh_toolcontext (cmd)) { - old_cft =remove_config_tree_by_source (cmd,CONFIG_STRING ); -if (old_cft) -dm_config_destroy (old_cft); +if ((config_string_cft =remove_config_tree_by_source (cmd,CONFIG_STRING ))) +dm_config_destroy (config_string_cft);log_error ("Updated config file invalid. Aborting." );return ECMD_FAILED ; }
@@ -1204,8 +1203,13 @@ int lvm_run_command(struct cmd_context *cmd, int argc, char **argv)lvmcache_destroy (cmd,1 ,0 ); } -if ((old_cft =remove_config_tree_by_source (cmd,CONFIG_STRING ))) { -dm_config_destroy (old_cft); +if ((config_string_cft =remove_config_tree_by_source (cmd,CONFIG_STRING ))) +dm_config_destroy (config_string_cft); + + config_profile_cft =remove_config_tree_by_source (cmd,CONFIG_PROFILE ); + cmd->profile_params->global_profile =NULL ; + +if (config_string_cft || config_profile_cft) {/* Move this? */ if (!refresh_toolcontext (cmd)) stack;