diff --git a/libvirt/tests/cfg/virtual_disks/startup_policy.cfg b/libvirt/tests/cfg/virtual_disks/startup_policy.cfg index 88dd68e8efe..54fc056296e 100644 --- a/libvirt/tests/cfg/virtual_disks/startup_policy.cfg +++ b/libvirt/tests/cfg/virtual_disks/startup_policy.cfg @@ -65,6 +65,7 @@ aarch64: disk_target_bus = "scsi" - floppy: + no s390-virtio device_type = "floppy" target_dev = "fda" disk_target_bus = "fdc" @@ -78,6 +79,7 @@ target_dev = "vdb" disk_target_bus = "virtio" - sata_bus: + no s390-virtio target_dev = "sdb" disk_target_bus = "sata" variants: diff --git a/libvirt/tests/src/virtual_disks/startup_policy.py b/libvirt/tests/src/virtual_disks/startup_policy.py index 11a07bb87b9..ac05da969d0 100644 --- a/libvirt/tests/src/virtual_disks/startup_policy.py +++ b/libvirt/tests/src/virtual_disks/startup_policy.py @@ -1,6 +1,7 @@ import os import re import logging as log +import platform import shutil import aexpect @@ -23,6 +24,8 @@ # Using as lower capital is not the best way to do, but this is just a # workaround to avoid changing the entire file. logging = log.getLogger('avocado.' + __name__) +get_parts_list_func = utils_disk.get_parts_list +parts_path = "/dev/%" def run(test, params, env): @@ -174,7 +177,7 @@ def check_in_vm(old_parts): """ try: session = vm.wait_for_login() - new_parts = utils_disk.get_parts_list(session) + new_parts = get_parts_list_func(session) logging.debug("new parted:%s", new_parts) added_parts = list(set(new_parts).difference(set(old_parts))) logging.info("Added parts:%s", added_parts) @@ -186,10 +189,10 @@ def check_in_vm(old_parts): logging.error("Can't see added partition in VM") return False if 'sr' not in added_part and 'fd' not in added_part: - cmd = ("fdisk -l /dev/{0} && mkfs.ext4 -F /dev/{0} && " - "mkdir -p test && mount /dev/{0} test && echo" + cmd = ("fdisk -l {0} && mkfs.ext4 -F {0} && " + "mkdir -p test && mount {0} test && echo" " teststring > test/testfile && umount test" - .format(added_part)) + .format(parts_path % added_part)) status, output = session.cmd_status_output(cmd) logging.info("Check disk operation in VM:\n%s", output) if status != 0: @@ -342,7 +345,7 @@ def rename_file(source_file, target_file, revert=False): if vm.is_dead(): vm.start() session = vm.wait_for_login() - old_parts = utils_disk.get_parts_list(session) + old_parts = get_parts_list_func(session) session.close() vm.destroy(gracefully=False) @@ -385,6 +388,11 @@ def rename_file(source_file, target_file, revert=False): update_policy_list = params.get("update_policy_list").split() expect_value = [None, startup_policy] + if "s390x" == platform.machine(): + global parts_path, get_parts_list_func + parts_path = "/dev/disk/by-path/%s" + get_parts_list_func = utils_disk.get_parts_list_by_path + try: if disk_type == "volume": pvt = libvirt.PoolVolumeTest(test, params) diff --git a/libvirt/tests/src/virtual_disks/virtual_disks_filedescriptor.py b/libvirt/tests/src/virtual_disks/virtual_disks_filedescriptor.py index dfd741622e1..80cd4c8f883 100644 --- a/libvirt/tests/src/virtual_disks/virtual_disks_filedescriptor.py +++ b/libvirt/tests/src/virtual_disks/virtual_disks_filedescriptor.py @@ -29,7 +29,9 @@ from virttest.utils_test import libvirt LOG = logging.getLogger('avocado.' + __name__) - +get_parts_func = utils_disk.get_parts_list +get_added_parts_func = utils_disk.get_added_parts +part_path = "/dev/%" cleanup_files = [] @@ -50,7 +52,7 @@ def get_added_disks(old_partitions, test, params, env): session = vm.wait_for_login() if platform.platform().count('ppc64'): time.sleep(10) - added_partitions = utils_disk.get_added_parts(session, old_partitions) + added_partitions = get_added_parts_func(session,old_partitions) LOG.debug("Newly added partition(s) is: %s", added_partitions) return added_partitions except Exception as err: @@ -113,8 +115,7 @@ def coldplug_disk(test, params, env): def coldplug_save_restore(test, params, env): """ cold plug disk, save and restore VM in one session - - :param test: test object +:param test: test object :param params: one dictionary wrapping parameters :param env: environment representing running context """ @@ -239,11 +240,17 @@ def run(test, params, env): # Skip test if version not match expected one libvirt_version.is_libvirt_feature_supported(params) + if 's390x' == platform.machine(): + global get_parts_func, get_added_parts_func, part_path + get_parts_func = utils_disk.get_parts_list_by_path + get_added_parts_func = utils_disk.get_added_parts_by_path + part_path = "/dev/disk/by-path/%s" + # Get disk partitions info before hot/cold plug virtual disk if vm.is_dead(): vm.start() session = vm.wait_for_login() - old_partitions = utils_disk.get_parts_list(session) + old_partitions = get_parts_func(session) session.close() if not hotplug: vm.destroy(gracefully=False) @@ -289,10 +296,10 @@ def run(test, params, env): if platform.platform().count('ppc64'): time.sleep(10) if disk_readonly: - if libvirt_disk.check_virtual_disk_io(vm, new_disk): + if libvirt_disk.check_virtual_disk_io(vm, new_disk, path=part_path): test.fail("Expect the newly added disk is not writable, but actually it is") else: - if not libvirt_disk.check_virtual_disk_io(vm, new_disk): + if not libvirt_disk.check_virtual_disk_io(vm, new_disk, path=part_path): test.fail("Cannot operate the newly added disk in vm.") virsh.detach_device(vm_name, device_obj.xml, flagstr="--live", debug=True, ignore_status=False) diff --git a/libvirt/tests/src/virtual_disks/virtual_disks_nbd.py b/libvirt/tests/src/virtual_disks/virtual_disks_nbd.py index a1255647978..c435184483c 100755 --- a/libvirt/tests/src/virtual_disks/virtual_disks_nbd.py +++ b/libvirt/tests/src/virtual_disks/virtual_disks_nbd.py @@ -20,9 +20,9 @@ from virttest.libvirt_xml.devices.disk import Disk -# Using as lower capital is not the best way to do, but this is just a -# workaround to avoid changing the entire file. logging = log.getLogger('avocado.' + __name__) +parts_path = "/dev/%s" +get_parts_func = utils_disk.get_parts_list def run(test, params, env): @@ -112,11 +112,10 @@ def _check_file_create(filename): % snapshot_name2) _check_file_create("mem.txt") - def check_in_vm(target, old_parts): + def check_in_vm(old_parts): """ Check mount/read/write disk in VM. - :param target: Disk dev in VM. :param old_parts: Original disk partitions in VM. :return: True if check successfully. """ @@ -124,7 +123,7 @@ def check_in_vm(target, old_parts): session = vm.wait_for_login() if platform.platform().count('ppc64'): time.sleep(10) - new_parts = utils_disk.get_parts_list(session) + new_parts = get_parts_func(session) added_parts = list(set(new_parts).difference(set(old_parts))) logging.info("Added parts:%s", added_parts) if len(added_parts) != 1: @@ -132,10 +131,10 @@ def check_in_vm(target, old_parts): return False else: added_part = added_parts[0] - cmd = ("fdisk -l /dev/{0} && mkfs.ext4 -F /dev/{0} && " - "mkdir -p test && mount /dev/{0} test && echo" + cmd = ("fdisk -l {0} && mkfs.ext4 -F {0} && " + "mkdir -p test && mount {0} test && echo" " teststring > test/testfile && umount test" - .format(added_part)) + .format(parts_path % added_part)) status, output = session.cmd_status_output(cmd) logging.debug("Disk operation in VM:\nexit code:\n%s\noutput:\n%s", status, output) @@ -172,11 +171,15 @@ def check_in_vm(target, old_parts): # Initialize one NbdExport object nbd = None + if 's390x' == platform.machine(): + parts_path = "/dev/disk/by-path/%s" + get_parts_func = utils_disk.get_parts_list_by_path + # Start VM and get all partitions in VM. if vm.is_dead(): vm.start() session = vm.wait_for_login() - old_parts = utils_disk.get_parts_list(session) + old_parts = get_parts_func(session) session.close() vm.destroy(gracefully=False) @@ -278,7 +281,7 @@ def check_in_vm(target, old_parts): if check_partitions and not status_error: logging.debug("wait seconds for starting in checking vm part") time.sleep(2) - if not check_in_vm(device_target, old_parts): + if not check_in_vm(old_parts): test.fail("Check disk partitions in VM failed") # Check snapshot operation and its result if domain_operation == 'snap_shot':