From 748dfab4ef4b2fe441808f5ad849d8d9ee726d6e Mon Sep 17 00:00:00 2001 From: Yumei Huang Date: Thu, 4 Jun 2020 17:40:55 +0800 Subject: [PATCH] nvdimm_mode: Add new case to test change nvdimm mode inside guest Signed-off-by: Yumei Huang --- qemu/tests/cfg/nvdimm.cfg | 17 +++++++++++++++++ qemu/tests/nvdimm_mode.py | 35 +++++++++++++++++++++++++++++++++++ 2 files changed, 52 insertions(+) create mode 100644 qemu/tests/nvdimm_mode.py diff --git a/qemu/tests/cfg/nvdimm.cfg b/qemu/tests/cfg/nvdimm.cfg index 852e6919..abf153da 100644 --- a/qemu/tests/cfg/nvdimm.cfg +++ b/qemu/tests/cfg/nvdimm.cfg @@ -66,3 +66,20 @@ check_command = "grep -A21 '${nv_backend}' /proc/%s/smaps" clean_command = "rm -rf ${mount_dir}/${nv_backend} && umount ${mount_dir} && rm -rf ${mount_dir}" start_vm = no + - nvdimm_mode: + type = nvdimm_mode + mem_devs = mem1 mem2 + mem-path_mem1 = /tmp/test1.img + mem-path_mem2 = /tmp/test2.img + align_mem1 = 128M + align_mem2 = 128M + dimm_extra_params = "label-size=2M" + pre_command = "dd if=/dev/zero of=${mem-path_mem1} bs=1M count=1024" + pre_command += "; dd if=/dev/zero of=${mem-path_mem2} bs=1M count=1024" + post_command = "rm -rf ${mem-path_mem1} ${mem-path_mem2}" + create_dax_cmd = "ndctl create-namespace -m dax -e namespace%s.0 -f -v -a 4096" + ndctl_check_cmd = "ndctl list" + del mount_dir + del dev_path + del format_command + del mount_command diff --git a/qemu/tests/nvdimm_mode.py b/qemu/tests/nvdimm_mode.py new file mode 100644 index 00000000..9af2005c --- /dev/null +++ b/qemu/tests/nvdimm_mode.py @@ -0,0 +1,35 @@ +from virttest import utils_package +from virttest import error_context + + +@error_context.context_aware +def run(test, params, env): + """ + Run nvdimm cases: + 1) Boot guest with two nvdimm devices + 2) Change the two nvdimm devices to dax mode inside guest + 3) Check if both devices are dax mode + + :param test: QEMU test object + :param params: Dictionary with the test parameters + :param env: Dictionary with test environment. + """ + vm = env.get_vm(params["main_vm"]) + vm.verify_alive() + session = vm.wait_for_login() + if not utils_package.package_install("ndctl", session): + test.cancel("Please install ndctl inside guest to proceed") + create_dax_cmd = params["create_dax_cmd"] + nvdimm_number = len(params["mem_devs"].split()) + try: + for i in range(nvdimm_number): + session.cmd(create_dax_cmd % i) + output = session.cmd_output(params["ndctl_check_cmd"]) + output = eval(output) + for item in output: + if item['mode'] != 'devdax': + test.fail("Change both nvdimm to dax mode failed") + finally: + utils_package.package_remove("ndctl", session) + session.close() + vm.destroy() -- GitLab