未验证 提交 1cfba46a 编写于 作者: B Balamuruhan S 提交者: GitHub

Merge pull request #1178 from huangyum/numa_1503402

numa_basic: Check node free memory before test
import logging
from autotest.client.shared import error
from virttest import env_process
from virttest import utils_misc
from virttest import utils_test
from virttest import error_context
from virttest.staging import utils_memory
@error.context_aware
@error_context.context_aware
def run(test, params, env):
"""
Qemu numa basic test:
......@@ -23,24 +22,28 @@ def run(test, params, env):
:param params: Dictionary with the test parameters
:param env: Dictionary with test environment.
"""
error.context("Get host numa topological structure", logging.info)
error_context.context("Get host numa topological structure", logging.info)
timeout = float(params.get("login_timeout", 240))
host_numa_node = utils_misc.NumaInfo()
node_list = host_numa_node.online_nodes
for node_id in node_list:
error.base_context("Bind qemu process to numa node %s" % node_id,
logging.info)
error_context.base_context("Bind qemu process to numa node %s" % node_id,
logging.info)
vm = "vm_bind_to_%s" % node_id
params['qemu_command_prefix'] = "numactl --cpunodebind=%s" % node_id
utils_memory.drop_caches()
node_MemFree = int(host_numa_node.read_from_node_meminfo(node_id,
"MemFree"))
if node_MemFree < int(params["mem"]) * 1024:
test.cancel("No enough free memory in node %d." % node_id)
env_process.preprocess_vm(test, params, env, vm)
vm = env.get_vm(vm)
vm.verify_alive()
session = vm.wait_for_login(timeout=timeout)
session.close()
error.context("Check the memory use status of qemu process",
logging.info)
error_context.context("Check the memory use status of qemu process",
logging.info)
memory_status, _ = utils_test.qemu.get_numa_status(host_numa_node,
vm.get_pid())
node_used_most = 0
......@@ -52,9 +55,7 @@ def run(test, params, env):
logging.debug("Qemu used %s pages in node"
" %s" % (memory_status[index], node_list[index]))
if node_used_most != node_id:
raise error.TestFail("Qemu still use memory from other node."
" Expect: %s, used: %s" % (node_id,
node_used_most))
error.context("Destroy guest.", logging.info)
test.fail("Qemu still use memory from other node. "
"Expect: %s, used: %s" % (node_id, node_used_most))
error_context.context("Destroy guest.", logging.info)
vm.destroy()
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册