summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlasdair G Kergon <agk@redhat.com>2015-03-09 19:03:11 +0000
committerAlasdair G Kergon <agk@redhat.com>2015-03-09 19:03:11 +0000
commit458b0210d1b4195171992f112aeb3a798d4509a3 (patch)
tree8e14592cba0b21648794cd54fa104bf89c1bf82e
parent1334ea214ea1f55173f2ff7e3045cc72a8c4e7c7 (diff)
downloadlvm2-458b0210d1b4195171992f112aeb3a798d4509a3.tar.gz
vgchange: Additional system ID warnings.
Also prompt before setting a system ID on a VG when none is set on the host. Put quotes round system ID in messages where it could be blank.
-rw-r--r--tools/vgchange.c57
1 files changed, 30 insertions, 27 deletions
diff --git a/tools/vgchange.c b/tools/vgchange.c
index 36b44a9ad..88a85d86e 100644
--- a/tools/vgchange.c
+++ b/tools/vgchange.c
@@ -536,42 +536,45 @@ static int _vgchange_system_id(struct cmd_context *cmd, struct volume_group *vg)
}
if (!strcmp(vg->system_id, system_id)) {
- log_error("Volume Group system ID is already %s", vg->system_id);
+ log_error("Volume Group system ID is already \"%s\".", vg->system_id);
return 0;
}
- if (cmd->system_id && strcmp(system_id, cmd->system_id)) {
- if (!*system_id) {
- log_warn("WARNING: Removing the system ID allows unsafe access from other hosts.");
+ if (!*system_id && cmd->system_id && strcmp(system_id, cmd->system_id)) {
+ log_warn("WARNING: Removing the system ID allows unsafe access from other hosts.");
- if (!arg_count(cmd, yes_ARG) &&
- yes_no_prompt("Remove system ID %s on volume group %s? [y/n]: ",
- vg->system_id, vg->name) == 'n') {
- log_error("Volume group %s system ID not changed.", vg->name);
- return 0;
- }
- } else {
- if (lvs_in_vg_activated(vg)) {
- log_error("Logical Volumes in VG %s must be deactivated before system ID can be changed.",
- vg->name);
- return 0;
- }
+ if (!arg_count(cmd, yes_ARG) &&
+ yes_no_prompt("Remove system ID %s from volume group %s? [y/n]: ",
+ vg->system_id, vg->name) == 'n') {
+ log_error("System ID of volume group %s not changed.", vg->name);
+ return 0;
+ }
+ }
- log_warn("WARNING: Requested system ID %s does not match local system ID %s",
- system_id, cmd->system_id);
- log_warn("WARNING: Volume group %s might become inaccessible from this machine.",
- vg->name);
+ if (*system_id && (!cmd->system_id || strcmp(system_id, cmd->system_id))) {
+ if (lvs_in_vg_activated(vg)) {
+ log_error("Logical Volumes in VG %s must be deactivated before system ID can be changed.",
+ vg->name);
+ return 0;
+ }
- if (!arg_count(cmd, yes_ARG) &&
- yes_no_prompt("Set foreign system ID %s on volume group %s? [y/n]: ",
- system_id, vg->name) == 'n') {
- log_error("Volume group %s system ID not changed.", vg->name);
- return 0;
- }
+ if (cmd->system_id)
+ log_warn("WARNING: Requested system ID %s does not match local system ID %s.",
+ system_id, cmd->system_id ? : "");
+ else
+ log_warn("WARNING: No local system ID is set.");
+ log_warn("WARNING: Volume group %s might become inaccessible from this machine.",
+ vg->name);
+
+ if (!arg_count(cmd, yes_ARG) &&
+ yes_no_prompt("Set foreign system ID %s on volume group %s? [y/n]: ",
+ system_id, vg->name) == 'n') {
+ log_error("Volume group %s system ID not changed.", vg->name);
+ return 0;
}
}
- log_verbose("Changing system ID for VG %s from %s to %s.",
+ log_verbose("Changing system ID for VG %s from \"%s\" to \"%s\".",
vg->name, vg->system_id, system_id);
vg->system_id = system_id;