lvmcmdline: still support use of profile 1752567800
authorZdenek Kabelac <zkabelac@redhat.com>
Wed, 2 Apr 2025 08:58:16 +0000 (10:58 +0200)
committerZdenek Kabelac <zkabelac@redhat.com>
Fri, 4 Apr 2025 12:48:57 +0000 (14:48 +0200)
Couple commands (lvcreate,lvconvert,vgcreate,lvchange,vgchange)
has the 'specific' property that within them the option --profile
behaves like --metadataprofile, while for all other commands this
option should be simply an alias for --commandprofile.

We may eventually drop this rather confusing behavior in the future
version and there will be only one use as --[command]profile

It should be noted this --commandprofile can be often used
instead of --config option for preconfiguring setting
for some group of commands - we should possibly more propagate
this usage.

tools/lvchange.c
tools/lvmcmdline.c

index d9399fc8935065717673d5ea6268377dec742dde..0ccebd3448eb91a41a2a5d2affd513d68217f95d 100644 (file)
@@ -1360,8 +1360,11 @@ static int _lvchange_properties_single(struct cmd_context *cmd,
        for (i = 0; i < cmd->command->ro_count + cmd->command->any_ro_count; i++) {
                opt_enum = cmd->command->required_opt_args[i].opt;
 
-               if (!arg_is_set(cmd, opt_enum))
-                       continue;
+               if (!arg_is_set(cmd, opt_enum)) {
+                       if ((opt_enum != metadataprofile_ARG) ||
+                           !arg_is_set(cmd, profile_ARG))
+                               continue;
+               }
 
                /*
                 * Skip options requiring direct commit/reload
index ddcef0063dfce0db3452bc4239210b01bf3d13f3..2cc6087d3477697e150160d352693ecd1d13ffe2 100644 (file)
@@ -1137,6 +1137,15 @@ int headings_arg(struct cmd_context *cmd, struct arg_values *av)
        return report_headings_str_to_type(av->value) != REPORT_HEADINGS_UNKNOWN;
 }
 
+static int _is_profile_metadataprofile(const char *name)
+{
+       return (!strcmp(name, "lvcreate") ||
+               !strcmp(name, "lvconvert") ||
+               !strcmp(name, "vgcreate") ||
+               !strcmp(name, "lvchange") ||
+               !strcmp(name, "vgchange"));
+}
+
 /*
  * FIXME: there's been a confusing mixup among:
  * resizeable, resizable, allocatable, allocation.
@@ -1187,6 +1196,10 @@ static int _opt_standard_to_synonym(const char *cmd_name, int opt)
                if (!strncmp(cmd_name, "vg", 2))
                        return metadatacopies_ARG;
                return 0;
+       case metadataprofile_ARG:
+               if (_is_profile_metadataprofile(cmd_name))
+                       return profile_ARG;
+               return 0;
        }
        return 0;
 }
@@ -1224,6 +1237,10 @@ static int _opt_synonym_to_standard(const char *cmd_name, int opt)
                if (!strncmp(cmd_name, "vg", 2))
                        return vgmetadatacopies_ARG;
                return 0;
+       case profile_ARG:
+               if (_is_profile_metadataprofile(cmd_name))
+                       return metadataprofile_ARG;
+               return 0;
        }
        return 0;
 }
@@ -2820,11 +2837,7 @@ static int _prepare_profiles(struct cmd_context *cmd)
                 * it's recognized as shortcut to --metadataprofile.
                 * The --commandprofile is assumed otherwise.
                 */
-               if (!strcmp(cmd->command->name, "lvcreate") ||
-                   !strcmp(cmd->command->name, "lvconvert") ||
-                   !strcmp(cmd->command->name, "vgcreate") ||
-                   !strcmp(cmd->command->name, "lvchange") ||
-                   !strcmp(cmd->command->name, "vgchange")) {
+               if (_is_profile_metadataprofile(cmd->command->name)) {
                        if (arg_is_set(cmd, metadataprofile_ARG)) {
                                log_error("Only one of --profile or "
                                          " --metadataprofile allowed.");
This page took 0.108296 seconds and 5 git commands to generate.