summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorDavid Teigland <teigland@redhat.com>2023-02-09 17:14:19 -0600
committerDavid Teigland <teigland@redhat.com>2023-02-09 17:37:22 -0600
commitbe124ae81027e8736106e4958bd2dfab971d6764 (patch)
tree281729764d22b78a132d76e9ac669a8d2c0862f2 /test
parent94f77a4d8d9737fca05fb4e451678ec440c68670 (diff)
downloadlvm2-be124ae81027e8736106e4958bd2dfab971d6764.tar.gz
vgimportclone: fix non-duplicate PV with non-unique basevgname arg
Fix hang of vgimportclone command when: the PV(s) being imported are not actually clones/duplicates, and the -n vgname arg is the same as the current vgname. (Not the intended use of the command, but it should still work.) In this case, the old and new vgnames ended up being the same, when the code expected they would be different. A file lock on both the old and new vgnames is used, so when both flocks are on the same file, the second blocks indefinitely. Fix the new vgname to be the old name plus a numeric suffix, which is the expected result.
Diffstat (limited to 'test')
-rw-r--r--test/shell/vgimportclone.sh20
1 files changed, 20 insertions, 0 deletions
diff --git a/test/shell/vgimportclone.sh b/test/shell/vgimportclone.sh
index e1b9d3832..13924c3dd 100644
--- a/test/shell/vgimportclone.sh
+++ b/test/shell/vgimportclone.sh
@@ -104,6 +104,26 @@ pvremove "$dev1"
pvremove "$dev2"
pvremove "$dev3"
+# Test importing a non-duplicate pv using the existing vg name
+vgcreate $vg1 "$dev1"
+vgimportclone -n $vg1 "$dev1"
+vgs ${vg1}1
+not vgs $vg1
+vgremove ${vg1}1
+
+# Test importing a non-duplicate pv using the existing vg name
+# Another existing VG is using the initial generated vgname with
+# the "1" suffix, so "2" is used.
+vgcreate $vg1 "$dev1"
+vgcreate ${vg1}1 "$dev2"
+vgimportclone -n $vg1 "$dev1"
+vgs ${vg1}1
+vgs ${vg1}2
+vgremove ${vg1}1
+vgremove ${vg1}2
+pvremove "$dev1"
+pvremove "$dev2"
+
# Verify that if we provide the -n|--basevgname,
# the number suffix is not added unnecessarily.
vgcreate $SHARED --metadatasize 128k A${vg1}B "$dev1"