lvm2/0022-tests-update-for-work-in-fake-dev-environment.patch
heming zhao bde51e3862 Accepting request 1112038 from home:gsu
- Update lvm2 from LVM2.2.03.16 to LVM2.2.03.22 (jsc#PED-6339)
  *** WHATS_NEW from 2.03.17 to 2.03.22 ***
  
  version 2.03.22 - 02nd August 2023
  ==================================
    Fix pv_major/pv_minor report field types so they are integers, not strings.
    Add lvmdevices --delnotfound to delete entries for missing devices.
    Always use cachepool name for metadata backup LV for lvconvert --repair.
    Make metadata backup LVs read-only after pool's lvconvert --repair.
    Improve VDO and Thin support with lvmlockd.
    Handle 'lvextend --usepolicies' for pools for all activation variants.
    Fix memleak in vgchange autoactivation setup.
    Update py-compile building script.
    Support conversion from thick to fully provisioned thin LV.
    Cache/Thin-pool can use error and zero volumes for testing.
    Individual thin volume can be cached, but cannot take snapshot.
    Better internal support for handling error and zero target (for testing).
    Resize COW above trimmed maximal size is does not return error.
    Support parsing of vdo geometry format version 4.
    Add lvm.conf thin_restore and cache_restore settings.
    Handle multiple mounts while resizing volume with a FS.
    Handle leading/trailing spaces in sys_wwid and sys_serial used by deivce_id.
    Enhance lvm_import_vdo and use snapshot when converting VDO volume.
    Fix parsing of VDO metadata.
    Fix failing -S|--select for non-reporting cmds if using LV info/status fields.
    Allow snapshots of raid+integrity LV.
    Fix multisegment RAID1 allocator to prevent using single disk for more legs.
  version 2.03.21 - 21st April 2023
  =================================
    Fix activation of vdo-pool for with 0 length headers (converted pools).
    Avoid printing internal init messages when creation integration devices.
    Allow (write)cache over raid+integrity LV.
  version 2.03.20 - 21st March 2023
  =================================
    Fix segfault if using -S|--select with log/report_command_log=1 setting.
    Configure now fails when requested lvmlockd dependencies are missing.
    Add some configure Gentoo enhancements for static builds.
  version 2.03.19 - 21st February 2023
  ====================================
    Configure supports --with-systemd-run executed from udev rules.
    Enhancement for build with MuslC systemd and non-bash system shells (dash).
    Do not reset SYSTEMD_READY variable in udev for PVs on MD and loop devices.
    Ensure udev is processing origin LV before its thick snapshots LVs.
    Fix and improve runtime memory size detection for VDO volumes.
  version 2.03.18 - 22nd December 2022
  ====================================
    Fix issues reported by coverity scan.
    Fix warning for thin pool overprovisioning on lvextend (2.03.17).
    Add support for writecache metadata_only and pause_writeback settings.
    Fix missing error messages in lvmdbusd.
  Version 2.03.17 - 10th November 2022
  ====================================
    Add new options (--fs, --fsmode) for FS handling when resizing LVs.
    Fix 'lvremove -S|--select LV' to not also remove its historical LV right away.
    Fix lv_active field type to binary so --select and --binary applies properly.
    Switch to use mallinfo2 and use it only with glibc.
    Error out in lvm shell if using a cmd argument not supported in the shell.
    Fix lvm shell's lastlog command to report previous pre-command failures.
    Extend VDO and VDOPOOL without flushing and locking fs.
    Add --valuesonly option to lvmconfig to print only values without keys.
    Updates configure with recent autoconf tooling.
    Fix lvconvert --test --type vdo-pool execution.
    Add json_std output format for more JSON standard compliant version of output.
    Fix vdo_slab_size_mb value for converted VDO volume.
    Fix many corner cases in device_id, including handling of S/N duplicates.
    Fix various issues in lvmdbusd.
- Drop patches that have been merged into upstream
  - 0001-devices-file-move-clean-up-after-command-is-run.patch
  - 0002-devices-file-fail-if-devicesfile-filename-doesn-t-ex.patch
  - 0003-filter-mpath-handle-other-wwid-types-in-blacklist.patch
  - 0004-filter-mpath-get-wwids-from-sysfs-vpd_pg83.patch
  - 0005-pvdisplay-restore-reportformat-option.patch
  - 0006-exit-with-error-when-devicesfile-name-doesn-t-exist.patch
  - 0007-report-fix-pe_start-column-type-from-NUM-to-SIZ.patch
  - 0008-_vg_read_raw_area-fix-segfault-caused-by-using-null-.patch
  - 0009-mm-remove-libaio-from-being-skipped.patch
  - 0010-dmsetup-check-also-for-ouf-of-range-value.patch
  - 0011-devices-drop-double-from-sysfs-path.patch
  - 0012-devices-file-fix-pvcreate-uuid-matching-pvid-entry-w.patch
  - 0013-vgimportdevices-change-result-when-devices-are-not-a.patch
  - 0014-vgimportdevices-fix-locking-when-creating-devices-fi.patch
  - bug-1203216_lvmlockd-purge-the-lock-resources-left-in-previous-l.patch
  - bug-1212613_apply-multipath_component_detection-0-to-duplicate-P.patch
- Add upstream patch
  + 0001-lvconvert-swapmetadata-fix-lvmlockd-locking.patch
  + 0002-lvconvert-fix-ret-values-fro-integrity-remove.patch
  + 0003-lvconvert-fix-regresion-from-integrity-check.patch
  + 0004-gcc-cleanup-warnings.patch
  + 0005-lvmlockd-fix-thick-to-thin-lv-conversion.patch
  + 0006-lvmlockd-let-lockd_init_lv_args-set-lock_args.patch
  + 0007-lvmlockd-fix-lvconvert-to-thin-pool.patch
  + 0008-lvconvert-run-error-path-code-only-for-shared-VG.patch
  + 0009-vgchange-acquire-an-exclusive-VG-lock-for-refresh.patch
  + 0010-lvmlockd-client-mutex-ordering.patch
  + 0011-filesystem-move-stat-after-open-check.patch
  + 0012-tests-check-for-writecache.patch
  + 0013-lvresize-fix-32-bit-overflow-in-size-calculation.patch
  + 0014-gcc-fix-warnings-for-x32-architecture.patch
  + 0015-gcc-warning-missing-braces-around-initializer.patch
  + 0016-test-improve-aux-teardown.patch
  + 0017-tests-aux-try-with-extra-sleep.patch
  + 0018-tests-aux-using-singl-lvmconf-call.patch
  + 0019-tests-missing-to-check-for-writecache-support.patch
  + 0020-tests-pvmove-large-disk-area.patch
  + 0021-tests-enforce-full-fs-check.patch
  + 0022-tests-update-for-work-in-fake-dev-environment.patch
  + 0023-tests-skip-test-when-lvmdbusd-runs-on-the-system.patch
  + 0024-tests-better-slowdown.patch
- Update patch
  - bug-1037309_Makefile-skip-compliling-daemons-lvmlockd-directory.patch
  - bug-1184124-link-tests-as-PIE.patch
  - bug-1184687_Add-nolvm-for-kernel-cmdline.patch
  - fate-31841-03_tests-new-test-suite-of-fsadm-for-btrfs.patch
  
- Rename & Update patch
  - bug-1012973_simplify-special-case-for-md-in-69-dm-lvm-metadata.patch
  + bug-1012973_simplify-special-case-for-md-in-69-dm-lvm-rules.patch
  
- update lvm2.spec
  - change upstream_device_mapper_version to 1.02.196
  - change device_mapper_version to %{lvm2_version}_1.02.196
  - add config item "-with-libexecdir=%{_libexecdir}" to fix libexec path since commit a2d33cdf
  - add new binary "%{_libexecdir}/lvresize_fs_helper" to lvm2 package

OBS-URL: https://build.opensuse.org/request/show/1112038
OBS-URL: https://build.opensuse.org/package/show/Base:System/lvm2?expand=0&rev=332
2023-09-19 00:36:45 +00:00

589 lines
18 KiB
Diff

From 9683478371c60e78920c22cb4f5ca14b39bb9fcb Mon Sep 17 00:00:00 2001
From: Zdenek Kabelac <zkabelac@redhat.com>
Date: Thu, 14 Sep 2023 00:51:58 +0200
Subject: [PATCH 22/24] tests: update for work in fake dev environment
No write outside of $LVM_TEST_DIR (removed /test access).
Use 'aux prepare_scsi_debug_dev' for automated scsi_debug handling
Properly use "" around shell vars.
Smarter read of PVS values.
Relax requirement to only work with real /dev dir.
---
test/shell/devicesfile-vpd-ids.sh | 328 +++++++++++++++---------------
1 file changed, 164 insertions(+), 164 deletions(-)
diff --git a/test/shell/devicesfile-vpd-ids.sh b/test/shell/devicesfile-vpd-ids.sh
index 9a12f49f9..37fb6b79f 100644
--- a/test/shell/devicesfile-vpd-ids.sh
+++ b/test/shell/devicesfile-vpd-ids.sh
@@ -16,12 +16,10 @@ SKIP_WITH_LVMPOLLD=1
. lib/inittest
-test "$DM_DEV_DIR" = "/dev" || skip "Only works with /dev access -> make check LVM_TEST_DEVDIR=/dev"
-
-aux lvmconf 'devices/use_devicesfile = 1'
+SYS_DIR="sys"
# requires trailing / to match dm
-aux lvmconf 'devices/device_id_sysfs_dir = "/test/sys/"'
-SYS_DIR="/test/sys"
+aux lvmconf "devices/device_id_sysfs_dir = \"$PWD/$SYS_DIR/\"" \
+ "devices/use_devicesfile = 1"
# These values match the values encoded in the binary blob
# written to dev1_vpd_pg83
@@ -34,7 +32,7 @@ DEV1_NAA2=naa.600a098000000002ac18542400000dbd
DEV1_NAA3=naa.553b13644430344b4e3f486d32647962
create_base() {
- mkdir -p $SYS_DIR/dev/block
+ mkdir -p "$SYS_DIR/dev/block"
echo -n "0083 009c 0201 0020 4c56 4d54 5354 2020 \
204c 554e 2038 3039 7741 4c56 4d54 5354 \
@@ -45,39 +43,36 @@ create_base() {
0000 0dbd 0114 0004 0101 0005 0115 0004 \
0000 03ec 0328 0028 6e61 612e 3535 3342 \
3133 3634 3434 3330 3334 3442 3445 3346 \
- 3438 3644 3332 3634 3739 3632 0000 0000" | xxd -r -p > $SYS_DIR/dev1_vpd_pg83
+ 3438 3644 3332 3634 3739 3632 0000 0000" | xxd -r -p > "$SYS_DIR/dev1_vpd_pg83"
}
remove_base() {
- rm $SYS_DIR/dev1_vpd_pg83
- rmdir $SYS_DIR/dev/block
- rmdir $SYS_DIR/dev
- rmdir $SYS_DIR
+ rm "$SYS_DIR/dev1_vpd_pg83"
+ rmdir "$SYS_DIR/dev/block"
+ rmdir "$SYS_DIR/dev"
+ rmdir "$SYS_DIR"
}
setup_sysfs() {
- mkdir -p $SYS_DIR/dev/block/$MAJOR1:$MINOR1/device
- echo $1 > $SYS_DIR/dev/block/$MAJOR1:$MINOR1/device/wwid
- cp $SYS_DIR/dev1_vpd_pg83 $SYS_DIR/dev/block/$MAJOR1:$MINOR1/device/vpd_pg83
+ mkdir -p "$SYS_DIR/dev/block/$MAJOR1:$MINOR1/device"
+ echo "$1" > "$SYS_DIR/dev/block/$MAJOR1:$MINOR1/device/wwid"
+ cp "$SYS_DIR/dev1_vpd_pg83" "$SYS_DIR/dev/block/$MAJOR1:$MINOR1/device/vpd_pg83"
}
cleanup_sysfs() {
- rm -f $SYS_DIR/dev/block/$MAJOR1:$MINOR1/device/wwid
- rm -f $SYS_DIR/dev/block/$MAJOR1:$MINOR1/device/vpd_pg83
- rmdir $SYS_DIR/dev/block/$MAJOR1:$MINOR1/device || true
- rmdir $SYS_DIR/dev/block/$MAJOR1:$MINOR1 || true
+ rm -f "$SYS_DIR/dev/block/$MAJOR1:$MINOR1/device/wwid"
+ rm -f "$SYS_DIR/dev/block/$MAJOR1:$MINOR1/device/vpd_pg83"
+ rmdir "$SYS_DIR/dev/block/$MAJOR1:$MINOR1/device" || true
+ rmdir "$SYS_DIR/dev/block/$MAJOR1:$MINOR1" || true
}
+aux prepare_scsi_debug_dev 16 || skip
-modprobe scsi_debug dev_size_mb=16 num_tgts=1
-sleep 2
# Get scsi device name created by scsi_debug.
# SD = sdh
# DEV1 = /dev/sdh
-SD=$(grep -H scsi_debug /sys/block/sd*/device/model | cut -f4 -d /);
-echo $SD
-DEV1=/dev/$SD
-echo $DEV1
+DEV1=$(< SCSI_DEBUG_DEV)
+echo "Using scsi_debug device: $DEV1"
DFDIR="$LVM_SYSTEM_DIR/devices"
mkdir -p "$DFDIR" || true
@@ -87,22 +82,23 @@ touch $DF
pvcreate "$DEV1"
vgcreate $vg "$DEV1"
-MAJOR1=`pvs "$DEV1" --noheading -o major | tr -d - | awk '{print $1}'`
-MINOR1=`pvs "$DEV1" --noheading -o minor | tr -d - | awk '{print $1}'`
-PVID1=`pvs "$DEV1" --noheading -o uuid | tr -d - | awk '{print $1}'`
+eval "$(pvs --noheading --nameprefixes -o major,minor,uuid "$DEV1")"
+MAJOR1=$LVM2_PV_MAJOR
+MINOR1=$LVM2_PV_MINOR
+PVID1=${LVM2_PV_UUID//-/}
create_base
# No sys/wwid, lvm uses wwid from sys/vpd
-setup_sysfs $DEV1_NAA
+setup_sysfs "$DEV1_NAA"
# no sys/wwid is reported
-rm $SYS_DIR/dev/block/$MAJOR1:$MINOR1/device/wwid
-rm $DF
+rm "$SYS_DIR/dev/block/$MAJOR1:$MINOR1/device/wwid"
+rm "$DF"
lvmdevices --adddev "$DEV1"
-cat $DF
+cat "$DF"
pvs "$DEV1"
-grep $DEV1_NAA $DF
+grep "$DEV1_NAA" "$DF"
cleanup_sysfs
# Kernel changes the type printed from sys/wwid from t10 to naa
@@ -113,15 +109,15 @@ cleanup_sysfs
# reporting pvs should still find the dev based on using vpd data
# and find the t10 value there
-setup_sysfs $DEV1_T10
-rm $DF
+setup_sysfs "$DEV1_T10"
+rm "$DF"
lvmdevices --adddev "$DEV1"
-cat $DF
-grep sys_wwid $DF
-grep $DEV1_T10 $DF
+cat "$DF"
+grep sys_wwid "$DF"
+grep "$DEV1_T10" "$DF"
pvs "$DEV1"
# kernel changes what it reports from sys/wwid
-echo $DEV1_NAA > $SYS_DIR/dev/block/$MAJOR1:$MINOR1/device/wwid
+echo "$DEV1_NAA" > "$SYS_DIR/dev/block/$MAJOR1:$MINOR1/device/wwid"
# lvm finds the original t10 id in vpd
pvs "$DEV1"
cleanup_sysfs
@@ -132,229 +128,231 @@ cleanup_sysfs
# df entry uses the specified type
# reporting pvs should show the pv
-setup_sysfs $DEV1_T10
-rm $DF
+setup_sysfs "$DEV1_T10"
+rm "$DF"
lvmdevices --adddev "$DEV1" --deviceidtype wwid_naa
-cat $DF
-grep wwid_naa $DF
-grep $DEV1_NAA $DF
+cat "$DF"
+grep wwid_naa "$DF"
+grep "$DEV1_NAA" "$DF"
pvs "$DEV1"
lvmdevices --deldev "$DEV1"
lvmdevices --addpvid "$PVID1" --deviceidtype wwid_naa
-cat $DF
-grep $DEV1_NAA $DF
+cat "$DF"
+grep "$DEV1_NAA" "$DF"
pvs "$DEV1"
lvmdevices --deldev "$DEV1"
lvmdevices --adddev "$DEV1" --deviceidtype wwid_eui
-cat $DF
-grep wwid_eui $DF
-grep $DEV1_EUI $DF
+cat "$DF"
+grep wwid_eui "$DF"
+grep "$DEV1_EUI" "$DF"
pvs "$DEV1"
cleanup_sysfs
-# Any of the vpd wwids can be used in the devices file
+# Any of the vpd wwids can be used in the devices file
# with type sys_wwid and the device will be matched to
# it by finding that wwid in the vpd data.
-setup_sysfs $DEV1_NAA
-rm $DF
+setup_sysfs "$DEV1_NAA"
+rm "$DF"
lvmdevices --adddev "$DEV1"
-cat $DF
-rm $SYS_DIR/dev/block/$MAJOR1:$MINOR1/device/wwid
+cat "$DF"
+rm "$SYS_DIR/dev/block/$MAJOR1:$MINOR1/device/wwid"
pvs "$DEV1"
cleanup_sysfs
-setup_sysfs $DEV1_NAA2
-rm $DF
+setup_sysfs "$DEV1_NAA2"
+rm "$DF"
lvmdevices --adddev "$DEV1"
-cat $DF
-rm $SYS_DIR/dev/block/$MAJOR1:$MINOR1/device/wwid
+cat "$DF"
+rm "$SYS_DIR/dev/block/$MAJOR1:$MINOR1/device/wwid"
pvs "$DEV1"
cleanup_sysfs
-setup_sysfs $DEV1_NAA3
-rm $DF
+setup_sysfs "$DEV1_NAA3"
+rm "$DF"
lvmdevices --adddev "$DEV1"
-cat $DF
-rm $SYS_DIR/dev/block/$MAJOR1:$MINOR1/device/wwid
+cat "$DF"
+rm "$SYS_DIR/dev/block/$MAJOR1:$MINOR1/device/wwid"
pvs "$DEV1"
cleanup_sysfs
-setup_sysfs $DEV1_EUI
-rm $DF
+setup_sysfs "$DEV1_EUI"
+rm "$DF"
lvmdevices --adddev "$DEV1"
-cat $DF
-rm $SYS_DIR/dev/block/$MAJOR1:$MINOR1/device/wwid
+cat "$DF"
+rm "$SYS_DIR/dev/block/$MAJOR1:$MINOR1/device/wwid"
pvs "$DEV1"
cleanup_sysfs
-setup_sysfs $DEV1_T10
-rm $DF
+setup_sysfs "$DEV1_T10"
+rm "$DF"
lvmdevices --adddev "$DEV1"
-cat $DF
-rm $SYS_DIR/dev/block/$MAJOR1:$MINOR1/device/wwid
+cat "$DF"
+rm "$SYS_DIR/dev/block/$MAJOR1:$MINOR1/device/wwid"
pvs "$DEV1"
cleanup_sysfs
# Test nvme wwid that starts with "nvme" instead of naa/eui/t10
-rm $DF
+rm "$DF"
aux wipefs_a "$DEV1"
-mkdir -p $SYS_DIR/dev/block/$MAJOR1:$MINOR1/
-echo "nvme.111111111111111111122222222222333333333333333-44444444444444444445555555555556666666666666666662-00000001" > $SYS_DIR/dev/block/$MAJOR1:$MINOR1/wwid
+mkdir -p "$SYS_DIR/dev/block/$MAJOR1:$MINOR1"
+echo "nvme.111111111111111111122222222222333333333333333-44444444444444444445555555555556666666666666666662-00000001" > "$SYS_DIR/dev/block/$MAJOR1:$MINOR1/wwid"
lvmdevices --adddev "$DEV1"
-cat $DF
+cat "$DF"
vgcreate $vg "$DEV1"
lvcreate -l1 -an $vg
-cat $DF
+cat "$DF"
pvs -o+deviceidtype,deviceid "$DEV1" |tee out
grep sys_wwid out
grep nvme.111 out
-grep sys_wwid $DF
-grep nvme.111 $DF
+grep sys_wwid "$DF"
+grep nvme.111 "$DF"
lvmdevices --deldev "$DEV1"
not lvmdevices --adddev "$DEV1" --deviceidtype wwid_eui
lvmdevices --adddev "$DEV1" --deviceidtype sys_wwid
lvmdevices | grep nvme.111
lvremove -y $vg
-sleep 1
+sleep .1
lvs $vg
vgremove $vg
-rm $SYS_DIR/dev/block/$MAJOR1:$MINOR1/wwid
+rm "$SYS_DIR/dev/block/$MAJOR1:$MINOR1/wwid"
cleanup_sysfs
# Test t10 wwid containing quote
-rm $DF
+rm "$DF"
aux wipefs_a "$DEV1"
-mkdir -p $SYS_DIR/dev/block/$MAJOR1:$MINOR1/device
-echo "t10.ATA_2.5\"_SATA_SSD_1112-A___111111111111" > $SYS_DIR/dev/block/$MAJOR1:$MINOR1/device/wwid
+mkdir -p "$SYS_DIR/dev/block/$MAJOR1:$MINOR1/device"
+echo "t10.ATA_2.5\"_SATA_SSD_1112-A___111111111111" > "$SYS_DIR/dev/block/$MAJOR1:$MINOR1/device/wwid"
lvmdevices --adddev "$DEV1"
-cat $DF
+cat "$DF"
vgcreate $vg "$DEV1"
lvcreate -l1 -an $vg
-cat $DF
+cat "$DF"
# check wwid string in metadata output
pvs -o+deviceidtype,deviceid "$DEV1" |tee out
grep sys_wwid out
# the quote is removed after the 5
grep 2.5_SATA_SSD out
# check wwid string in system.devices
-grep sys_wwid $DF
+grep sys_wwid "$DF"
# the quote is removed after the 5
-grep 2.5_SATA_SSD $DF
+grep 2.5_SATA_SSD "$DF"
lvremove -y $vg
vgremove $vg
-rm $SYS_DIR/dev/block/$MAJOR1:$MINOR1/device/wwid
+rm "$SYS_DIR/dev/block/$MAJOR1:$MINOR1/device/wwid"
cleanup_sysfs
# Test t10 wwid with trailing space and line feed at the end
-rm $DF
+rm "$DF"
aux wipefs_a "$DEV1"
-mkdir -p $SYS_DIR/dev/block/$MAJOR1:$MINOR1/device
+mkdir -p "$SYS_DIR/dev/block/$MAJOR1:$MINOR1/device"
echo -n "7431 302e 4154 4120 2020 2020 5642 4f58 \
2048 4152 4444 4953 4b20 2020 2020 2020 \
2020 2020 2020 2020 2020 2020 2020 2020 \
2020 2020 5642 3963 3130 6433 3138 2d31 \
-3838 6439 6562 6320 0a" | xxd -r -p > $SYS_DIR/dev/block/$MAJOR1:$MINOR1/device/wwid
-cat $SYS_DIR/dev/block/$MAJOR1:$MINOR1/device/wwid
+3838 6439 6562 6320 0a" | xxd -r -p > "$SYS_DIR/dev/block/$MAJOR1:$MINOR1/device/wwid"
+cat "$SYS_DIR/dev/block/$MAJOR1:$MINOR1/device/wwid"
lvmdevices --adddev "$DEV1"
-cat $DF
+cat "$DF"
vgcreate $vg "$DEV1"
lvcreate -l1 -an $vg
-cat $DF
+cat "$DF"
# check wwid string in metadata output
pvs -o+deviceidtype,deviceid "$DEV1" |tee out
grep sys_wwid out
# check wwid string in system.devices
-grep sys_wwid $DF
+grep sys_wwid "$DF"
lvremove -y $vg
vgremove $vg
-rm $SYS_DIR/dev/block/$MAJOR1:$MINOR1/device/wwid
+rm "$SYS_DIR/dev/block/$MAJOR1:$MINOR1/device/wwid"
cleanup_sysfs
# Test t10 wwid with trailing space at the end that was created by 9.0/9.1
-rm $DF
+rm "$DF"
aux wipefs_a "$DEV1"
-mkdir -p $SYS_DIR/dev/block/$MAJOR1:$MINOR1/device
+mkdir -p "$SYS_DIR/dev/block/$MAJOR1:$MINOR1/device"
echo -n "7431 302e 4154 4120 2020 2020 5642 4f58 \
2048 4152 4444 4953 4b20 2020 2020 2020 \
2020 2020 2020 2020 2020 2020 2020 2020 \
2020 2020 5642 3963 3130 6433 3138 2d31 \
-3838 6439 6562 6320 0a" | xxd -r -p > $SYS_DIR/dev/block/$MAJOR1:$MINOR1/device/wwid
-cat $SYS_DIR/dev/block/$MAJOR1:$MINOR1/device/wwid
+3838 6439 6562 6320 0a" | xxd -r -p > "$SYS_DIR/dev/block/$MAJOR1:$MINOR1/device/wwid"
+cat "$SYS_DIR/dev/block/$MAJOR1:$MINOR1/device/wwid"
lvmdevices --adddev "$DEV1"
-cat $DF
+cat "$DF"
vgcreate $vg "$DEV1"
-PVID1=`pvs "$DEV1" --noheading -o uuid | tr -d - | awk '{print $1}'`
+eval "$(pvs --noheading --nameprefixes -o uuid "$DEV1")"
+PVID1=${LVM2_PV_UUID//-/}
T10_WWID_RHEL91="t10.ATA_____VBOX_HARDDISK___________________________VB9c10d318-188d9ebc_"
lvcreate -l1 -an $vg
-cat $DF
+cat "$DF"
# check wwid string in metadata output
pvs -o+deviceidtype,deviceid "$DEV1" |tee out
grep sys_wwid out
# check wwid string in system.devices
-grep sys_wwid $DF
+grep sys_wwid "$DF"
# Replace IDNAME with the IDNAME that 9.0/9.1 created from this wwid
-cat $DF | grep -v IDNAME > $DFTMP
-cat $DFTMP
-echo "IDTYPE=sys_wwid IDNAME=t10.ATA_____VBOX_HARDDISK___________________________VB9c10d318-188d9ebc_ DEVNAME=${DEV1} PVID=${PVID1}" >> $DFTMP
-cp $DFTMP $DF
-cat $DF
+cat "$DF" | grep -v IDNAME > "$DFTMP"
+cat "$DFTMP"
+echo "IDTYPE=sys_wwid IDNAME=t10.ATA_____VBOX_HARDDISK___________________________VB9c10d318-188d9ebc_ DEVNAME=${DEV1} PVID=${PVID1}" >> "$DFTMP"
+cp "$DFTMP" "$DF"
+cat "$DF"
vgs
pvs
pvs -o+deviceidtype,deviceid "$DEV1"
# Removing the trailing _ which should then work
-cat $DF | grep -v IDNAME > $DFTMP
-cat $DFTMP
-echo "IDTYPE=sys_wwid IDNAME=t10.ATA_____VBOX_HARDDISK___________________________VB9c10d318-188d9ebc DEVNAME=${DEV1} PVID=${PVID1}" >> $DFTMP
-cp $DFTMP $DF
-cat $DF
+cat "$DF" | grep -v IDNAME > "$DFTMP"
+cat "$DFTMP"
+echo "IDTYPE=sys_wwid IDNAME=t10.ATA_____VBOX_HARDDISK___________________________VB9c10d318-188d9ebc DEVNAME=${DEV1} PVID=${PVID1}" >> "$DFTMP"
+cp "$DFTMP" "$DF"
+cat "$DF"
vgs
pvs
pvs -o+deviceidtype,deviceid "$DEV1"
lvremove -y $vg
vgremove $vg
-rm $SYS_DIR/dev/block/$MAJOR1:$MINOR1/device/wwid
+rm "$SYS_DIR/dev/block/$MAJOR1:$MINOR1/device/wwid"
cleanup_sysfs
# test a t10 wwid that has actual trailing underscore which
# is followed by a trailing space.
-rm $DF
+rm "$DF"
aux wipefs_a "$DEV1"
-mkdir -p $SYS_DIR/dev/block/$MAJOR1:$MINOR1/device
+mkdir -p "$SYS_DIR/dev/block/$MAJOR1:$MINOR1/device"
echo -n "7431 302e 4154 4120 2020 2020 5642 4f58 \
2048 4152 4444 4953 4b20 2020 2020 2020 \
2020 2020 2020 2020 2020 2020 2020 2020 \
2020 2020 5642 3963 3130 6433 3138 2d31 \
-3838 6439 6562 5f20 0a" | xxd -r -p > $SYS_DIR/dev/block/$MAJOR1:$MINOR1/device/wwid
-cat $SYS_DIR/dev/block/$MAJOR1:$MINOR1/device/wwid
+3838 6439 6562 5f20 0a" | xxd -r -p > "$SYS_DIR/dev/block/$MAJOR1:$MINOR1/device/wwid"
+cat "$SYS_DIR/dev/block/$MAJOR1:$MINOR1/device/wwid"
# The wwid has an actual underscore char (5f) followed by a space char (20)
# 9.1 converts the trailing space to an underscore
T10_WWID_RHEL91="t10.ATA_____VBOX_HARDDISK___________________________VB9c10d318-188d9eb__"
# 9.2 ignores the trailing space
T10_WWID_RHEL92="t10.ATA_____VBOX_HARDDISK___________________________VB9c10d318-188d9eb_"
lvmdevices --adddev "$DEV1"
-cat $DF
+cat "$DF"
vgcreate $vg "$DEV1"
-PVID1=`pvs "$DEV1" --noheading -o uuid | tr -d - | awk '{print $1}'`
+eval "$(pvs --noheading --nameprefixes -o uuid "$DEV1")"
+PVID1=${LVM2_PV_UUID//-/}
lvcreate -l1 -an $vg
-cat $DF
+cat "$DF"
# check wwid string in metadata output
pvs -o+deviceidtype,deviceid "$DEV1" |tee out
grep sys_wwid out
# check wwid string in system.devices
-grep sys_wwid $DF
+grep sys_wwid "$DF"
# Replace IDNAME with the IDNAME that 9.0/9.1 created from this wwid
-cat $DF | grep -v IDNAME > $DFTMP
-cat $DFTMP
-echo "IDTYPE=sys_wwid IDNAME=${T10_WWID_RHEL91} DEVNAME=${DEV1} PVID=${PVID1}" >> $DFTMP
-cp $DFTMP $DF
-cat $DF
+cat "$DF" | grep -v IDNAME > "$DFTMP"
+cat "$DFTMP"
+echo "IDTYPE=sys_wwid IDNAME=${T10_WWID_RHEL91} DEVNAME=${DEV1} PVID=${PVID1}" >> "$DFTMP"
+cp "$DFTMP" "$DF"
+cat "$DF"
vgs
pvs
pvs -o+deviceidtype,deviceid "$DEV1"
lvremove -y $vg
vgremove $vg
-rm $SYS_DIR/dev/block/$MAJOR1:$MINOR1/device/wwid
+rm "$SYS_DIR/dev/block/$MAJOR1:$MINOR1/device/wwid"
cleanup_sysfs
#
@@ -363,67 +361,70 @@ cleanup_sysfs
# underscores are understood.
#
-rm $DF
+rm "$DF"
aux wipefs_a "$DEV1"
-mkdir -p $SYS_DIR/dev/block/$MAJOR1:$MINOR1/device
-echo -n " s123 456 " > $SYS_DIR/dev/block/$MAJOR1:$MINOR1/device/serial
+mkdir -p "$SYS_DIR/dev/block/$MAJOR1:$MINOR1/device"
+echo -n " s123 456 " > "$SYS_DIR/dev/block/$MAJOR1:$MINOR1/device/serial"
lvmdevices --adddev "$DEV1"
-cat $DF
-grep "IDNAME=s123__456 DEVNAME" $DF
+cat "$DF"
+grep "IDNAME=s123__456 DEVNAME" "$DF"
vgcreate $vg "$DEV1"
-PVID1=`pvs "$DEV1" --noheading -o uuid | tr -d - | awk '{print $1}'`
-cat $DF | grep -v IDNAME > $DFTMP
-cat $DFTMP
-echo "IDTYPE=sys_serial IDNAME=__s123__456__ DEVNAME=${DEV1} PVID=${PVID1}" >> $DFTMP
-cp $DFTMP $DF
-cat $DF
+eval "$(pvs --noheading --nameprefixes -o uuid "$DEV1")"
+PVID1=${LVM2_PV_UUID//-/}
+cat "$DF" | grep -v IDNAME > "$DFTMP"
+cat "$DFTMP"
+echo "IDTYPE=sys_serial IDNAME=__s123__456__ DEVNAME=${DEV1} PVID=${PVID1}" >> "$DFTMP"
+cp "$DFTMP" "$DF"
+cat "$DF"
vgs
pvs -o+deviceidtype,deviceid "$DEV1"
lvremove -y $vg
vgremove $vg
-rm $SYS_DIR/dev/block/$MAJOR1:$MINOR1/device/serial
+rm "$SYS_DIR/dev/block/$MAJOR1:$MINOR1/device/serial"
cleanup_sysfs
-rm $DF
+rm "$DF"
aux wipefs_a "$DEV1"
-mkdir -p $SYS_DIR/dev/block/$MAJOR1:$MINOR1/device
-echo -n " t10.123 456 " > $SYS_DIR/dev/block/$MAJOR1:$MINOR1/device/wwid
+mkdir -p "$SYS_DIR/dev/block/$MAJOR1:$MINOR1/device"
+echo -n " t10.123 456 " > "$SYS_DIR/dev/block/$MAJOR1:$MINOR1/device/wwid"
lvmdevices --adddev "$DEV1"
-cat $DF
-grep "IDNAME=t10.123_456 DEVNAME" $DF
+cat "$DF"
+grep "IDNAME=t10.123_456 DEVNAME" "$DF"
vgcreate $vg "$DEV1"
-PVID1=`pvs "$DEV1" --noheading -o uuid | tr -d - | awk '{print $1}'`
-cat $DF | grep -v IDNAME > $DFTMP
-cat $DFTMP
-echo "IDTYPE=sys_wwid IDNAME=__t10.123__456__ DEVNAME=${DEV1} PVID=${PVID1}" >> $DFTMP
-cp $DFTMP $DF
-cat $DF
+eval "$(pvs --noheading --nameprefixes -o uuid "$DEV1")"
+PVID1=${LVM2_PV_UUID//-/}
+cat "$DF" | grep -v IDNAME > "$DFTMP"
+cat "$DFTMP"
+echo "IDTYPE=sys_wwid IDNAME=__t10.123__456__ DEVNAME=${DEV1} PVID=${PVID1}" >> "$DFTMP"
+cp "$DFTMP" "$DF"
+cat "$DF"
vgs
pvs -o+deviceidtype,deviceid "$DEV1"
lvremove -y $vg
vgremove $vg
-rm $SYS_DIR/dev/block/$MAJOR1:$MINOR1/device/wwid
+rm "$SYS_DIR/dev/block/$MAJOR1:$MINOR1/device/wwid"
cleanup_sysfs
-rm $DF
+rm "$DF"
aux wipefs_a "$DEV1"
-mkdir -p $SYS_DIR/dev/block/$MAJOR1:$MINOR1/device
-echo -n " naa.123 456 " > $SYS_DIR/dev/block/$MAJOR1:$MINOR1/device/wwid
+mkdir -p "$SYS_DIR/dev/block/$MAJOR1:$MINOR1/device"
+echo -n " naa.123 456 " > "$SYS_DIR/dev/block/$MAJOR1:$MINOR1/device/wwid"
lvmdevices --adddev "$DEV1"
-cat $DF
-grep "IDNAME=naa.123__456 DEVNAME" $DF
+cat "$DF"
+grep "IDNAME=naa.123__456 DEVNAME" "$DF"
vgcreate $vg "$DEV1"
-PVID1=`pvs "$DEV1" --noheading -o uuid | tr -d - | awk '{print $1}'`
-cat $DF | grep -v IDNAME > $DFTMP
-cat $DFTMP
-echo "IDTYPE=sys_wwid IDNAME=__naa.123__456__ DEVNAME=${DEV1} PVID=${PVID1}" >> $DFTMP
-cp $DFTMP $DF
-cat $DF
+eval "$(pvs --noheading --nameprefixes -o uuid "$DEV1")"
+PVID1=${LVM2_PV_UUID//-/}
+cat "$DF" | grep -v IDNAME > "$DFTMP"
+cat "$DFTMP"
+echo "IDTYPE=sys_wwid IDNAME=__naa.123__456__ DEVNAME=${DEV1} PVID=${PVID1}" >> "$DFTMP"
+cp "$DFTMP" "$DF"
+cat "$DF"
vgs
pvs -o+deviceidtype,deviceid "$DEV1"
lvremove -y $vg
vgremove $vg
-rm $SYS_DIR/dev/block/$MAJOR1:$MINOR1/device/wwid
+rm "$SYS_DIR/dev/block/$MAJOR1:$MINOR1/device/wwid"
cleanup_sysfs
@@ -433,4 +434,3 @@ cleanup_sysfs
# This would let the user specify the second naa wwid.
remove_base
-rmmod scsi_debug || true
--
2.35.3