diff options
author | Peter Rajnoha <prajnoha@redhat.com> | 2013-06-25 12:33:06 +0200 |
---|---|---|
committer | Peter Rajnoha <prajnoha@redhat.com> | 2013-07-02 15:22:10 +0200 |
commit | 0cd47947359d2ba093dc7da5e489cafb34b038d0 (patch) | |
tree | 1381b1617111bd4f31c4565798731f8ee0677f28 /tools/vgchange.c | |
parent | e21e38cf740b5b174e59fe400663bf6847f2f547 (diff) | |
download | lvm2-0cd47947359d2ba093dc7da5e489cafb34b038d0.tar.gz |
tools: add support for changing configuration profile for existing volumes (vgchange/lvchange)
The command to change the profile for existing VG/LV:
"vgchange/lvchange --profile <profile_name>"
The command to detach any existing profile from VG/LV:
"vgchange/lvchange --detachprofile"
Diffstat (limited to 'tools/vgchange.c')
-rw-r--r-- | tools/vgchange.c | 35 |
1 files changed, 34 insertions, 1 deletions
diff --git a/tools/vgchange.c b/tools/vgchange.c index 683159733..e55c40453 100644 --- a/tools/vgchange.c +++ b/tools/vgchange.c @@ -419,6 +419,30 @@ static int _vgchange_metadata_copies(struct cmd_context *cmd, return 1; } +static int _vgchange_profile(struct cmd_context *cmd, + struct volume_group *vg) +{ + const char *old_profile_name, *new_profile_name; + struct profile *new_profile; + + old_profile_name = vg->profile ? vg->profile->name : "(no profile)"; + + if (arg_count(cmd, detachprofile_ARG)) { + new_profile_name = "(no profile)"; + vg->profile = NULL; + } else { + new_profile_name = arg_str_value(cmd, profile_ARG, NULL); + if (!(new_profile = add_profile(cmd, new_profile_name))) + return_0; + vg->profile = new_profile; + } + + log_verbose("Changing configuration profile for VG %s: %s -> %s.", + vg->name, old_profile_name, new_profile_name); + + return 1; +} + static int vgchange_single(struct cmd_context *cmd, const char *vg_name, struct volume_group *vg, void *handle __attribute__((unused))) @@ -439,6 +463,8 @@ static int vgchange_single(struct cmd_context *cmd, const char *vg_name, { alloc_ARG, &_vgchange_alloc }, { clustered_ARG, &_vgchange_clustered }, { vgmetadatacopies_ARG, &_vgchange_metadata_copies }, + { profile_ARG, &_vgchange_profile}, + { detachprofile_ARG, &_vgchange_profile}, { -1, NULL }, }; @@ -511,7 +537,9 @@ int vgchange(struct cmd_context *cmd, int argc, char **argv) /* Update commands that can be combined */ int update_partial_safe = arg_count(cmd, deltag_ARG) || - arg_count(cmd, addtag_ARG); + arg_count(cmd, addtag_ARG) || + arg_count(cmd, profile_ARG) || + arg_count(cmd, detachprofile_ARG); int update_partial_unsafe = arg_count(cmd, logicalvolume_ARG) || arg_count(cmd, maxphysicalvolumes_ARG) || @@ -535,6 +563,11 @@ int vgchange(struct cmd_context *cmd, int argc, char **argv) return EINVALID_CMD_LINE; } + if (arg_count(cmd, profile_ARG) && arg_count(cmd, detachprofile_ARG)) { + log_error("Only one of --profile and --detachprofile permitted."); + return EINVALID_CMD_LINE; + } + if (arg_count(cmd, activate_ARG) && arg_count(cmd, refresh_ARG)) { log_error("Only one of -a and --refresh permitted."); return EINVALID_CMD_LINE; |