From 78e9bb837c258ac0ec7712b3d612cc2f407e731e Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Wed, 12 Jun 2024 05:50:42 +0200 Subject: Merging upstream version 256. Signed-off-by: Daniel Baumann --- test/TEST-64-UDEV-STORAGE/btrfs_basic.configure | 26 ++++++++ test/TEST-64-UDEV-STORAGE/iscsi_lvm.configure | 26 ++++++++ .../TEST-64-UDEV-STORAGE/long_sysfs_path.configure | 32 ++++++++++ test/TEST-64-UDEV-STORAGE/lvm_basic.configure | 25 ++++++++ test/TEST-64-UDEV-STORAGE/mdadm_basic.configure | 25 ++++++++ test/TEST-64-UDEV-STORAGE/mdadm_lvm.configure | 25 ++++++++ test/TEST-64-UDEV-STORAGE/meson.build | 43 ++++++++++++++ .../multipath_basic_failover.configure | 31 ++++++++++ test/TEST-64-UDEV-STORAGE/nvme_basic.configure | 39 ++++++++++++ test/TEST-64-UDEV-STORAGE/nvme_subsystem.configure | 39 ++++++++++++ .../simultaneous_events.configure | 21 +++++++ test/TEST-64-UDEV-STORAGE/test.sh | 69 ++++++---------------- .../virtio_scsi_basic.configure | 28 +++++++++ ...tio_scsi_identically_named_partitions.configure | 33 +++++++++++ 14 files changed, 412 insertions(+), 50 deletions(-) create mode 100755 test/TEST-64-UDEV-STORAGE/btrfs_basic.configure create mode 100755 test/TEST-64-UDEV-STORAGE/iscsi_lvm.configure create mode 100755 test/TEST-64-UDEV-STORAGE/long_sysfs_path.configure create mode 100755 test/TEST-64-UDEV-STORAGE/lvm_basic.configure create mode 100755 test/TEST-64-UDEV-STORAGE/mdadm_basic.configure create mode 100755 test/TEST-64-UDEV-STORAGE/mdadm_lvm.configure create mode 100644 test/TEST-64-UDEV-STORAGE/meson.build create mode 100755 test/TEST-64-UDEV-STORAGE/multipath_basic_failover.configure create mode 100755 test/TEST-64-UDEV-STORAGE/nvme_basic.configure create mode 100755 test/TEST-64-UDEV-STORAGE/nvme_subsystem.configure create mode 100755 test/TEST-64-UDEV-STORAGE/simultaneous_events.configure create mode 100755 test/TEST-64-UDEV-STORAGE/virtio_scsi_basic.configure create mode 100755 test/TEST-64-UDEV-STORAGE/virtio_scsi_identically_named_partitions.configure (limited to 'test/TEST-64-UDEV-STORAGE') diff --git a/test/TEST-64-UDEV-STORAGE/btrfs_basic.configure b/test/TEST-64-UDEV-STORAGE/btrfs_basic.configure new file mode 100755 index 0000000..8ef58a9 --- /dev/null +++ b/test/TEST-64-UDEV-STORAGE/btrfs_basic.configure @@ -0,0 +1,26 @@ +#!/usr/bin/python3 +# SPDX-License-Identifier: LGPL-2.1-or-later + +import json +import sys + + +config = json.load(sys.stdin) + +config["QemuArgs"] += ["-device", "virtio-scsi-pci,id=scsi0"] + +for i in range(4): + id = f"drivebtrfsbasic{i}" + config["QemuDrives"] += [ + { + "Id": id, + "Size": "350M" if i == 0 else "128M", + "Options": "cache=unsafe", + } + ] + config["QemuArgs"] += [ + "-device", + f"scsi-hd,drive={id},vendor=systemd,product=foobar,serial=deadbeefbtrfs{i}", + ] + +json.dump(config, sys.stdout) diff --git a/test/TEST-64-UDEV-STORAGE/iscsi_lvm.configure b/test/TEST-64-UDEV-STORAGE/iscsi_lvm.configure new file mode 100755 index 0000000..ca23e33 --- /dev/null +++ b/test/TEST-64-UDEV-STORAGE/iscsi_lvm.configure @@ -0,0 +1,26 @@ +#!/usr/bin/python3 +# SPDX-License-Identifier: LGPL-2.1-or-later + +import json +import sys + + +config = json.load(sys.stdin) + +config["QemuArgs"] += ["-device", "virtio-scsi-pci,id=scsi0"] + +for i in range(4): + id = f"driveiscsibasic{i}" + config["QemuDrives"] += [ + { + "Id": id, + "Size": "150M" if i == 0 else "70M", + "Options": "cache=unsafe", + } + ] + config["QemuArgs"] += [ + "-device", + f"scsi-hd,drive={id},vendor=systemd,product=foobar,serial=deadbeefiscsi{i}", + ] + +json.dump(config, sys.stdout) diff --git a/test/TEST-64-UDEV-STORAGE/long_sysfs_path.configure b/test/TEST-64-UDEV-STORAGE/long_sysfs_path.configure new file mode 100755 index 0000000..6108bdb --- /dev/null +++ b/test/TEST-64-UDEV-STORAGE/long_sysfs_path.configure @@ -0,0 +1,32 @@ +#!/usr/bin/python3 +# SPDX-License-Identifier: LGPL-2.1-or-later + +import json +import sys + + +config = json.load(sys.stdin) + +config["QemuDrives"] += [ + { + "Id": "drive0", + "Size": "64M", + "Options": "cache=unsafe", + } +] +config["QemuArgs"] += ["-device", "pci-bridge,id=pci_bridge0,chassis_nr=64"] + +# Create 25 additional PCI bridges, each one connected to the previous one +# (basically a really long extension cable), and attach a virtio drive to +# the last one. This should force udev into attempting to create a device +# unit with a _really_ long name. +for bridge in range(1, 26): + config["QemuArgs"] += [ + "-device", + f"pci-bridge,id=pci_bridge{bridge},bus=pci_bridge{bridge - 1}," + f"chassis_nr={64 + bridge}" + ] + +config["QemuArgs"] += ["-device", f"virtio-blk-pci,drive=drive0,scsi=off,bus=pci_bridge25"] + +json.dump(config, sys.stdout) diff --git a/test/TEST-64-UDEV-STORAGE/lvm_basic.configure b/test/TEST-64-UDEV-STORAGE/lvm_basic.configure new file mode 100755 index 0000000..9387b83 --- /dev/null +++ b/test/TEST-64-UDEV-STORAGE/lvm_basic.configure @@ -0,0 +1,25 @@ +#!/usr/bin/python3 +# SPDX-License-Identifier: LGPL-2.1-or-later + +import json +import sys + + +config = json.load(sys.stdin) + +config["QemuArgs"] += ["-device", "virtio-scsi-pci,id=scsi0"] + +for i in range(4): + id = f"drivelvmbasic{i}" + config["QemuDrives"] += [ + { + "Id": id, + "Size": "32M", + "Options": "cache=unsafe", + } + ] + config["QemuArgs"] += [ + "-device", f"scsi-hd,drive={id},vendor=systemd,product=foobar,serial=deadbeeflvm{i}", + ] + +json.dump(config, sys.stdout) diff --git a/test/TEST-64-UDEV-STORAGE/mdadm_basic.configure b/test/TEST-64-UDEV-STORAGE/mdadm_basic.configure new file mode 100755 index 0000000..3f00afa --- /dev/null +++ b/test/TEST-64-UDEV-STORAGE/mdadm_basic.configure @@ -0,0 +1,25 @@ +#!/usr/bin/python3 +# SPDX-License-Identifier: LGPL-2.1-or-later + +import json +import sys + + +config = json.load(sys.stdin) + +config["QemuArgs"] += ["-device", "virtio-scsi-pci,id=scsi0"] + +for i in range(5): + id = f"drivemdadmbasic{i}" + config["QemuDrives"] += [ + { + "Id": id, + "Size": "64M", + "Options": "cache=unsafe", + } + ] + config["QemuArgs"] += [ + "-device", f"scsi-hd,drive={id},vendor=systemd,product=foobar,serial=deadbeefmdadm{i}", + ] + +json.dump(config, sys.stdout) diff --git a/test/TEST-64-UDEV-STORAGE/mdadm_lvm.configure b/test/TEST-64-UDEV-STORAGE/mdadm_lvm.configure new file mode 100755 index 0000000..b7661d9 --- /dev/null +++ b/test/TEST-64-UDEV-STORAGE/mdadm_lvm.configure @@ -0,0 +1,25 @@ +#!/usr/bin/python3 +# SPDX-License-Identifier: LGPL-2.1-or-later + +import json +import sys + + +config = json.load(sys.stdin) + +config["QemuArgs"] += ["-device", "virtio-scsi-pci,id=scsi0"] + +for i in range(5): + id = f"drivemdadmlvm{i}" + config["QemuDrives"] += [ + { + "Id": id, + "Size": "64M", + "Options": "cache=unsafe", + } + ] + config["QemuArgs"] += [ + "-device", f"scsi-hd,drive={id},vendor=systemd,product=foobar,serial=deadbeefmdadmlvm{i}", + ] + +json.dump(config, sys.stdout) diff --git a/test/TEST-64-UDEV-STORAGE/meson.build b/test/TEST-64-UDEV-STORAGE/meson.build new file mode 100644 index 0000000..15981ce --- /dev/null +++ b/test/TEST-64-UDEV-STORAGE/meson.build @@ -0,0 +1,43 @@ +# SPDX-License-Identifier: LGPL-2.1-or-later + +name = fs.name(meson.current_source_dir()) +unit = configure_file( + input : files('../test.service.in'), + output : '@0@.service'.format(name), + # Disable user service manager by default for performance. + configuration : integration_test_template['configuration'] + { + 'wants' : '', + 'after' : '', + }, +) + +foreach testcase : [ + 'btrfs_basic', + 'iscsi_lvm', + 'long_sysfs_path', + 'lvm_basic', + 'mdadm_basic', + 'mdadm_lvm', + 'multipath_basic_failover', + 'nvme_basic', + 'nvme_subsystem', + 'simultaneous_events', + 'virtio_scsi_basic', + 'virtio_scsi_identically_named_partitions', +] + integration_tests += [ + integration_test_template + { + 'name' : '@0@-@1@'.format(name, testcase), + # Make sure the service is still named TEST-64-UDEV-STORAGE.service. + 'unit' : unit, + 'cmdline' : integration_test_template['cmdline'] + [ + 'systemd.setenv=TEST_FUNCTION_NAME=testcase_@0@'.format(testcase) + ], + 'mkosi-args' : integration_test_template['mkosi-args'] + [ + '--configure-script', files('@0@.configure'.format(testcase)), + ], + 'priority' : 10, + 'vm' : true, + }, + ] +endforeach diff --git a/test/TEST-64-UDEV-STORAGE/multipath_basic_failover.configure b/test/TEST-64-UDEV-STORAGE/multipath_basic_failover.configure new file mode 100755 index 0000000..5f323b8 --- /dev/null +++ b/test/TEST-64-UDEV-STORAGE/multipath_basic_failover.configure @@ -0,0 +1,31 @@ +#!/usr/bin/python3 +# SPDX-License-Identifier: LGPL-2.1-or-later + +import json +import sys + + +config = json.load(sys.stdin) + +# Add 16 multipath devices, each backed by 4 paths +# We don't use --qemu-drive for this since they have to share the file. +for ndisk in range(16): + wwn = f"0xDEADDEADBEEF{ndisk:04d}" + if ndisk == 0: + size = "16M" + else: + size = "1M" + + for nback in range(4): + id = f"drive{ndisk}x{nback}" + config["QemuDrives"] += [ + { + "Id": id, + "Size": size, + "Options": "cache=unsafe", + "FileId": str(ndisk), + } + ] + config["QemuArgs"] += ["-device", f"scsi-hd,drive={id},serial=MPIO{ndisk},wwn={wwn}"] + +json.dump(config, sys.stdout) diff --git a/test/TEST-64-UDEV-STORAGE/nvme_basic.configure b/test/TEST-64-UDEV-STORAGE/nvme_basic.configure new file mode 100755 index 0000000..37d0d35 --- /dev/null +++ b/test/TEST-64-UDEV-STORAGE/nvme_basic.configure @@ -0,0 +1,39 @@ +#!/usr/bin/python3 +# SPDX-License-Identifier: LGPL-2.1-or-later + +import json +import os +import subprocess +import sys + + +config = json.load(sys.stdin) + +qemu = f"qemu-system-{os.environ["QEMU_ARCHITECTURE"]}" +result = subprocess.run([qemu, '-device', 'help'], check=True, text=True, stdout=subprocess.PIPE) +if 'name "nvme"' not in result.stdout: + print("nvme device driver is not available, skipping test...", file=sys.stderr) + exit(77) + +def add_drive(i: int, serial: str) -> None: + global config + id = f"nvme{i}" + config["QemuDrives"] += [ + { + "Id": id, + "Size": "1M", + "Options": "cache=unsafe", + } + ] + config["QemuArgs"] += ["-device", f"nvme,drive={id},serial={serial},num_queues=8"] + +for i in range(5): + add_drive(i, serial=f"deadbeef{i}") +for i in range(5, 10): + add_drive(i, serial=f" deadbeef {i} ") +for i in range(10, 15): + add_drive(i, serial=f" dead/beef/{i} ") +for i in range(15, 20): + add_drive(i, serial=f"dead/../../beef/{i}") + +json.dump(config, sys.stdout) diff --git a/test/TEST-64-UDEV-STORAGE/nvme_subsystem.configure b/test/TEST-64-UDEV-STORAGE/nvme_subsystem.configure new file mode 100755 index 0000000..eb601a6 --- /dev/null +++ b/test/TEST-64-UDEV-STORAGE/nvme_subsystem.configure @@ -0,0 +1,39 @@ +#!/usr/bin/python3 +# SPDX-License-Identifier: LGPL-2.1-or-later + +import json +import os +import subprocess +import sys + + +config = json.load(sys.stdin) + +qemu = f"qemu-system-{os.environ["QEMU_ARCHITECTURE"]}" +result = subprocess.run([qemu, '-device', 'help'], check=True, text=True, stdout=subprocess.PIPE) +if 'name "nvme"' not in result.stdout: + print("nvme device driver is not available, skipping test...", file=sys.stderr) + exit(77) + +for id in ("nvme0", "nvme1"): + config["QemuDrives"] += [ + { + "Id": id, + "Size": "1M", + "Options": "cache=unsafe", + } + + ] + +config["QemuArgs"] += [ + # Create an NVM Subsystem Device + "-device", "nvme-subsys,id=nvme-subsys-64,nqn=subsys64", + # Attach two NVM controllers to it + "-device", "nvme,subsys=nvme-subsys-64,serial=deadbeef", + "-device", "nvme,subsys=nvme-subsys-64,serial=deadbeef", + # And create two shared namespaces attached to both controllers + "-device", "nvme-ns,drive=nvme0,nsid=16,shared=on", + "-device", "nvme-ns,drive=nvme1,nsid=17,shared=on", +] + +json.dump(config, sys.stdout) diff --git a/test/TEST-64-UDEV-STORAGE/simultaneous_events.configure b/test/TEST-64-UDEV-STORAGE/simultaneous_events.configure new file mode 100755 index 0000000..a0edb01 --- /dev/null +++ b/test/TEST-64-UDEV-STORAGE/simultaneous_events.configure @@ -0,0 +1,21 @@ +#!/usr/bin/python3 +# SPDX-License-Identifier: LGPL-2.1-or-later + +import json +import sys + + +config = json.load(sys.stdin) + +for i in range(10): + id = f"drivesimultaneousevents{i}" + config["QemuDrives"] += [ + { + "Id": id, + "Size": "128M", + "Options": "cache=unsafe", + } + ] + config["QemuArgs"] += ["-device", f"scsi-hd,drive={id},serial=deadbeeftest{i}"] + +json.dump(config, sys.stdout) diff --git a/test/TEST-64-UDEV-STORAGE/test.sh b/test/TEST-64-UDEV-STORAGE/test.sh index b9e7bdf..b5a70ca 100755 --- a/test/TEST-64-UDEV-STORAGE/test.sh +++ b/test/TEST-64-UDEV-STORAGE/test.sh @@ -159,18 +159,18 @@ test_run() { return 0 } -testcase_megasas2_basic() { - if ! "${QEMU_BIN:?}" -device help | grep 'name "megasas-gen2"'; then - echo "megasas-gen2 device driver is not available, skipping test..." +testcase_virtio_scsi_basic() { + if ! "${QEMU_BIN:?}" -device help | grep 'name "virtio-scsi-pci"'; then + echo "virtio-scsi-pci device driver is not available, skipping test..." return 77 fi local i local qemu_opts=( - "-device megasas-gen2,id=scsi0" - "-device megasas-gen2,id=scsi1" - "-device megasas-gen2,id=scsi2" - "-device megasas-gen2,id=scsi3" + "-device virtio-scsi-pci,id=scsi0" + "-device virtio-scsi-pci,id=scsi1" + "-device virtio-scsi-pci,id=scsi2" + "-device virtio-scsi-pci,id=scsi3" ) for i in {0..127}; do @@ -268,24 +268,15 @@ testcase_virtio_scsi_identically_named_partitions() { # and attach them to a virtio-scsi controller local qemu_opts=("-device virtio-scsi-pci,id=scsi0,num_queues=4") local diskpath="${TESTDIR:?}/namedpart0.img" - local i lodev num_disk num_part qemu_timeout + local i num_disk qemu_timeout if get_bool "${IS_BUILT_WITH_ASAN:=}" || ! get_bool "$QEMU_KVM"; then num_disk=4 - num_part=4 else num_disk=16 - num_part=8 fi dd if=/dev/zero of="$diskpath" bs=1M count=18 - lodev="$(losetup --show -f -P "$diskpath")" - sfdisk "${lodev:?}" <