Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Automate Resize a block size to a value that's not a multiple of 1024 #5931

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions libvirt/tests/cfg/virtual_disks/virtual_disks_blockresize.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
21 changes: 18 additions & 3 deletions libvirt/tests/src/virtual_disks/virtual_disks_blockresize.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,15 +65,24 @@ 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 = {}

# 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:
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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)
Expand All @@ -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)
Loading