未验证 提交 045ec71b 编写于 作者: Y Yanan Fu 提交者: GitHub

Merge pull request #2214 from huangyum/map_sync

nvdimm_mapsync: add new case to test MAP_SYNC
......@@ -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
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)
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册