From c9d41cb93892e43a9ac742d1694dca43aab781ac Mon Sep 17 00:00:00 2001 From: Aakanksha Tripathi Date: Wed, 18 Oct 2023 13:10:30 +0530 Subject: [PATCH] Resolve memory attachment & update issues Fix memory device attachment and update errors. The block size was too small, requiring a minimum of 524288KiB.This commit corrects the issue, allowing successful memory device attachment and updates. Signed-off-by: Aakanksha Tripathi --- libvirt/tests/cfg/memory/memory_attach_device.cfg | 4 ++-- libvirt/tests/cfg/memory/memory_update_device.cfg | 5 ++--- libvirt/tests/src/memory/memory_attach_device.py | 7 ++----- libvirt/tests/src/memory/memory_update_device.py | 13 ++++--------- 4 files changed, 10 insertions(+), 19 deletions(-) diff --git a/libvirt/tests/cfg/memory/memory_attach_device.cfg b/libvirt/tests/cfg/memory/memory_attach_device.cfg index ccaf00fd69b..701031386b9 100644 --- a/libvirt/tests/cfg/memory/memory_attach_device.cfg +++ b/libvirt/tests/cfg/memory/memory_attach_device.cfg @@ -9,12 +9,12 @@ variants test_case: - virtio_mem: no pseries - set_num_huge_pages = 1000 required_kernel = [5.14.0,) guest_required_kernel = [5.8.0,) func_supported_since_libvirt_ver = (8, 0, 0) func_supported_since_qemu_kvm_ver = (6, 2, 0) vm_attrs = {'max_mem_rt': 10485760, 'max_mem_rt_slots': 16, 'max_mem_rt_unit': 'KiB', 'vcpu': 4, 'cpu': {'numa_cell': [{'id': '0', 'cpus': '0-1', 'memory': '1048576', 'unit': 'KiB'}]}} + mem_device_attrs = {'mem_model': 'virtio-mem', 'target': {'requested_unit': 'KiB', 'size': 262144, 'node': 0, 'size_unit': 'KiB', 'requested_size': 131072, 'block_unit': 'KiB', 'block_size': 2048}} aarch64: vm_attrs = {'max_mem_rt': 10485760, 'max_mem_rt_slots': 16, 'max_mem_rt_unit': 'KiB', 'vcpu': 4, 'cpu': {'mode': 'host-passthrough', 'numa_cell': [{'id': '0', 'cpus': '0-3', 'memory': '524288', 'unit': 'KiB'}]}} - mem_device_attrs = {'mem_model': 'virtio-mem', 'target': {'requested_unit': 'KiB', 'size': 262144, 'node': 0, 'size_unit': 'KiB', 'requested_size': 131072, 'block_unit': 'KiB', 'block_size': 2048}, 'source': {'pagesize_unit': 'KiB', 'pagesize': 2048, 'nodemask': '0'}} + mem_device_attrs = {'mem_model': 'virtio-mem', 'target': {'requested_unit': 'KiB', 'size': 1048576, 'node': 0, 'size_unit': 'KiB', 'requested_size': 524288, 'block_unit': 'KiB', 'block_size': 524288}} diff --git a/libvirt/tests/cfg/memory/memory_update_device.cfg b/libvirt/tests/cfg/memory/memory_update_device.cfg index 7608cb9e60f..6ff1f277aa0 100644 --- a/libvirt/tests/cfg/memory/memory_update_device.cfg +++ b/libvirt/tests/cfg/memory/memory_update_device.cfg @@ -5,7 +5,6 @@ variants test_case: - virtio_mem: no pseries - set_num_huge_pages = 1000 required_kernel = [5.14.0,) guest_required_kernel = [5.8.0,) func_supported_since_libvirt_ver = (8, 0, 0) @@ -13,7 +12,7 @@ vm_attrs = {'max_mem_rt': 10485760, 'max_mem_rt_slots': 16, 'max_mem_rt_unit': 'KiB', 'vcpu': 4, 'cpu': {'numa_cell': [{'id': '0', 'cpus': '0-1', 'memory': '1048576', 'unit': 'KiB'}]}} aarch64: vm_attrs = {'max_mem_rt': 10485760, 'max_mem_rt_slots': 16, 'max_mem_rt_unit': 'KiB', 'vcpu': 4, 'cpu': {'mode': 'host-passthrough', 'numa_cell': [{'id': '0', 'cpus': '0-3', 'memory': '524288', 'unit': 'KiB'}]}} - mem_device_attrs = {'mem_model': 'virtio-mem', 'target': {'requested_unit': 'KiB', 'size': 262144, 'node': 0, 'size_unit': 'KiB', 'requested_size': 131072, 'block_unit': 'KiB', 'block_size': 2048}, 'source': {'pagesize_unit': 'KiB', 'pagesize': 2048, 'nodemask': '0'}} - requested_size = 160MiB + mem_device_attrs = {'mem_model': 'virtio-mem', 'target': {'requested_unit': 'KiB', 'size': 1048576, 'node': 0, 'size_unit': 'KiB', 'requested_size': 524288, 'block_unit': 'KiB', 'block_size': 524288}} + requested_size = 1048576KiB check_log_str = "MEMORY_DEVICE_SIZE_CHANGE.*virtiomem" virsh_opts = "--alias %s --requested-size ${requested_size}" diff --git a/libvirt/tests/src/memory/memory_attach_device.py b/libvirt/tests/src/memory/memory_attach_device.py index 0e99b305447..d1c9eb15ee6 100644 --- a/libvirt/tests/src/memory/memory_attach_device.py +++ b/libvirt/tests/src/memory/memory_attach_device.py @@ -7,6 +7,7 @@ from virttest.staging import utils_memory from virttest.utils_libvirt import libvirt_vmxml from virttest.utils_version import VersionInterval +import time VIRSH_ARGS = {'debug': True, 'ignore_status': False} ORG_HP = utils_memory.get_num_huge_pages() @@ -56,9 +57,6 @@ def setup_test_virtio_mem(): """ Setup vmxml for test """ - set_num_huge_pages = params.get("set_num_huge_pages") - if set_num_huge_pages: - utils_memory.set_num_huge_pages(int(set_num_huge_pages)) libvirt_vmxml.remove_vm_devices_by_type(vm, 'memory') vmxml = vm_xml.VMXML.new_from_dumpxml(vm_name) @@ -83,6 +81,7 @@ def run_test_virtio_mem(): virsh.attach_device(vm_name, mem_device.xml, flagstr=options, debug=True, ignore_status=False) + time.sleep(10) if not vm.is_alive(): vm.start() vm.wait_for_login().close() @@ -111,8 +110,6 @@ def cleanup_test_virtio_mem(): """ Clean up environment """ - if utils_memory.get_num_huge_pages() != ORG_HP: - utils_memory.set_num_huge_pages(ORG_HP) # Variable assignment test_case = params.get('test_case', '') diff --git a/libvirt/tests/src/memory/memory_update_device.py b/libvirt/tests/src/memory/memory_update_device.py index 5094bd461d9..e1892a0b180 100644 --- a/libvirt/tests/src/memory/memory_update_device.py +++ b/libvirt/tests/src/memory/memory_update_device.py @@ -59,10 +59,6 @@ def setup_test_virtio_mem(): """ Setup vmxml for test """ - set_num_huge_pages = params.get("set_num_huge_pages") - if set_num_huge_pages: - utils_memory.set_num_huge_pages(int(set_num_huge_pages)) - libvirt_vmxml.remove_vm_devices_by_type(vm, 'memory') vm_attrs = eval(params.get('vm_attrs', '{}')) vmxml = vm_xml.VMXML.new_from_dumpxml(vm_name) @@ -89,7 +85,8 @@ def run_test_virtio_mem(): test.log.debug("VM's memory before updating requested size: %s", vm_mem_before) - test.log.info("TEST_STEP1: Update requested size for virtio-mem device.") + test.log.info( + "TEST_STEP1: Update requested size for virtio-mem device.") vmxml_cur = vm_xml.VMXML.new_from_dumpxml(vm_name) mem_dev = vmxml_cur.devices.by_device_tag("memory")[0] mem_dev_alias = mem_dev.fetch_attrs()['alias']['name'] @@ -114,7 +111,8 @@ def run_test_virtio_mem(): test.log.info("TEST_STEP3: Check 'MEMORY_DEVICE_SIZE_CHANGE' in " "libvirtd/virtqemud log") log_file = utils_misc.get_path(test.debugdir, "libvirtd.log") - check_log_str = params.get("check_log_str", "MEMORY_DEVICE_SIZE_CHANGE") + check_log_str = params.get( + "check_log_str", "MEMORY_DEVICE_SIZE_CHANGE") libvirt.check_logfile(check_log_str, log_file) test.log.info("TEST STEP4: Check memory in the VM.") @@ -131,9 +129,6 @@ def cleanup_test_virtio_mem(): """ Clean up environment """ - if utils_memory.get_num_huge_pages() != ORG_HP: - utils_memory.set_num_huge_pages(ORG_HP) - # Variable assignment test_case = params.get('test_case', '')