Skip to content

Commit

Permalink
Resolve memory attachment & update issues
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
Aakanksha Tripathi committed Oct 18, 2023
1 parent 0732f90 commit b18852a
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 16 deletions.
3 changes: 1 addition & 2 deletions libvirt/tests/cfg/memory/memory_attach_device.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,11 @@
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'}]}}
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': 52488}}
5 changes: 2 additions & 3 deletions libvirt/tests/cfg/memory/memory_update_device.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,14 @@
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'}]}}
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}"
9 changes: 4 additions & 5 deletions libvirt/tests/src/memory/memory_attach_device.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -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)
Expand All @@ -77,11 +75,14 @@ def run_test_virtio_mem():
mem_device_attrs = eval(params.get('mem_device_attrs', '{}'))
mem_device = Memory()
mem_device.setup_attrs(**mem_device_attrs)
if params.get("start_vm") == "yes":
time.sleep(30)

test.log.info("TEST_STEP1: Attach a virtio-mem device.")
options = '' if vm.is_alive() else '--config'
virsh.attach_device(vm_name, mem_device.xml, flagstr=options,
debug=True, ignore_status=False)
time.sleep(30)

if not vm.is_alive():
vm.start()
Expand Down Expand Up @@ -111,8 +112,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', '')
Expand Down
10 changes: 4 additions & 6 deletions libvirt/tests/src/memory/memory_update_device.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import re
import time

from virttest import libvirt_version
from virttest import utils_misc
Expand Down Expand Up @@ -59,10 +60,7 @@ 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)
Expand All @@ -88,6 +86,8 @@ def run_test_virtio_mem():
vm_mem_before = int(re.findall(r'Mem:\s+(\d+)\s+\d+\s+', cmdRes)[-1])
test.log.debug("VM's memory before updating requested size: %s",
vm_mem_before)
if params.get("start_vm") == "yes":
time.sleep(30)

test.log.info("TEST_STEP1: Update requested size for virtio-mem device.")
vmxml_cur = vm_xml.VMXML.new_from_dumpxml(vm_name)
Expand Down Expand Up @@ -131,8 +131,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', '')
Expand Down

0 comments on commit b18852a

Please sign in to comment.