diff --git a/qemu/tests/cfg/nvdimm.cfg b/qemu/tests/cfg/nvdimm.cfg index 3e9dbc99d2e5a906dd417f0e0cd345cd07e0183d..852e69190e073d624b2e4e34f01fd306f7727fd2 100644 --- a/qemu/tests/cfg/nvdimm.cfg +++ b/qemu/tests/cfg/nvdimm.cfg @@ -53,3 +53,16 @@ ndctl_install_cmd = "rpm -q ndctl || yum install -y ndctl" create_dax_cmd = "ndctl create-namespace -m dax -e namespace0.0 -f -v -a 4096" del_dax_cmd = "ndctl create-namespace -m memory -e namespace0.0 -f -v -a 4096" + - nvdimm_mapsync: + type = nvdimm_mapsync + no Host_RHEL.m7 + pmem_mem = on + nv_backend = nvdimm0 + mount_dir = "/mnt/pmem" + mem-path = "${mount_dir}/${nv_backend}" + format_command = "mkfs.xfs -f ${dev_path} -m reflink=0" + mount_command = "mkdir -p ${mount_dir} && mount -o dax ${dev_path} ${mount_dir}" + truncate_command = "truncate -s ${size_mem} ${mount_dir}/${nv_backend}" + 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 diff --git a/qemu/tests/nvdimm_mapsync.py b/qemu/tests/nvdimm_mapsync.py new file mode 100644 index 0000000000000000000000000000000000000000..eada6c459ace876d0214ecf403e89afac3a535cd --- /dev/null +++ b/qemu/tests/nvdimm_mapsync.py @@ -0,0 +1,57 @@ +import re +import os +import pathlib + +from avocado.utils import process + +from virttest import env_process +from virttest import error_context + + +@error_context.context_aware +def run(test, params, env): + """ + Run nvdimm cases: + 1) Mount nvdimm device on host + 2) Create a file in the mount point + 3) Boot guest with nvdimm backed by the file + 4) Check flag 'sf' is present in qemu smaps + + :param test: QEMU test object + :param params: Dictionary with the test parameters + :param env: Dictionary with test environment. + """ + dev_path = params["dev_path"] + p = pathlib.Path(dev_path) + if not p.is_block_device(): + test.error("There is no nvdimm device in host, please add kernel param" + "'memmap' to emulate one") + + format_cmd = params["format_command"] + mount_cmd = params["mount_command"] + truncate_cmd = params["truncate_command"] + check_cmd = params["check_command"] + clean_cmd = params["clean_command"] + try: + process.run(format_cmd) + process.run(mount_cmd, shell=True) + process.run(truncate_cmd) + except Exception as e: + test.error(e) + else: + try: + params["start_vm"] = "yes" + env_process.preprocess_vm(test, params, env, params['main_vm']) + vm = env.get_vm(params["main_vm"]) + vm.verify_alive() + vm.wait_for_login() + vm_pid = vm.get_pid() + + output = process.system_output(check_cmd % vm_pid).decode() + if 'sf' not in re.findall('(?:VmFlags: )(.*)', output)[0].split(): + test.fail("Flag 'sf' is not present in smaps file") + finally: + vm.destroy() + finally: + if os.path.ismount(params["mount_dir"]): + process.run(clean_cmd, shell=True)