Skip to content

Commit

Permalink
Merge pull request #5028 from nanli1/fix_memory_libvirt_version_issue
Browse files Browse the repository at this point in the history
fix memory case libvirt version issue
  • Loading branch information
chloerh authored Jul 26, 2023
2 parents 02aae6c + 538ea2e commit 6bad85f
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
- mam_memory:
vm_attrs = {'max_mem_rt': ${value}, 'max_mem_rt_slots': ${max_mem_slots}, 'max_mem_rt_unit': "${max_mem_unit}",'memory_unit':"${mem_unit}",'memory':${mem_value},'current_mem':${current_mem},'current_mem_unit':'${current_mem_unit}','vcpu': 4,'cpu': {'numa_cell': [{'id': '0', 'cpus': '0-1', 'memory': '${numa_mem}', 'unit': 'KiB'},{'id':'1','cpus': '2-3','memory':'${numa_mem}','unit':'KiB'}]}}
error_msg = "both maximum memory size and memory slot count must be specified"
error_msg_2 = "maximum memory size must be specified when specifying number of memory slot"
status_error = "yes"
- numa:
xpaths_list = [{'element_attrs':[".//cell[@id='0']"]}, {'element_attrs':[".//memory[@unit='${mem_unit}']"], 'text':'${numa_mem}'}, {'element_attrs':[".//currentMemory[@unit='${current_mem_unit}']"], 'text':'${numa_mem}'}]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import os

from virttest import virsh
from virttest import libvirt_version
from virttest import utils_libvirtd

from virttest.libvirt_xml import vm_xml
Expand Down Expand Up @@ -121,7 +122,10 @@ def check_qemu_cmdline():
"""
expected_str = ""
if mem_config == "without_maxmemory":
expected_str = r"-m %s" % str(int(mem_value/1024))
if libvirt_version.version_compare(9, 5, 0):
expected_str = r"-m size=%sk" % mem_value
else:
expected_str = r"-m %s" % str(int(mem_value/1024))
elif mem_config == "with_numa":
expected_str = r"-m size=%dk,slots=%d,maxmem=%dk" % (
int(mem_value), max_mem_slots, int(max_mem))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,12 @@ def run_test():
if num == "minus":
libvirt.check_result(cmd_result, minus_error_msg)
elif num == "zero":
if error_msg:
if mem_config == "mam_memory":
if libvirt_version.version_compare(9, 5, 0):
libvirt.check_result(cmd_result, error_msg_2)
else:
libvirt.check_result(cmd_result, error_msg)
elif mem_config == "memory":
libvirt.check_result(cmd_result, error_msg)
else:
test.log.info("TEST_STEP2: Check xml after define")
Expand All @@ -54,14 +59,14 @@ def check_mem_config():
Check current mem device config
"""
vmxml = vm_xml.VMXML.new_from_inactive_dumpxml(vm_name)
test.log.debug('111111111111111111111:%s', vmxml)
libvirt_vmxml.check_guest_xml_by_xpaths(vmxml, xpaths_list)

vm_name = params.get("main_vm")
vmxml = vm_xml.VMXML.new_from_inactive_dumpxml(vm_name)
bkxml = vmxml.copy()

error_msg = params.get("error_msg", "")
error_msg_2 = params.get("error_msg_2", "")
minus_error_msg = params.get("minus_error_msg", "")
start_error_msg = params.get("start_error_msg", "")

Expand Down

0 comments on commit 6bad85f

Please sign in to comment.