From 0ef8308f1b66728185fcb7d2d615dbdf2024c08f Mon Sep 17 00:00:00 2001 From: Milan Broz Date: Tue, 24 Mar 2009 13:16:34 +0000 Subject: [PATCH] Fix segfault for vgcfgrestore on VG with missing PVs. --- WHATS_NEW | 1 + lib/format_text/archiver.c | 6 ++++++ test/t-covercmd.sh | 7 ++++++- 3 files changed, 13 insertions(+), 1 deletion(-) diff --git a/WHATS_NEW b/WHATS_NEW index 36afb10dd..0f8922b06 100644 --- a/WHATS_NEW +++ b/WHATS_NEW @@ -1,5 +1,6 @@ Version 2.02.46 - ================================ + Fix segfault for vgcfgrestore on VG with missing PVs. Block SIGTERM & SIGINT in clvmd subthreads. Detect and conditionally wipe swapspace signatures in pvcreate. Fix maximal volume count check for snapshots if max_lv set for volume group. diff --git a/lib/format_text/archiver.c b/lib/format_text/archiver.c index a8fe3f0e0..521c46717 100644 --- a/lib/format_text/archiver.c +++ b/lib/format_text/archiver.c @@ -333,6 +333,12 @@ int backup_restore_from_file(struct cmd_context *cmd, const char *vg_name, if (!(vg = backup_read_vg(cmd, vg_name, file))) return_0; + /* + * If PV is missing, there is already message from read above + */ + if (vg_missing_pv_count(vg)) + return_0; + return backup_restore_vg(cmd, vg); } diff --git a/test/t-covercmd.sh b/test/t-covercmd.sh index 445c7d988..ed191bc7b 100755 --- a/test/t-covercmd.sh +++ b/test/t-covercmd.sh @@ -14,6 +14,8 @@ . ./test-utils.sh +TEST_UUID="aaaaaa-aaaa-aaaa-aaaa-aaaa-aaaa-aaaaaa" + get_lvs_() { case $(lvs --units s --nosuffix --noheadings -o $1_read_ahead "$vg"/"$lv") in @@ -28,7 +30,7 @@ pvcreate $dev1 pvcreate --metadatacopies 0 $dev2 pvcreate --metadatacopies 0 $dev3 pvcreate $dev4 -pvcreate --metadatacopies 0 $dev5 +pvcreate -u $TEST_UUID --metadatacopies 0 $dev5 vgcreate -c n $vg $devs lvcreate -n $lv -l 5 -i5 -I256 $vg @@ -67,6 +69,9 @@ lvrename "$vg" "$lv" "$lv-rename" vgcfgbackup -f "$(pwd)/backup.$$" "$vg" vgchange -an "$vg" vgcfgrestore -f "$(pwd)/backup.$$" "$vg" +pvremove -y -ff $dev5 +not vgcfgrestore -f "$(pwd)/backup.$$" "$vg" +pvcreate -u $TEST_UUID --restorefile "$(pwd)/backup.$$" $dev5 vgremove -f "$vg" pvresize --setphysicalvolumesize 10M "$dev1"