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..b0bb32ad39c 100644 --- a/libvirt/tests/src/virtual_disks/startup_policy.py +++ b/libvirt/tests/src/virtual_disks/startup_policy.py @@ -165,16 +165,17 @@ def create_disk_xml(): shutil.copyfile(disk_xml, disk_xml_file) return disk_xml - def check_in_vm(old_parts): + def check_in_vm(old_parts, device_type): """ Check mount/read/write disk in VM. :param old_parts: pre-operated partitions in VM. + :param device_type: test parameter, e.g. 'cdrom', 'floppy' :return: True if check successfully. """ try: session = vm.wait_for_login() - new_parts = utils_disk.get_parts_list(session) + new_parts = utils_disk.get_parts_list_by_path(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) @@ -185,11 +186,12 @@ def check_in_vm(old_parts): if not added_part: 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" + if device_type not in ["cdrom", "floppy"]: + + cmd = ("fdisk -l {0} && mkfs.ext4 -F {0} && " + "mkdir -p test && mount {0} test && echo" " teststring > test/testfile && umount test" - .format(added_part)) + .format("/dev/disk/by-path/%s" % added_part)) status, output = session.cmd_status_output(cmd) logging.info("Check disk operation in VM:\n%s", output) if status != 0: @@ -342,7 +344,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 = utils_disk.get_parts_list_by_path(session) session.close() vm.destroy(gracefully=False) @@ -459,7 +461,7 @@ def rename_file(source_file, target_file, revert=False): # Step 1. Start domain and destroy it normally. vm.start() # Step 1 Start VM successfully. - if not check_in_vm(old_parts): + if not check_in_vm(old_parts, device_type): test.fail("Check disk partitions in VM failed") # Step 2 Destroy VM, move the volume to other place, refresh the pool, then start the guest. diff --git a/libvirt/tests/src/virtual_disks/virtual_disks_filedescriptor.py b/libvirt/tests/src/virtual_disks/virtual_disks_filedescriptor.py index dfd741622e1..b5a233538a3 100644 --- a/libvirt/tests/src/virtual_disks/virtual_disks_filedescriptor.py +++ b/libvirt/tests/src/virtual_disks/virtual_disks_filedescriptor.py @@ -29,7 +29,6 @@ from virttest.utils_test import libvirt LOG = logging.getLogger('avocado.' + __name__) - cleanup_files = [] @@ -50,7 +49,8 @@ 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 = utils_disk.get_added_parts_by_path(session, + old_partitions) LOG.debug("Newly added partition(s) is: %s", added_partitions) return added_partitions except Exception as err: @@ -235,6 +235,7 @@ def run(test, params, env): hotplug = "yes" == params.get("virt_device_hotplug") pkgs_host = params.get("pkgs_host", "") disk_readonly = params.get("disk_readonly", "no") == "yes" + part_path = "/dev/disk/by-path/%s" # Skip test if version not match expected one libvirt_version.is_libvirt_feature_supported(params) @@ -243,7 +244,7 @@ def run(test, params, env): if vm.is_dead(): vm.start() session = vm.wait_for_login() - old_partitions = utils_disk.get_parts_list(session) + old_partitions = utils_disk.get_parts_list_by_path(session) session.close() if not hotplug: vm.destroy(gracefully=False) @@ -289,10 +290,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..d9d0c1908c5 100755 --- a/libvirt/tests/src/virtual_disks/virtual_disks_nbd.py +++ b/libvirt/tests/src/virtual_disks/virtual_disks_nbd.py @@ -20,8 +20,6 @@ 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__) @@ -112,11 +110,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 +121,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 = utils_disk.get_parts_list_by_path(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 +129,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("/dev/disk/by-path/%s" % added_part)) status, output = session.cmd_status_output(cmd) logging.debug("Disk operation in VM:\nexit code:\n%s\noutput:\n%s", status, output) @@ -176,7 +173,7 @@ def check_in_vm(target, old_parts): if vm.is_dead(): vm.start() session = vm.wait_for_login() - old_parts = utils_disk.get_parts_list(session) + old_parts = utils_disk.get_parts_list_by_path(session) session.close() vm.destroy(gracefully=False) @@ -278,7 +275,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':