Skip to content

Commit

Permalink
Merge pull request #4967 from nanli1/add_case_for_invalid_nodeset_of_…
Browse files Browse the repository at this point in the history
…numa_memory_binding

numa: add case for invalid nodeset of numa memory binding
  • Loading branch information
Yingshun committed Jul 4, 2023
2 parents 290fd12 + cd9fd2d commit 94fd119
Show file tree
Hide file tree
Showing 2 changed files with 95 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -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}"}]}
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#
# Copyright Redhat
#
# SPDX-License-Identifier: GPL-2.0

# Author: Nan Li <[email protected]>
#
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
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()

0 comments on commit 94fd119

Please sign in to comment.