1
0
mirror of git://sourceware.org/git/lvm2.git synced 2024-10-27 18:55:19 +03:00
lvm2/tools/dumpconfig.c

283 lines
7.8 KiB
C
Raw Normal View History

/*
2008-01-30 17:00:02 +03:00
* Copyright (C) 2003-2004 Sistina Software, Inc. All rights reserved.
* Copyright (C) 2004-2007 Red Hat, Inc. All rights reserved.
*
2004-03-30 23:35:44 +04:00
* This file is part of LVM2.
*
2004-03-30 23:35:44 +04:00
* This copyrighted material is made available to anyone wishing to use,
* modify, copy, or redistribute it subject to the terms and conditions
* of the GNU Lesser General Public License v.2.1.
*
* You should have received a copy of the GNU Lesser General Public License
2004-03-30 23:35:44 +04:00
* along with this program; if not, write to the Free Software Foundation,
* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include "tools.h"
dumpconfig: add --mergedconfig option Normally, the lvm dumpconfig processes only the configuration tree that is at the top of the cascade. Considering the cascade is: CONFIG_STRING -> CONFIG_PROFILE -> CONFIG_MERGED_FILES/CONFIG_FILE ...then: (dumpconfig of lvm.conf only) raw/~ $ lvm dumpconfig allocation allocation { maximise_cling=1 mirror_logs_require_separate_pvs=0 thin_pool_metadata_require_separate_pvs=0 thin_pool_chunk_size=64 } (dumpconfig of selected profile configuration only) raw/~ $ lvm dumpconfig --profile test allocation allocation { thin_pool_chunk_size=8 thin_pool_discards="passdown" thin_pool_zero=1 } (dumpconfig of given --config configuration only) raw/~ $ lvm dumpconfig --config 'allocation{thin_pool_chunk_size=16}' allocation allocation { thin_pool_chunk_size=16 } The --mergedconfig option causes the configuration cascade to be merged before processing it with dumpconfig: (dumpconfig of merged selected profile and lvm.conf) raw/~ $ lvm dumpconfig --profile test allocation --mergedconfig allocation { maximise_cling=1 thin_pool_zero=1 thin_pool_discards="passdown" mirror_logs_require_separate_pvs=0 thin_pool_metadata_require_separate_pvs=0 thin_pool_chunk_size=8 } (dumpconfig merged given --config and selected profile and lvm.conf) raw/~ $ lvm dumpconfig --profile test --config 'allocation{thin_pool_chunk_size=16}' allocation --mergedconfig allocation { maximise_cling=1 thin_pool_zero=1 thin_pool_discards="passdown" mirror_logs_require_separate_pvs=0 thin_pool_metadata_require_separate_pvs=0 thin_pool_chunk_size=16 } Hence with the --mergedconfig, we are able to see the configuration that is actually used when processing any LVM command while using any combination of --config/--profile options together with lvm.conf file.
2013-07-08 17:34:27 +04:00
static int _get_vsn(struct cmd_context *cmd, uint16_t *version_int)
{
2013-07-08 15:45:37 +04:00
const char *atversion = arg_str_value(cmd, atversion_ARG, LVM_VERSION);
unsigned int major, minor, patchlevel;
2013-07-08 15:45:37 +04:00
if (sscanf(atversion, "%u.%u.%u", &major, &minor, &patchlevel) != 3) {
log_error("Incorrect version format.");
return 0;
}
dumpconfig: add --mergedconfig option Normally, the lvm dumpconfig processes only the configuration tree that is at the top of the cascade. Considering the cascade is: CONFIG_STRING -> CONFIG_PROFILE -> CONFIG_MERGED_FILES/CONFIG_FILE ...then: (dumpconfig of lvm.conf only) raw/~ $ lvm dumpconfig allocation allocation { maximise_cling=1 mirror_logs_require_separate_pvs=0 thin_pool_metadata_require_separate_pvs=0 thin_pool_chunk_size=64 } (dumpconfig of selected profile configuration only) raw/~ $ lvm dumpconfig --profile test allocation allocation { thin_pool_chunk_size=8 thin_pool_discards="passdown" thin_pool_zero=1 } (dumpconfig of given --config configuration only) raw/~ $ lvm dumpconfig --config 'allocation{thin_pool_chunk_size=16}' allocation allocation { thin_pool_chunk_size=16 } The --mergedconfig option causes the configuration cascade to be merged before processing it with dumpconfig: (dumpconfig of merged selected profile and lvm.conf) raw/~ $ lvm dumpconfig --profile test allocation --mergedconfig allocation { maximise_cling=1 thin_pool_zero=1 thin_pool_discards="passdown" mirror_logs_require_separate_pvs=0 thin_pool_metadata_require_separate_pvs=0 thin_pool_chunk_size=8 } (dumpconfig merged given --config and selected profile and lvm.conf) raw/~ $ lvm dumpconfig --profile test --config 'allocation{thin_pool_chunk_size=16}' allocation --mergedconfig allocation { maximise_cling=1 thin_pool_zero=1 thin_pool_discards="passdown" mirror_logs_require_separate_pvs=0 thin_pool_metadata_require_separate_pvs=0 thin_pool_chunk_size=16 } Hence with the --mergedconfig, we are able to see the configuration that is actually used when processing any LVM command while using any combination of --config/--profile options together with lvm.conf file.
2013-07-08 17:34:27 +04:00
*version_int = vsn(major, minor, patchlevel);
return 1;
}
static int _do_def_check(struct config_def_tree_spec *spec,
struct dm_config_tree *cft,
dumpconfig: add --mergedconfig option Normally, the lvm dumpconfig processes only the configuration tree that is at the top of the cascade. Considering the cascade is: CONFIG_STRING -> CONFIG_PROFILE -> CONFIG_MERGED_FILES/CONFIG_FILE ...then: (dumpconfig of lvm.conf only) raw/~ $ lvm dumpconfig allocation allocation { maximise_cling=1 mirror_logs_require_separate_pvs=0 thin_pool_metadata_require_separate_pvs=0 thin_pool_chunk_size=64 } (dumpconfig of selected profile configuration only) raw/~ $ lvm dumpconfig --profile test allocation allocation { thin_pool_chunk_size=8 thin_pool_discards="passdown" thin_pool_zero=1 } (dumpconfig of given --config configuration only) raw/~ $ lvm dumpconfig --config 'allocation{thin_pool_chunk_size=16}' allocation allocation { thin_pool_chunk_size=16 } The --mergedconfig option causes the configuration cascade to be merged before processing it with dumpconfig: (dumpconfig of merged selected profile and lvm.conf) raw/~ $ lvm dumpconfig --profile test allocation --mergedconfig allocation { maximise_cling=1 thin_pool_zero=1 thin_pool_discards="passdown" mirror_logs_require_separate_pvs=0 thin_pool_metadata_require_separate_pvs=0 thin_pool_chunk_size=8 } (dumpconfig merged given --config and selected profile and lvm.conf) raw/~ $ lvm dumpconfig --profile test --config 'allocation{thin_pool_chunk_size=16}' allocation --mergedconfig allocation { maximise_cling=1 thin_pool_zero=1 thin_pool_discards="passdown" mirror_logs_require_separate_pvs=0 thin_pool_metadata_require_separate_pvs=0 thin_pool_chunk_size=16 } Hence with the --mergedconfig, we are able to see the configuration that is actually used when processing any LVM command while using any combination of --config/--profile options together with lvm.conf file.
2013-07-08 17:34:27 +04:00
struct cft_check_handle **cft_check_handle)
{
struct cft_check_handle *handle;
if (!(handle = get_config_tree_check_handle(spec->cmd, cft)))
return 0;
handle->force_check = 1;
handle->suppress_messages = 1;
if (spec->type == CFG_DEF_TREE_DIFF) {
if (!handle->check_diff)
handle->skip_if_checked = 0;
handle->check_diff = 1;
} else {
handle->skip_if_checked = 1;
handle->check_diff = 0;
}
config_def_check(handle);
*cft_check_handle = handle;
return 1;
}
dumpconfig: add --mergedconfig option Normally, the lvm dumpconfig processes only the configuration tree that is at the top of the cascade. Considering the cascade is: CONFIG_STRING -> CONFIG_PROFILE -> CONFIG_MERGED_FILES/CONFIG_FILE ...then: (dumpconfig of lvm.conf only) raw/~ $ lvm dumpconfig allocation allocation { maximise_cling=1 mirror_logs_require_separate_pvs=0 thin_pool_metadata_require_separate_pvs=0 thin_pool_chunk_size=64 } (dumpconfig of selected profile configuration only) raw/~ $ lvm dumpconfig --profile test allocation allocation { thin_pool_chunk_size=8 thin_pool_discards="passdown" thin_pool_zero=1 } (dumpconfig of given --config configuration only) raw/~ $ lvm dumpconfig --config 'allocation{thin_pool_chunk_size=16}' allocation allocation { thin_pool_chunk_size=16 } The --mergedconfig option causes the configuration cascade to be merged before processing it with dumpconfig: (dumpconfig of merged selected profile and lvm.conf) raw/~ $ lvm dumpconfig --profile test allocation --mergedconfig allocation { maximise_cling=1 thin_pool_zero=1 thin_pool_discards="passdown" mirror_logs_require_separate_pvs=0 thin_pool_metadata_require_separate_pvs=0 thin_pool_chunk_size=8 } (dumpconfig merged given --config and selected profile and lvm.conf) raw/~ $ lvm dumpconfig --profile test --config 'allocation{thin_pool_chunk_size=16}' allocation --mergedconfig allocation { maximise_cling=1 thin_pool_zero=1 thin_pool_discards="passdown" mirror_logs_require_separate_pvs=0 thin_pool_metadata_require_separate_pvs=0 thin_pool_chunk_size=16 } Hence with the --mergedconfig, we are able to see the configuration that is actually used when processing any LVM command while using any combination of --config/--profile options together with lvm.conf file.
2013-07-08 17:34:27 +04:00
static int _merge_config_cascade(struct cmd_context *cmd, struct dm_config_tree *cft_cascaded,
struct dm_config_tree **cft_merged)
{
if (!cft_cascaded)
return 1;
if (!*cft_merged && !(*cft_merged = config_open(CONFIG_MERGED_FILES, NULL, 0)))
return_0;
if (!_merge_config_cascade(cmd, cft_cascaded->cascade, cft_merged))
return_0;
return merge_config_tree(cmd, *cft_merged, cft_cascaded, CONFIG_MERGE_TYPE_RAW);
}
static int _config_validate(struct cmd_context *cmd, struct dm_config_tree *cft)
{
struct cft_check_handle *handle;
if (!(handle = get_config_tree_check_handle(cmd, cft)))
return 1;
handle->force_check = 1;
handle->skip_if_checked = 1;
handle->suppress_messages = 0;
return config_def_check(handle);
}
int dumpconfig(struct cmd_context *cmd, int argc, char **argv)
{
const char *file = arg_str_value(cmd, file_ARG, NULL);
lvmconfig: add --type list and -l|--list lvmconfig --type list displays plain list of configuration settings. Some of the existing decorations can be used (--withsummary and --withversions) as well as existing options/switches (--ignoreadvanced, --ignoreunsupported, --ignorelocal, --atversion). For example (displaying only "config" section so the list is not long): $lvmconfig --type list config config/checks config/abort_on_errors config/profile_dir $ lvmconfig --type list --withsummary config config/checks - If enabled, any LVM configuration mismatch is reported. config/abort_on_errors - Abort the LVM process if a configuration mismatch is found. config/profile_dir - Directory where LVM looks for configuration profiles. $ lvmconfig -l config config/checks - If enabled, any LVM configuration mismatch is reported. config/abort_on_errors - Abort the LVM process if a configuration mismatch is found. config/profile_dir - Directory where LVM looks for configuration profiles. $ lvmconfig --type list --withsummary --withversions config config/checks - If enabled, any LVM configuration mismatch is reported. [2.2.99] config/abort_on_errors - Abort the LVM process if a configuration mismatch is found. [2.2.99] config/profile_dir - Directory where LVM looks for configuration profiles. [2.2.99] Example with --atversion (displaying global section): $ lvmconfig --type list global global/umask global/test global/units global/si_unit_consistency global/suffix global/activation global/fallback_to_lvm1 global/format global/format_libraries global/segment_libraries global/proc global/etc global/locking_type global/wait_for_locks global/fallback_to_clustered_locking global/fallback_to_local_locking global/locking_dir global/prioritise_write_locks global/library_dir global/locking_library global/abort_on_internal_errors global/detect_internal_vg_cache_corruption global/metadata_read_only global/mirror_segtype_default global/raid10_segtype_default global/sparse_segtype_default global/lvdisplay_shows_full_device_path global/use_lvmetad global/thin_check_executable global/thin_dump_executable global/thin_repair_executable global/thin_check_options global/thin_repair_options global/thin_disabled_features global/cache_check_executable global/cache_dump_executable global/cache_repair_executable global/cache_check_options global/cache_repair_options global/system_id_source global/system_id_file $ lvmconfig --type list global --atversion 2.2.50 global/umask global/test global/units global/suffix global/activation global/fallback_to_lvm1 global/format global/format_libraries global/segment_libraries global/proc global/locking_type global/wait_for_locks global/fallback_to_clustered_locking global/fallback_to_local_locking global/locking_dir global/library_dir global/locking_library
2015-04-29 12:11:58 +03:00
const char *type = arg_str_value(cmd, configtype_ARG, arg_count(cmd, list_ARG) ? "list" : "current");
struct config_def_tree_spec tree_spec = {0};
2013-07-08 15:45:37 +04:00
struct dm_config_tree *cft = NULL;
struct cft_check_handle *cft_check_handle = NULL;
struct profile *profile = NULL;
int r = ECMD_PROCESSED;
config: add CFG_DEFAULT_RUN_TIME for config options with runtime defaults Previously, we declared a default value as undefined ("NULL") for settings which require runtime context to be set first (e.g. settings for paths that rely on SYSTEM_DIR environment variable or they depend on any other setting in some way). If we want to output default values as they are really used in runtime, we should make it possible to define a default value as function which is evaluated, not just providing a firm constant value as it was before. This patch defines simple prototypes for such functions. Also, there's new helper macros "cfg_runtime" and "cfg_array_runtime" - they provide exactly the same functionality as the original "cfg" and "cfg_array" macros when defining the configuration settings in config_settings.h, but they don't set the constant default value. Instead, they automatically link the configuration setting definition with one of these functions: typedef int (*t_fn_CFG_TYPE_BOOL) (struct cmd_context *cmd, struct profile *profile); typedef int (*t_fn_CFG_TYPE_INT) (struct cmd_context *cmd, struct profile *profile); typedef float (*t_fn_CFG_TYPE_FLOAT) (struct cmd_context *cmd, struct profile *profile); typedef const char* (*t_fn_CFG_TYPE_STRING) (struct cmd_context *cmd, struct profile *profile); typedef const char* (*t_fn_CFG_TYPE_ARRAY) (struct cmd_context *cmd, struct profile *profile); (The new macros actually set the CFG_DEFAULT_RUNTIME flag properly and set the default value link to the function accordingly). Then such configuration setting requires a function of selected type to be defined. This function has a predefined name: get_default_<id> ...where the <id> is the id of the setting as defined in config_settings.h. For example "backup_archive_dir_CFG" if defined as a setting with default value evaluated in runtime with "cfg_runtime" will automatically have "get_default_backup_archive_dir_CFG" function linked to this setting to get the default value.
2014-03-03 15:34:11 +04:00
tree_spec.cmd = cmd;
if (arg_count(cmd, configtype_ARG) && arg_count(cmd, validate_ARG)) {
log_error("Only one of --type and --validate permitted.");
return EINVALID_CMD_LINE;
}
lvmconfig: add --type list and -l|--list lvmconfig --type list displays plain list of configuration settings. Some of the existing decorations can be used (--withsummary and --withversions) as well as existing options/switches (--ignoreadvanced, --ignoreunsupported, --ignorelocal, --atversion). For example (displaying only "config" section so the list is not long): $lvmconfig --type list config config/checks config/abort_on_errors config/profile_dir $ lvmconfig --type list --withsummary config config/checks - If enabled, any LVM configuration mismatch is reported. config/abort_on_errors - Abort the LVM process if a configuration mismatch is found. config/profile_dir - Directory where LVM looks for configuration profiles. $ lvmconfig -l config config/checks - If enabled, any LVM configuration mismatch is reported. config/abort_on_errors - Abort the LVM process if a configuration mismatch is found. config/profile_dir - Directory where LVM looks for configuration profiles. $ lvmconfig --type list --withsummary --withversions config config/checks - If enabled, any LVM configuration mismatch is reported. [2.2.99] config/abort_on_errors - Abort the LVM process if a configuration mismatch is found. [2.2.99] config/profile_dir - Directory where LVM looks for configuration profiles. [2.2.99] Example with --atversion (displaying global section): $ lvmconfig --type list global global/umask global/test global/units global/si_unit_consistency global/suffix global/activation global/fallback_to_lvm1 global/format global/format_libraries global/segment_libraries global/proc global/etc global/locking_type global/wait_for_locks global/fallback_to_clustered_locking global/fallback_to_local_locking global/locking_dir global/prioritise_write_locks global/library_dir global/locking_library global/abort_on_internal_errors global/detect_internal_vg_cache_corruption global/metadata_read_only global/mirror_segtype_default global/raid10_segtype_default global/sparse_segtype_default global/lvdisplay_shows_full_device_path global/use_lvmetad global/thin_check_executable global/thin_dump_executable global/thin_repair_executable global/thin_check_options global/thin_repair_options global/thin_disabled_features global/cache_check_executable global/cache_dump_executable global/cache_repair_executable global/cache_check_options global/cache_repair_options global/system_id_source global/system_id_file $ lvmconfig --type list global --atversion 2.2.50 global/umask global/test global/units global/suffix global/activation global/fallback_to_lvm1 global/format global/format_libraries global/segment_libraries global/proc global/locking_type global/wait_for_locks global/fallback_to_clustered_locking global/fallback_to_local_locking global/locking_dir global/library_dir global/locking_library
2015-04-29 12:11:58 +03:00
if (arg_count(cmd, configtype_ARG) && arg_count(cmd, list_ARG)) {
log_error("Only one of --type and --list permitted.");
return EINVALID_CMD_LINE;
}
if (arg_count(cmd, atversion_ARG) && !arg_count(cmd, configtype_ARG) &&
!arg_count(cmd, list_ARG)) {
log_error("--atversion requires --type or --list");
return EINVALID_CMD_LINE;
}
if (arg_count(cmd, ignoreadvanced_ARG))
tree_spec.ignoreadvanced = 1;
if (arg_count(cmd, ignoreunsupported_ARG))
tree_spec.ignoreunsupported = 1;
if (arg_count(cmd, ignorelocal_ARG))
tree_spec.ignorelocal = 1;
2013-07-08 15:45:37 +04:00
if (!strcmp(type, "current")) {
if (arg_count(cmd, atversion_ARG)) {
log_error("--atversion has no effect with --type current");
return EINVALID_CMD_LINE;
}
if ((tree_spec.ignoreadvanced || tree_spec.ignoreunsupported)) {
log_error("--ignoreadvanced and --ignoreunsupported has "
"no effect with --type current");
return EINVALID_CMD_LINE;
}
} else if (arg_count(cmd, mergedconfig_ARG)) {
log_error("--mergedconfig has no effect without --type current");
return EINVALID_CMD_LINE;
2013-07-08 15:45:37 +04:00
}
if (!_get_vsn(cmd, &tree_spec.version))
return EINVALID_CMD_LINE;
/*
* The profile specified by --profile cmd arg is like --commandprofile,
* but it is used just for dumping the profile content and not for
* application.
*/
if (arg_count(cmd, profile_ARG) &&
(!(profile = add_profile(cmd, arg_str_value(cmd, profile_ARG, NULL), CONFIG_PROFILE_COMMAND)) ||
!override_config_tree_from_profile(cmd, profile))) {
log_error("Failed to load profile %s.", arg_str_value(cmd, profile_ARG, NULL));
return ECMD_FAILED;
}
dumpconfig: add --mergedconfig option Normally, the lvm dumpconfig processes only the configuration tree that is at the top of the cascade. Considering the cascade is: CONFIG_STRING -> CONFIG_PROFILE -> CONFIG_MERGED_FILES/CONFIG_FILE ...then: (dumpconfig of lvm.conf only) raw/~ $ lvm dumpconfig allocation allocation { maximise_cling=1 mirror_logs_require_separate_pvs=0 thin_pool_metadata_require_separate_pvs=0 thin_pool_chunk_size=64 } (dumpconfig of selected profile configuration only) raw/~ $ lvm dumpconfig --profile test allocation allocation { thin_pool_chunk_size=8 thin_pool_discards="passdown" thin_pool_zero=1 } (dumpconfig of given --config configuration only) raw/~ $ lvm dumpconfig --config 'allocation{thin_pool_chunk_size=16}' allocation allocation { thin_pool_chunk_size=16 } The --mergedconfig option causes the configuration cascade to be merged before processing it with dumpconfig: (dumpconfig of merged selected profile and lvm.conf) raw/~ $ lvm dumpconfig --profile test allocation --mergedconfig allocation { maximise_cling=1 thin_pool_zero=1 thin_pool_discards="passdown" mirror_logs_require_separate_pvs=0 thin_pool_metadata_require_separate_pvs=0 thin_pool_chunk_size=8 } (dumpconfig merged given --config and selected profile and lvm.conf) raw/~ $ lvm dumpconfig --profile test --config 'allocation{thin_pool_chunk_size=16}' allocation --mergedconfig allocation { maximise_cling=1 thin_pool_zero=1 thin_pool_discards="passdown" mirror_logs_require_separate_pvs=0 thin_pool_metadata_require_separate_pvs=0 thin_pool_chunk_size=16 } Hence with the --mergedconfig, we are able to see the configuration that is actually used when processing any LVM command while using any combination of --config/--profile options together with lvm.conf file.
2013-07-08 17:34:27 +04:00
/*
* Set the 'cft' to work with based on whether we need the plain
* config tree or merged config tree cascade if --mergedconfig is used.
*/
if (arg_count(cmd, mergedconfig_ARG) && cmd->cft->cascade) {
if (!_merge_config_cascade(cmd, cmd->cft, &cft)) {
log_error("Failed to merge configuration.");
r = ECMD_FAILED;
goto out;
}
} else
cft = cmd->cft;
if (arg_count(cmd, validate_ARG)) {
if (_config_validate(cmd, cft)) {
log_print("LVM configuration valid.");
dumpconfig: add --mergedconfig option Normally, the lvm dumpconfig processes only the configuration tree that is at the top of the cascade. Considering the cascade is: CONFIG_STRING -> CONFIG_PROFILE -> CONFIG_MERGED_FILES/CONFIG_FILE ...then: (dumpconfig of lvm.conf only) raw/~ $ lvm dumpconfig allocation allocation { maximise_cling=1 mirror_logs_require_separate_pvs=0 thin_pool_metadata_require_separate_pvs=0 thin_pool_chunk_size=64 } (dumpconfig of selected profile configuration only) raw/~ $ lvm dumpconfig --profile test allocation allocation { thin_pool_chunk_size=8 thin_pool_discards="passdown" thin_pool_zero=1 } (dumpconfig of given --config configuration only) raw/~ $ lvm dumpconfig --config 'allocation{thin_pool_chunk_size=16}' allocation allocation { thin_pool_chunk_size=16 } The --mergedconfig option causes the configuration cascade to be merged before processing it with dumpconfig: (dumpconfig of merged selected profile and lvm.conf) raw/~ $ lvm dumpconfig --profile test allocation --mergedconfig allocation { maximise_cling=1 thin_pool_zero=1 thin_pool_discards="passdown" mirror_logs_require_separate_pvs=0 thin_pool_metadata_require_separate_pvs=0 thin_pool_chunk_size=8 } (dumpconfig merged given --config and selected profile and lvm.conf) raw/~ $ lvm dumpconfig --profile test --config 'allocation{thin_pool_chunk_size=16}' allocation --mergedconfig allocation { maximise_cling=1 thin_pool_zero=1 thin_pool_discards="passdown" mirror_logs_require_separate_pvs=0 thin_pool_metadata_require_separate_pvs=0 thin_pool_chunk_size=16 } Hence with the --mergedconfig, we are able to see the configuration that is actually used when processing any LVM command while using any combination of --config/--profile options together with lvm.conf file.
2013-07-08 17:34:27 +04:00
goto out;
} else {
log_error("LVM configuration invalid.");
dumpconfig: add --mergedconfig option Normally, the lvm dumpconfig processes only the configuration tree that is at the top of the cascade. Considering the cascade is: CONFIG_STRING -> CONFIG_PROFILE -> CONFIG_MERGED_FILES/CONFIG_FILE ...then: (dumpconfig of lvm.conf only) raw/~ $ lvm dumpconfig allocation allocation { maximise_cling=1 mirror_logs_require_separate_pvs=0 thin_pool_metadata_require_separate_pvs=0 thin_pool_chunk_size=64 } (dumpconfig of selected profile configuration only) raw/~ $ lvm dumpconfig --profile test allocation allocation { thin_pool_chunk_size=8 thin_pool_discards="passdown" thin_pool_zero=1 } (dumpconfig of given --config configuration only) raw/~ $ lvm dumpconfig --config 'allocation{thin_pool_chunk_size=16}' allocation allocation { thin_pool_chunk_size=16 } The --mergedconfig option causes the configuration cascade to be merged before processing it with dumpconfig: (dumpconfig of merged selected profile and lvm.conf) raw/~ $ lvm dumpconfig --profile test allocation --mergedconfig allocation { maximise_cling=1 thin_pool_zero=1 thin_pool_discards="passdown" mirror_logs_require_separate_pvs=0 thin_pool_metadata_require_separate_pvs=0 thin_pool_chunk_size=8 } (dumpconfig merged given --config and selected profile and lvm.conf) raw/~ $ lvm dumpconfig --profile test --config 'allocation{thin_pool_chunk_size=16}' allocation --mergedconfig allocation { maximise_cling=1 thin_pool_zero=1 thin_pool_discards="passdown" mirror_logs_require_separate_pvs=0 thin_pool_metadata_require_separate_pvs=0 thin_pool_chunk_size=16 } Hence with the --mergedconfig, we are able to see the configuration that is actually used when processing any LVM command while using any combination of --config/--profile options together with lvm.conf file.
2013-07-08 17:34:27 +04:00
r = ECMD_FAILED;
goto out;
}
}
lvmconfig: add --type list and -l|--list lvmconfig --type list displays plain list of configuration settings. Some of the existing decorations can be used (--withsummary and --withversions) as well as existing options/switches (--ignoreadvanced, --ignoreunsupported, --ignorelocal, --atversion). For example (displaying only "config" section so the list is not long): $lvmconfig --type list config config/checks config/abort_on_errors config/profile_dir $ lvmconfig --type list --withsummary config config/checks - If enabled, any LVM configuration mismatch is reported. config/abort_on_errors - Abort the LVM process if a configuration mismatch is found. config/profile_dir - Directory where LVM looks for configuration profiles. $ lvmconfig -l config config/checks - If enabled, any LVM configuration mismatch is reported. config/abort_on_errors - Abort the LVM process if a configuration mismatch is found. config/profile_dir - Directory where LVM looks for configuration profiles. $ lvmconfig --type list --withsummary --withversions config config/checks - If enabled, any LVM configuration mismatch is reported. [2.2.99] config/abort_on_errors - Abort the LVM process if a configuration mismatch is found. [2.2.99] config/profile_dir - Directory where LVM looks for configuration profiles. [2.2.99] Example with --atversion (displaying global section): $ lvmconfig --type list global global/umask global/test global/units global/si_unit_consistency global/suffix global/activation global/fallback_to_lvm1 global/format global/format_libraries global/segment_libraries global/proc global/etc global/locking_type global/wait_for_locks global/fallback_to_clustered_locking global/fallback_to_local_locking global/locking_dir global/prioritise_write_locks global/library_dir global/locking_library global/abort_on_internal_errors global/detect_internal_vg_cache_corruption global/metadata_read_only global/mirror_segtype_default global/raid10_segtype_default global/sparse_segtype_default global/lvdisplay_shows_full_device_path global/use_lvmetad global/thin_check_executable global/thin_dump_executable global/thin_repair_executable global/thin_check_options global/thin_repair_options global/thin_disabled_features global/cache_check_executable global/cache_dump_executable global/cache_repair_executable global/cache_check_options global/cache_repair_options global/system_id_source global/system_id_file $ lvmconfig --type list global --atversion 2.2.50 global/umask global/test global/units global/suffix global/activation global/fallback_to_lvm1 global/format global/format_libraries global/segment_libraries global/proc global/locking_type global/wait_for_locks global/fallback_to_clustered_locking global/fallback_to_local_locking global/locking_dir global/library_dir global/locking_library
2015-04-29 12:11:58 +03:00
if (!strcmp(type, "list") || arg_count(cmd, list_ARG)) {
tree_spec.type = CFG_DEF_TREE_LIST;
if (arg_count(cmd, withcomments_ARG)) {
log_error("--withcomments has no effect with --type list");
return EINVALID_CMD_LINE;
}
/* list type does not require status check */
} else if (!strcmp(type, "current")) {
tree_spec.type = CFG_DEF_TREE_CURRENT;
if (!_do_def_check(&tree_spec, cft, &cft_check_handle)) {
dumpconfig: add --mergedconfig option Normally, the lvm dumpconfig processes only the configuration tree that is at the top of the cascade. Considering the cascade is: CONFIG_STRING -> CONFIG_PROFILE -> CONFIG_MERGED_FILES/CONFIG_FILE ...then: (dumpconfig of lvm.conf only) raw/~ $ lvm dumpconfig allocation allocation { maximise_cling=1 mirror_logs_require_separate_pvs=0 thin_pool_metadata_require_separate_pvs=0 thin_pool_chunk_size=64 } (dumpconfig of selected profile configuration only) raw/~ $ lvm dumpconfig --profile test allocation allocation { thin_pool_chunk_size=8 thin_pool_discards="passdown" thin_pool_zero=1 } (dumpconfig of given --config configuration only) raw/~ $ lvm dumpconfig --config 'allocation{thin_pool_chunk_size=16}' allocation allocation { thin_pool_chunk_size=16 } The --mergedconfig option causes the configuration cascade to be merged before processing it with dumpconfig: (dumpconfig of merged selected profile and lvm.conf) raw/~ $ lvm dumpconfig --profile test allocation --mergedconfig allocation { maximise_cling=1 thin_pool_zero=1 thin_pool_discards="passdown" mirror_logs_require_separate_pvs=0 thin_pool_metadata_require_separate_pvs=0 thin_pool_chunk_size=8 } (dumpconfig merged given --config and selected profile and lvm.conf) raw/~ $ lvm dumpconfig --profile test --config 'allocation{thin_pool_chunk_size=16}' allocation --mergedconfig allocation { maximise_cling=1 thin_pool_zero=1 thin_pool_discards="passdown" mirror_logs_require_separate_pvs=0 thin_pool_metadata_require_separate_pvs=0 thin_pool_chunk_size=16 } Hence with the --mergedconfig, we are able to see the configuration that is actually used when processing any LVM command while using any combination of --config/--profile options together with lvm.conf file.
2013-07-08 17:34:27 +04:00
r = ECMD_FAILED;
goto_out;
}
}
else if (!strcmp(type, "missing")) {
tree_spec.type = CFG_DEF_TREE_MISSING;
if (!_do_def_check(&tree_spec, cft, &cft_check_handle)) {
dumpconfig: add --mergedconfig option Normally, the lvm dumpconfig processes only the configuration tree that is at the top of the cascade. Considering the cascade is: CONFIG_STRING -> CONFIG_PROFILE -> CONFIG_MERGED_FILES/CONFIG_FILE ...then: (dumpconfig of lvm.conf only) raw/~ $ lvm dumpconfig allocation allocation { maximise_cling=1 mirror_logs_require_separate_pvs=0 thin_pool_metadata_require_separate_pvs=0 thin_pool_chunk_size=64 } (dumpconfig of selected profile configuration only) raw/~ $ lvm dumpconfig --profile test allocation allocation { thin_pool_chunk_size=8 thin_pool_discards="passdown" thin_pool_zero=1 } (dumpconfig of given --config configuration only) raw/~ $ lvm dumpconfig --config 'allocation{thin_pool_chunk_size=16}' allocation allocation { thin_pool_chunk_size=16 } The --mergedconfig option causes the configuration cascade to be merged before processing it with dumpconfig: (dumpconfig of merged selected profile and lvm.conf) raw/~ $ lvm dumpconfig --profile test allocation --mergedconfig allocation { maximise_cling=1 thin_pool_zero=1 thin_pool_discards="passdown" mirror_logs_require_separate_pvs=0 thin_pool_metadata_require_separate_pvs=0 thin_pool_chunk_size=8 } (dumpconfig merged given --config and selected profile and lvm.conf) raw/~ $ lvm dumpconfig --profile test --config 'allocation{thin_pool_chunk_size=16}' allocation --mergedconfig allocation { maximise_cling=1 thin_pool_zero=1 thin_pool_discards="passdown" mirror_logs_require_separate_pvs=0 thin_pool_metadata_require_separate_pvs=0 thin_pool_chunk_size=16 } Hence with the --mergedconfig, we are able to see the configuration that is actually used when processing any LVM command while using any combination of --config/--profile options together with lvm.conf file.
2013-07-08 17:34:27 +04:00
r = ECMD_FAILED;
goto_out;
}
}
else if (!strcmp(type, "default")) {
tree_spec.type = CFG_DEF_TREE_DEFAULT;
/* default type does not require check status */
}
else if (!strcmp(type, "diff")) {
tree_spec.type = CFG_DEF_TREE_DIFF;
if (!_do_def_check(&tree_spec, cft, &cft_check_handle)) {
r = ECMD_FAILED;
goto_out;
}
}
else if (!strcmp(type, "new")) {
tree_spec.type = CFG_DEF_TREE_NEW;
/* new type does not require check status */
}
else if (!strcmp(type, "profilable")) {
tree_spec.type = CFG_DEF_TREE_PROFILABLE;
/* profilable type does not require check status */
}
else if (!strcmp(type, "profilable-command")) {
tree_spec.type = CFG_DEF_TREE_PROFILABLE_CMD;
/* profilable-command type does not require check status */
}
else if (!strcmp(type, "profilable-metadata")) {
tree_spec.type = CFG_DEF_TREE_PROFILABLE_MDA;
/* profilable-metadata type does not require check status */
}
else {
log_error("Incorrect type of configuration specified. "
lvmconfig: add --type list and -l|--list lvmconfig --type list displays plain list of configuration settings. Some of the existing decorations can be used (--withsummary and --withversions) as well as existing options/switches (--ignoreadvanced, --ignoreunsupported, --ignorelocal, --atversion). For example (displaying only "config" section so the list is not long): $lvmconfig --type list config config/checks config/abort_on_errors config/profile_dir $ lvmconfig --type list --withsummary config config/checks - If enabled, any LVM configuration mismatch is reported. config/abort_on_errors - Abort the LVM process if a configuration mismatch is found. config/profile_dir - Directory where LVM looks for configuration profiles. $ lvmconfig -l config config/checks - If enabled, any LVM configuration mismatch is reported. config/abort_on_errors - Abort the LVM process if a configuration mismatch is found. config/profile_dir - Directory where LVM looks for configuration profiles. $ lvmconfig --type list --withsummary --withversions config config/checks - If enabled, any LVM configuration mismatch is reported. [2.2.99] config/abort_on_errors - Abort the LVM process if a configuration mismatch is found. [2.2.99] config/profile_dir - Directory where LVM looks for configuration profiles. [2.2.99] Example with --atversion (displaying global section): $ lvmconfig --type list global global/umask global/test global/units global/si_unit_consistency global/suffix global/activation global/fallback_to_lvm1 global/format global/format_libraries global/segment_libraries global/proc global/etc global/locking_type global/wait_for_locks global/fallback_to_clustered_locking global/fallback_to_local_locking global/locking_dir global/prioritise_write_locks global/library_dir global/locking_library global/abort_on_internal_errors global/detect_internal_vg_cache_corruption global/metadata_read_only global/mirror_segtype_default global/raid10_segtype_default global/sparse_segtype_default global/lvdisplay_shows_full_device_path global/use_lvmetad global/thin_check_executable global/thin_dump_executable global/thin_repair_executable global/thin_check_options global/thin_repair_options global/thin_disabled_features global/cache_check_executable global/cache_dump_executable global/cache_repair_executable global/cache_check_options global/cache_repair_options global/system_id_source global/system_id_file $ lvmconfig --type list global --atversion 2.2.50 global/umask global/test global/units global/suffix global/activation global/fallback_to_lvm1 global/format global/format_libraries global/segment_libraries global/proc global/locking_type global/wait_for_locks global/fallback_to_clustered_locking global/fallback_to_local_locking global/locking_dir global/library_dir global/locking_library
2015-04-29 12:11:58 +03:00
"Expected one of: current, default, list, missing, new, "
"profilable, profilable-command, profilable-metadata.");
dumpconfig: add --mergedconfig option Normally, the lvm dumpconfig processes only the configuration tree that is at the top of the cascade. Considering the cascade is: CONFIG_STRING -> CONFIG_PROFILE -> CONFIG_MERGED_FILES/CONFIG_FILE ...then: (dumpconfig of lvm.conf only) raw/~ $ lvm dumpconfig allocation allocation { maximise_cling=1 mirror_logs_require_separate_pvs=0 thin_pool_metadata_require_separate_pvs=0 thin_pool_chunk_size=64 } (dumpconfig of selected profile configuration only) raw/~ $ lvm dumpconfig --profile test allocation allocation { thin_pool_chunk_size=8 thin_pool_discards="passdown" thin_pool_zero=1 } (dumpconfig of given --config configuration only) raw/~ $ lvm dumpconfig --config 'allocation{thin_pool_chunk_size=16}' allocation allocation { thin_pool_chunk_size=16 } The --mergedconfig option causes the configuration cascade to be merged before processing it with dumpconfig: (dumpconfig of merged selected profile and lvm.conf) raw/~ $ lvm dumpconfig --profile test allocation --mergedconfig allocation { maximise_cling=1 thin_pool_zero=1 thin_pool_discards="passdown" mirror_logs_require_separate_pvs=0 thin_pool_metadata_require_separate_pvs=0 thin_pool_chunk_size=8 } (dumpconfig merged given --config and selected profile and lvm.conf) raw/~ $ lvm dumpconfig --profile test --config 'allocation{thin_pool_chunk_size=16}' allocation --mergedconfig allocation { maximise_cling=1 thin_pool_zero=1 thin_pool_discards="passdown" mirror_logs_require_separate_pvs=0 thin_pool_metadata_require_separate_pvs=0 thin_pool_chunk_size=16 } Hence with the --mergedconfig, we are able to see the configuration that is actually used when processing any LVM command while using any combination of --config/--profile options together with lvm.conf file.
2013-07-08 17:34:27 +04:00
r = EINVALID_CMD_LINE;
goto out;
}
lvmconfig: add --type list and -l|--list lvmconfig --type list displays plain list of configuration settings. Some of the existing decorations can be used (--withsummary and --withversions) as well as existing options/switches (--ignoreadvanced, --ignoreunsupported, --ignorelocal, --atversion). For example (displaying only "config" section so the list is not long): $lvmconfig --type list config config/checks config/abort_on_errors config/profile_dir $ lvmconfig --type list --withsummary config config/checks - If enabled, any LVM configuration mismatch is reported. config/abort_on_errors - Abort the LVM process if a configuration mismatch is found. config/profile_dir - Directory where LVM looks for configuration profiles. $ lvmconfig -l config config/checks - If enabled, any LVM configuration mismatch is reported. config/abort_on_errors - Abort the LVM process if a configuration mismatch is found. config/profile_dir - Directory where LVM looks for configuration profiles. $ lvmconfig --type list --withsummary --withversions config config/checks - If enabled, any LVM configuration mismatch is reported. [2.2.99] config/abort_on_errors - Abort the LVM process if a configuration mismatch is found. [2.2.99] config/profile_dir - Directory where LVM looks for configuration profiles. [2.2.99] Example with --atversion (displaying global section): $ lvmconfig --type list global global/umask global/test global/units global/si_unit_consistency global/suffix global/activation global/fallback_to_lvm1 global/format global/format_libraries global/segment_libraries global/proc global/etc global/locking_type global/wait_for_locks global/fallback_to_clustered_locking global/fallback_to_local_locking global/locking_dir global/prioritise_write_locks global/library_dir global/locking_library global/abort_on_internal_errors global/detect_internal_vg_cache_corruption global/metadata_read_only global/mirror_segtype_default global/raid10_segtype_default global/sparse_segtype_default global/lvdisplay_shows_full_device_path global/use_lvmetad global/thin_check_executable global/thin_dump_executable global/thin_repair_executable global/thin_check_options global/thin_repair_options global/thin_disabled_features global/cache_check_executable global/cache_dump_executable global/cache_repair_executable global/cache_check_options global/cache_repair_options global/system_id_source global/system_id_file $ lvmconfig --type list global --atversion 2.2.50 global/umask global/test global/units global/suffix global/activation global/fallback_to_lvm1 global/format global/format_libraries global/segment_libraries global/proc global/locking_type global/wait_for_locks global/fallback_to_clustered_locking global/fallback_to_local_locking global/locking_dir global/library_dir global/locking_library
2015-04-29 12:11:58 +03:00
if (arg_count(cmd, withsummary_ARG) || arg_count(cmd, list_ARG))
tree_spec.withsummary = 1;
if (arg_count(cmd, withcomments_ARG))
tree_spec.withcomments = 1;
if (arg_count(cmd, unconfigured_ARG))
tree_spec.unconfigured = 1;
if (arg_count(cmd, withversions_ARG))
tree_spec.withversions = 1;
if (cft_check_handle)
tree_spec.check_status = cft_check_handle->status;
if ((tree_spec.type != CFG_DEF_TREE_CURRENT) &&
(tree_spec.type != CFG_DEF_TREE_DIFF) &&
!(cft = config_def_create_tree(&tree_spec))) {
r = ECMD_FAILED;
goto_out;
}
if (!config_write(cft, &tree_spec, file, argc, argv)) {
stack;
r = ECMD_FAILED;
}
dumpconfig: add --mergedconfig option Normally, the lvm dumpconfig processes only the configuration tree that is at the top of the cascade. Considering the cascade is: CONFIG_STRING -> CONFIG_PROFILE -> CONFIG_MERGED_FILES/CONFIG_FILE ...then: (dumpconfig of lvm.conf only) raw/~ $ lvm dumpconfig allocation allocation { maximise_cling=1 mirror_logs_require_separate_pvs=0 thin_pool_metadata_require_separate_pvs=0 thin_pool_chunk_size=64 } (dumpconfig of selected profile configuration only) raw/~ $ lvm dumpconfig --profile test allocation allocation { thin_pool_chunk_size=8 thin_pool_discards="passdown" thin_pool_zero=1 } (dumpconfig of given --config configuration only) raw/~ $ lvm dumpconfig --config 'allocation{thin_pool_chunk_size=16}' allocation allocation { thin_pool_chunk_size=16 } The --mergedconfig option causes the configuration cascade to be merged before processing it with dumpconfig: (dumpconfig of merged selected profile and lvm.conf) raw/~ $ lvm dumpconfig --profile test allocation --mergedconfig allocation { maximise_cling=1 thin_pool_zero=1 thin_pool_discards="passdown" mirror_logs_require_separate_pvs=0 thin_pool_metadata_require_separate_pvs=0 thin_pool_chunk_size=8 } (dumpconfig merged given --config and selected profile and lvm.conf) raw/~ $ lvm dumpconfig --profile test --config 'allocation{thin_pool_chunk_size=16}' allocation --mergedconfig allocation { maximise_cling=1 thin_pool_zero=1 thin_pool_discards="passdown" mirror_logs_require_separate_pvs=0 thin_pool_metadata_require_separate_pvs=0 thin_pool_chunk_size=16 } Hence with the --mergedconfig, we are able to see the configuration that is actually used when processing any LVM command while using any combination of --config/--profile options together with lvm.conf file.
2013-07-08 17:34:27 +04:00
out:
if (cft && (cft != cmd->cft))
dm_pool_destroy(cft->mem);
else if (profile)
remove_config_tree_by_source(cmd, CONFIG_PROFILE_COMMAND);
2013-07-08 15:45:37 +04:00
/*
* The cmd->cft (the "current" tree) is destroyed
* together with cmd context destroy...
*/
return r;
}
int config(struct cmd_context *cmd, int argc, char **argv)
{
return dumpconfig(cmd, argc, argv);
}
int lvmconfig(struct cmd_context *cmd, int argc, char **argv)
{
return dumpconfig(cmd, argc, argv);
}