Also, use a /dev/disk/by-id/ symlink to the device, which should be
predictable, unlike the /dev/nvmeX stuff.
dd if=/dev/urandom of=/var/tmp/storagetm.test bs=1024 count=10240
systemd-run -u teststoragetm.service -p Type=notify /usr/lib/systemd/systemd-storagetm /var/tmp/storagetm.test --nqn=quux
+NVME_SERIAL="$(</sys/kernel/config/nvmet/subsystems/quux.storagetm.test/attr_serial)"
+NVME_DEVICE="/dev/disk/by-id/nvme-Linux_${NVME_SERIAL:?}"
nvme connect-all -t tcp -a 127.0.0.1 -s 16858 --hostid="$(cat /proc/sys/kernel/random/uuid)"
+udevadm wait --settle "$NVME_DEVICE"
-dd if=/dev/nvme1n1 bs=1024 | cmp /var/tmp/storagetm.test -
-
-nvme disconnect --device=nvme1
+dd if="$NVME_DEVICE" bs=1024 | cmp /var/tmp/storagetm.test -
+nvme disconnect-all
systemctl stop teststoragetm.service
-
rm /var/tmp/storagetm.test
touch /testok