Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=24774959221ab750…
Commit: 24774959221ab75038c336074470108a0727e672
Parent: cccc2b2980f8321e5f8c8b553f50966f7e1b5abc
Author: David Teigland <teigland(a)redhat.com>
AuthorDate: Tue Mar 3 16:45:16 2015 -0600
Committer: David Teigland <teigland(a)redhat.com>
CommitterDate: Tue Mar 3 16:45:16 2015 -0600
lvchange, vgchange: fix the system_id check
The check for matching system_id needs to check
that the system_id is not blank.
---
tools/lvchange.c | 3 ++-
tools/vgchange.c | 3 ++-
2 files changed, 4 insertions(+), 2 deletions(-)
diff --git a/tools/lvchange.c b/tools/lvchange.c
index bf7e356..0351e4e 100644
--- a/tools/lvchange.c
+++ b/tools/lvchange.c
@@ -191,7 +191,8 @@ static int _lvchange_activate(struct cmd_context *cmd, struct logical_volume *lv
* a foreign VG, which allows the VG to be accessed by lvchange -a
* so the LV can be deactivated.
*/
- if (lv->vg->system_id && cmd->system_id &&
+ if (lv->vg->system_id && lv->vg->system_id[0] &&
+ cmd->system_id && cmd->system_id[0] &&
strcmp(lv->vg->system_id, cmd->system_id) &&
is_change_activating(activate)) {
log_error("Cannot activate LVs in a foreign VG.");
diff --git a/tools/vgchange.c b/tools/vgchange.c
index 38a129f..8371310 100644
--- a/tools/vgchange.c
+++ b/tools/vgchange.c
@@ -201,7 +201,8 @@ int vgchange_activate(struct cmd_context *cmd, struct volume_group *vg,
* a foreign VG, which allows the VG to be accessed by vgchange -a
* so the LV can be deactivated.
*/
- if (vg->system_id && cmd->system_id &&
+ if (vg->system_id && vg->system_id[0] &&
+ cmd->system_id && cmd->system_id[0] &&
strcmp(vg->system_id, cmd->system_id) &&
is_change_activating(activate)) {
log_error("Cannot activate LVs in a foreign VG.");
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=cccc2b2980f8321e…
Commit: cccc2b2980f8321e5f8c8b553f50966f7e1b5abc
Parent: 926b38c0d73d958e5774082ff17fb2a48e20d32e
Author: David Teigland <teigland(a)redhat.com>
AuthorDate: Tue Mar 3 13:23:13 2015 -0600
Committer: David Teigland <teigland(a)redhat.com>
CommitterDate: Tue Mar 3 13:23:13 2015 -0600
vgchange: deactivate LVs in foreign VG
Apply the same logic as lvchange, which allows
deactivating LVs in a foreign VG.
---
tools/vgchange.c | 15 +++++++++++++++
1 files changed, 15 insertions(+), 0 deletions(-)
diff --git a/tools/vgchange.c b/tools/vgchange.c
index 199ee82..38a129f 100644
--- a/tools/vgchange.c
+++ b/tools/vgchange.c
@@ -197,6 +197,18 @@ int vgchange_activate(struct cmd_context *cmd, struct volume_group *vg,
int do_activate = is_change_activating(activate);
/*
+ * We can get here in the odd case where an LV is already active in
+ * a foreign VG, which allows the VG to be accessed by vgchange -a
+ * so the LV can be deactivated.
+ */
+ if (vg->system_id && cmd->system_id &&
+ strcmp(vg->system_id, cmd->system_id) &&
+ is_change_activating(activate)) {
+ log_error("Cannot activate LVs in a foreign VG.");
+ return ECMD_FAILED;
+ }
+
+ /*
* Safe, since we never write out new metadata here. Required for
* partial activation to work.
*/
@@ -795,6 +807,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, activate_ARG))
+ cmd->include_active_foreign_vgs = 1;
+
return process_each_vg(cmd, argc, argv, update ? READ_FOR_UPDATE : 0,
NULL, &vgchange_single);
}
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=eeaf3f2e88ef2c66…
Commit: eeaf3f2e88ef2c664b5cbefb9c9a9e7ada0c752b
Parent: 047fe6c59fe2cf3a52208b219caebed469ed6bdc
Author: Peter Rajnoha <prajnoha(a)redhat.com>
AuthorDate: Mon Mar 2 12:16:55 2015 +0100
Committer: Peter Rajnoha <prajnoha(a)redhat.com>
CommitterDate: Mon Mar 2 12:17:27 2015 +0100
metadata: vg: add missing vg->lvm1_system_id initialization
The vg->lvm1_systemd_id needs to be initialized as all the code around
counts with that. Just like we initialize lvm1_system_id in vg_create
(no matter if it's actually LVM1 or LVM2 format), this patch adds this
init in alloc_vg as well so the rest of the code does not segfaul
when trying to access vg->lvm1_system_id.
---
lib/metadata/vg.c | 6 ++++++
1 files changed, 6 insertions(+), 0 deletions(-)
diff --git a/lib/metadata/vg.c b/lib/metadata/vg.c
index 446aa7c..2993655 100644
--- a/lib/metadata/vg.c
+++ b/lib/metadata/vg.c
@@ -57,6 +57,12 @@ struct volume_group *alloc_vg(const char *pool_name, struct cmd_context *cmd,
dm_list_init(&vg->tags);
dm_list_init(&vg->removed_pvs);
+ if (!(vg->lvm1_system_id = dm_pool_zalloc(vg->vgmem, NAME_LEN + 1))) {
+ log_error("Failed to allocate VG systemd id.");
+ dm_pool_destroy(vgmem);
+ return NULL;
+ }
+
log_debug_mem("Allocated VG %s at %p.", vg->name, vg);
return vg;