fix vgcfgrestore segfault if PV is missing
PATCH 1/1 fix vgcfgrestore segfault if PV is missing
Fix segfault for vgcfgrestore on VG with missing PVs.
Caused by introducing MISSING_PV flag, previouslyvg_read failed here.
--- lib/format_text/archiver.c | 6 ++++++ test/t-covercmd.sh | 7 ++++++- 2 files changed, 12 insertions(+), 1 deletions(-)
lib/format_text/archiver.c +6 -0
@@ -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); }
test/t-covercmd.sh +6 -1
@@ -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"
PATCH 1/1 fix vgcfgrestore segfault if PV is missing
Quoted 1 line · Milan Broz
Caused by introducing
MISSING_PVflag, previouslyvg_readfailed here.
With my recent patches, vg_read fails here again for tools that don't set handles_missing_pvs (this fixes more segfaults of this kind, although ultimately, this is not the right fix, merely a workaround... making the code aware of MISSING_PV sounds like a better approach overall).
Quoted 40 lines
lib/format_text/archiver.c +6
-0@@ -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); }test/t-covercmd.sh +3
-1@@ -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
test/t-covercmd.sh lvrename "$vg" "$lv" "$lv-rename" · line 76
Quoted 8 lines
test/t-covercmd.sh +3
-0@@ -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"
The patch does what the advert says. It also comes with a test update. Therefore,
Signature · 6 lines
Peter Rockai | me()mornfall!net | prockai()redhat!com
http://blog.mornfall.net | http://web.mornfall.net
"In My Egotistical Opinion, most people's C programs should be
indented six feet downward and covered with dirt."
-- Blair P. Houghton on the subject of C program indentationPATCH 1/1 fix vgcfgrestore segfault if PV is missing
In reply to Milan BrozQuoted 1 line · Milan Broz
Fix segfault for vgcfgrestore on VG with missing PVs.
Ack.
lib/format_text/archiver.c int backup_restore_from_file(struct cmd_context *cmd, const char *vg_name, · line 340
Quoted 2 lines
lib/format_text/archiver.c +2
-0+if (vg_missing_pv_count (vg)) +return 0 ;
return_0
Alasdair
Signature · 1 line
agk at redhat.com