summaryrefslogtreecommitdiff
path: root/tools/vgchange.c
diff options
context:
space:
mode:
Diffstat (limited to 'tools/vgchange.c')
-rw-r--r--tools/vgchange.c69
1 files changed, 56 insertions, 13 deletions
diff --git a/tools/vgchange.c b/tools/vgchange.c
index 9a9fe4866..e766beceb 100644
--- a/tools/vgchange.c
+++ b/tools/vgchange.c
@@ -336,6 +336,9 @@ static int _vgchange_clustered(struct cmd_context *cmd,
}
}
+ if (clustered)
+ vg->system_id = NULL;
+
if (!vg_set_clustered(vg, clustered))
return_0;
@@ -475,6 +478,39 @@ static int _vgchange_profile(struct cmd_context *cmd,
return 1;
}
+static int _vgchange_system_id(struct cmd_context *cmd, struct volume_group *vg)
+{
+ const char *system_id = arg_str_value(cmd, systemid_ARG, NULL);
+ const char *source = arg_str_value(cmd, systemidsource_ARG, NULL);
+
+ if (vg->system_id && vg->system_id[0] && !arg_is_set(cmd, force_ARG)) {
+ log_error("Volume group \"%s\" already has system id \"%s\"",
+ vg->name, vg->system_id);
+ return 0;
+ }
+
+ if (system_id) {
+ vg->system_id = system_id_from_string(cmd, system_id);
+ return 1;
+ }
+
+ if (!source)
+ return 1;
+
+ if (!strcmp(source, "none")) {
+ vg->system_id = NULL;
+ return 1;
+ }
+
+ if ((system_id = system_id_from_source(cmd, source))) {
+ vg->system_id = (char *)system_id;
+ return 1;
+ }
+
+ log_error("No system_id found from source %s", source);
+ return 0;
+}
+
static int vgchange_single(struct cmd_context *cmd, const char *vg_name,
struct volume_group *vg,
void *handle __attribute__((unused)))
@@ -498,8 +534,10 @@ static int vgchange_single(struct cmd_context *cmd, const char *vg_name,
{ clustered_ARG, &_vgchange_clustered },
{ vgmetadatacopies_ARG, &_vgchange_metadata_copies },
{ metadataprofile_ARG, &_vgchange_profile },
- { profile_ARG, &_vgchange_profile},
- { detachprofile_ARG, &_vgchange_profile},
+ { profile_ARG, &_vgchange_profile },
+ { detachprofile_ARG, &_vgchange_profile },
+ { systemid_ARG, &_vgchange_system_id },
+ { systemidsource_ARG, &_vgchange_system_id },
};
if (vg_is_exported(vg)) {
@@ -593,13 +631,19 @@ static int vgchange_single(struct cmd_context *cmd, const char *vg_name,
int vgchange(struct cmd_context *cmd, int argc, char **argv)
{
- /* Update commands that can be combined */
+ int noupdate =
+ arg_count(cmd, activate_ARG) ||
+ arg_count(cmd, monitor_ARG) ||
+ arg_count(cmd, poll_ARG) ||
+ arg_count(cmd, refresh_ARG);
+
int update_partial_safe =
arg_count(cmd, deltag_ARG) ||
arg_count(cmd, addtag_ARG) ||
arg_count(cmd, metadataprofile_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) ||
@@ -608,18 +652,14 @@ int vgchange(struct cmd_context *cmd, int argc, char **argv)
arg_count(cmd, physicalextentsize_ARG) ||
arg_count(cmd, clustered_ARG) ||
arg_count(cmd, alloc_ARG) ||
- arg_count(cmd, vgmetadatacopies_ARG);
+ arg_count(cmd, vgmetadatacopies_ARG) ||
+ arg_count(cmd, systemid_ARG) ||
+ arg_count(cmd, systemidsource_ARG);
+
int update = update_partial_safe || update_partial_unsafe;
- if (!update &&
- !arg_count(cmd, activate_ARG) &&
- !arg_count(cmd, monitor_ARG) &&
- !arg_count(cmd, poll_ARG) &&
- !arg_count(cmd, refresh_ARG)) {
- log_error("Need 1 or more of -a, -c, -l, -p, -s, -x, "
- "--refresh, --uuid, --alloc, --addtag, --deltag, "
- "--monitor, --poll, --vgmetadatacopies or "
- "--metadatacopies");
+ if (!update && !noupdate) {
+ log_error("Need one or more command options.");
return EINVALID_CMD_LINE;
}
@@ -709,6 +749,9 @@ int vgchange(struct cmd_context *cmd, int argc, char **argv)
if (!update || !update_partial_unsafe)
cmd->handles_missing_pvs = 1;
+ if (arg_is_set(cmd, systemid_ARG) && arg_is_set(cmd, force_ARG))
+ cmd->access_vg_force = 1;
+
return process_each_vg(cmd, argc, argv, update ? READ_FOR_UPDATE : 0,
NULL, &vgchange_single);
}