diff --git a/libvirt/tests/cfg/numa/numa_node_tuning/invalid_nodeset_of_numa_memory_binding.cfg b/libvirt/tests/cfg/numa/numa_node_tuning/invalid_nodeset_of_numa_memory_binding.cfg new file mode 100644 index 0000000000..0ce7b99310 --- /dev/null +++ b/libvirt/tests/cfg/numa/numa_node_tuning/invalid_nodeset_of_numa_memory_binding.cfg @@ -0,0 +1,25 @@ +- guest_numa_node_tuning.invalid_nodeset: + type = invalid_nodeset_of_numa_memory_binding + start_vm = "no" + error_msg = "error: unsupported configuration: NUMA node 2 is unavailable" + variants tuning: + - strict: + tuning_mode = "strict" + - interleave: + tuning_mode = "interleave" + - preferred: + tuning_mode = "preferred" + - restrictive: + tuning_mode = "restrictive" + variants node_set: + - partially_inexistent: + nodeset = "1-2" + - totally_inexistent: + nodeset = "2-3" + variants binding: + - host: + vm_attrs = {'numa_memory': {'mode': "${tuning_mode}",'nodeset': "${nodeset}"}} + - guest: + cell_id = 0 + numa_attr = "'cpu': {'numa_cell': [{'id': ${cell_id}, 'cpus': '0-1', 'memory': '2097152', 'unit': 'KiB'}]}" + vm_attrs = {${numa_attr},'numa_memnode': [{'cellid':"${cell_id}",'mode': "${tuning_mode}",'nodeset':"${nodeset}"}]} diff --git a/libvirt/tests/src/numa/numa_node_tuning/invalid_nodeset_of_numa_memory_binding.py b/libvirt/tests/src/numa/numa_node_tuning/invalid_nodeset_of_numa_memory_binding.py new file mode 100644 index 0000000000..b4afb61e55 --- /dev/null +++ b/libvirt/tests/src/numa/numa_node_tuning/invalid_nodeset_of_numa_memory_binding.py @@ -0,0 +1,70 @@ +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# Copyright Redhat +# +# SPDX-License-Identifier: GPL-2.0 + +# Author: Nan Li +# +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +import re + +from virttest import virt_vm + +from virttest.libvirt_xml import vm_xml + + +def run(test, params, env): + """ + Verify that error msg prompts when starting a guest vm with + invalid nodeset of numa memory binding + """ + + def setup_test(): + """ + Prepare init xml + """ + test.log.info("TEST_SETUP: Set hugepage and guest boot ") + vmxml = vm_xml.VMXML.new_from_dumpxml(vm_name) + vmxml.setup_attrs(**vm_attrs) + vmxml.sync() + + vmxml = vm_xml.VMXML.new_from_dumpxml(vm_name) + test.log.debug("The init xml is:\n%s", vmxml) + + def run_test(): + """ + Start vm and check result + """ + test.log.info("TEST_STEP1: Start vm and check result") + try: + vm.start() + if vm.is_alive(): + test.fail("Guest state should not be running") + except virt_vm.VMStartError as detail: + if not re.search(error_msg, str(detail)): + test.fail("Expect '%s' in '%s' " % (error_msg, str(detail))) + else: + test.log.debug("Got '%s' in '%s'" % (error_msg, detail)) + + def teardown_test(): + """ + Clean data. + """ + test.log.info("TEST_TEARDOWN: Clean up env.") + bkxml.sync() + + vm_name = params.get("main_vm") + vm = env.get_vm(vm_name) + vmxml = vm_xml.VMXML.new_from_inactive_dumpxml(vm_name) + bkxml = vmxml.copy() + + vm_attrs = eval(params.get("vm_attrs")) + error_msg = params.get("error_msg") + + try: + setup_test() + run_test() + + finally: + teardown_test()