diff --git a/lib/commands/toolcontext.h b/lib/commands/toolcontext.h index 07a9e889c..cfe1de1aa 100644 --- a/lib/commands/toolcontext.h +++ b/lib/commands/toolcontext.h @@ -216,6 +216,7 @@ struct cmd_context { unsigned device_ids_check_hostname:1; unsigned device_ids_refresh_trigger:1; unsigned device_ids_invalid:1; + unsigned get_vgname_from_options:1; /* used by lvconvert */ /* * Devices and filtering. diff --git a/tools/lvconvert.c b/tools/lvconvert.c index b848a895b..4d919ae54 100644 --- a/tools/lvconvert.c +++ b/tools/lvconvert.c @@ -5449,7 +5449,7 @@ static int _lvconvert_merge_mirror_images_single(struct cmd_context *cmd, int lvconvert_merge_mirror_images_cmd(struct cmd_context *cmd, int argc, char **argv) { /* arg can be a VG name, which is the standard option usage */ - cmd->cname->flags &= ~GET_VGNAME_FROM_OPTIONS; + cmd->get_vgname_from_options = 0; return process_each_lv(cmd, cmd->position_argc, cmd->position_argv, NULL, NULL, READ_FOR_UPDATE, NULL, &_lvconvert_visible_check, &_lvconvert_merge_mirror_images_single); @@ -5489,7 +5489,7 @@ int lvconvert_merge_cmd(struct cmd_context *cmd, int argc, char **argv) handle->custom_handle = &lr; - cmd->cname->flags &= ~GET_VGNAME_FROM_OPTIONS; + cmd->get_vgname_from_options = 0; ret = process_each_lv(cmd, cmd->position_argc, cmd->position_argv, NULL, NULL, READ_FOR_UPDATE, handle, NULL, &_lvconvert_merge_generic_single); @@ -6399,7 +6399,7 @@ int lvconvert_to_writecache_cmd(struct cmd_context *cmd, int argc, char **argv) handle->custom_handle = &lr; - cmd->cname->flags &= ~GET_VGNAME_FROM_OPTIONS; + cmd->get_vgname_from_options = 0; ret = process_each_lv(cmd, cmd->position_argc, cmd->position_argv, NULL, NULL, READ_FOR_UPDATE, handle, NULL, &lvconvert_writecache_attach_single); @@ -6422,7 +6422,7 @@ int lvconvert_to_cache_with_cachevol_cmd(struct cmd_context *cmd, int argc, char handle->custom_handle = &lr; - cmd->cname->flags &= ~GET_VGNAME_FROM_OPTIONS; + cmd->get_vgname_from_options = 0; ret = process_each_lv(cmd, cmd->position_argc, cmd->position_argv, NULL, NULL, READ_FOR_UPDATE, handle, NULL, &lvconvert_cachevol_attach_single); @@ -6528,7 +6528,7 @@ int lvconvert_integrity_cmd(struct cmd_context *cmd, int argc, char **argv) /* Want to be able to remove integrity from partial LV */ cmd->handles_missing_pvs = 1; - cmd->cname->flags &= ~GET_VGNAME_FROM_OPTIONS; + cmd->get_vgname_from_options = 0; ret = process_each_lv(cmd, cmd->position_argc, cmd->position_argv, NULL, NULL, READ_FOR_UPDATE, handle, NULL, &_lvconvert_integrity_single); diff --git a/tools/lvmcmdline.c b/tools/lvmcmdline.c index 4520b893b..6ae82032d 100644 --- a/tools/lvmcmdline.c +++ b/tools/lvmcmdline.c @@ -3161,6 +3161,8 @@ int lvm_run_command(struct cmd_context *cmd, int argc, char **argv) if (!(cmd->cname = find_command_name(cmd->name))) return ENO_SUCH_CMD; + cmd->get_vgname_from_options = (cmd->cname->flags & GET_VGNAME_FROM_OPTIONS) ? 1 : 0; + if (!_process_command_line(cmd, &argc, &argv)) { log_error("Error during parsing of command line."); return EINVALID_CMD_LINE; diff --git a/tools/toollib.c b/tools/toollib.c index 5fb210a25..31867f054 100644 --- a/tools/toollib.c +++ b/tools/toollib.c @@ -4014,7 +4014,7 @@ int process_each_lv(struct cmd_context *cmd, /* * Find any LVs, VGs or tags explicitly provided on the command line. */ - if (cmd->cname->flags & GET_VGNAME_FROM_OPTIONS) + if (cmd->get_vgname_from_options) ret = _get_arg_lvnames_using_options(cmd, argc, argv, &arg_vgnames, &arg_lvnames, &arg_tags); else ret = _get_arg_lvnames(cmd, argc, argv, one_vgname, one_lvname, &arg_vgnames, &arg_lvnames, &arg_tags);