From 339baf4689ca0aabae89e4640f272e0d513278ac Mon Sep 17 00:00:00 2001 From: chunfuwen Date: Sun, 6 Oct 2024 08:15:37 -0400 Subject: [PATCH] Automate Resize a block size to a value that's not a multiple of 1024 xxx-62472 - Resize a block size to a value that's not a multiple of 1024,it need align with multiple of 1024 Signed-off-by: chunfuwen --- .../virtual_disks_blockresize.cfg | 12 +++++++++++ .../virtual_disks_blockresize.py | 21 ++++++++++++++++--- 2 files changed, 30 insertions(+), 3 deletions(-) diff --git a/libvirt/tests/cfg/virtual_disks/virtual_disks_blockresize.cfg b/libvirt/tests/cfg/virtual_disks/virtual_disks_blockresize.cfg index ea6d397427..7077673864 100755 --- a/libvirt/tests/cfg/virtual_disks/virtual_disks_blockresize.cfg +++ b/libvirt/tests/cfg/virtual_disks/virtual_disks_blockresize.cfg @@ -42,6 +42,18 @@ status_error = "yes" resize_value = "--capacity" status_error_msg = "Operation not supported: block resize to full capacity supported only with.*raw.*local block-based disks" + - not_align_with_multiple_1024_large: + only coldplug..virtio + resize_value = "900B" + source_raw_file_path = "/var/lib/libvirt/images/align_large.raw" + type_name = "file" + actual_resize_value = "1024" + - not_align_with_multiple_1024_small: + only coldplug..virtio + resize_value = "600B" + source_raw_file_path = "/var/lib/libvirt/images/align_small.raw" + type_name = "file" + actual_resize_value = "1024" variants target_bus: - virtio: - sata: diff --git a/libvirt/tests/src/virtual_disks/virtual_disks_blockresize.py b/libvirt/tests/src/virtual_disks/virtual_disks_blockresize.py index e7380dd73b..fbf7f593eb 100644 --- a/libvirt/tests/src/virtual_disks/virtual_disks_blockresize.py +++ b/libvirt/tests/src/virtual_disks/virtual_disks_blockresize.py @@ -65,7 +65,14 @@ def create_customized_disk(params, test): device_target = params.get("target_dev") device_bus = params.get("target_bus") device_format = params.get("target_format") - source_file_path = setup_scsi_debug_block_device() + source_file_path = None + source_raw_file_path = params.get("source_raw_file_path") + if source_raw_file_path: + libvirt.create_local_disk("file", source_raw_file_path, "100M", device_format) + cleanup_files.append(source_raw_file_path) + source_file_path = source_raw_file_path + else: + source_file_path = setup_scsi_debug_block_device() overlay_source_file_path = params.get("overlay_source_file_path") expected_size = params.get("block_size_in_bytes") source_dict = {} @@ -73,7 +80,9 @@ def create_customized_disk(params, test): # check block size check_image_virtual_size(source_file_path, expected_size, test) - if source_file_path: + if source_raw_file_path: + source_dict.update({"file": source_file_path}) + else: source_dict.update({"dev": source_file_path}) if overlay_source_file_path: @@ -180,6 +189,8 @@ def run(test, params, env): target_bus = params.get("target_bus") target_dev = params.get('target_dev') status_error = "yes" == params.get("status_error") + type_name = params.get("type_name") + source_raw_file_path = params.get("source_raw_file_path") try: device_obj = create_customized_disk(params, test) if not hotplug: @@ -216,6 +227,9 @@ def run(test, params, env): result = virsh.blockresize(vm_name, target_dev, resize_value, **virsh_dargs) libvirt.check_exit_status(result, status_error) + if test_scenario in ["not_align_with_multiple_1024_large", "not_align_with_multiple_1024_small"]: + actual_expectd_size = params.get("actual_resize_value") + check_image_virtual_size(source_raw_file_path, actual_expectd_size, test) if not status_error: check_vm_dumpxml(params, test, False) @@ -228,7 +242,8 @@ def run(test, params, env): if vm.is_alive(): vm.destroy(gracefully=False) vmxml_backup.sync() - libvirt.delete_scsi_disk() + if type_name in ["block"]: + libvirt.delete_scsi_disk() for file_path in cleanup_files: if os.path.exists(file_path): os.remove(file_path)