-
Notifications
You must be signed in to change notification settings - Fork 172
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
virtio_fs_supp_group_transfer: add a new test case
Signed-off-by: Houqi (Nick) Zuo <[email protected]>
- Loading branch information
Showing
2 changed files
with
131 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
- virtio_fs_supp_group_transfer: | ||
type = virtio_fs_supp_group_transfer | ||
only Linux | ||
virt_test_type = qemu | ||
required_qemu = [4.2.0,) | ||
s390, s390x: | ||
required_qemu = [5.2.0,) | ||
vm_mem_share = yes | ||
pre_command_noncritical = yes | ||
pre_command = "echo 3 > /proc/sys/vm/drop_caches" | ||
setup_hugepages = yes | ||
kvm_module_parameters = 'hpage=1' | ||
expected_hugepage_size = 1024 | ||
clone_master = yes | ||
master_images_clone = image1 | ||
remove_image_image1 = yes | ||
kill_vm = yes | ||
start_vm = yes | ||
filesystems = fs | ||
fs_driver = virtio-fs | ||
force_create_fs_source = yes | ||
remove_fs_source = yes | ||
fs_target = 'myfs' | ||
fs_driver_props = {"queue-size": 1024} | ||
mem = 4096 | ||
mem_devs = mem1 | ||
backend_mem_mem1 = memory-backend-file | ||
mem-path_mem1 = /dev/shm | ||
size_mem1 = 4G | ||
use_mem_mem1 = no | ||
share_mem = yes | ||
!s390, s390x: | ||
guest_numa_nodes = shm0 | ||
numa_memdev_shm0 = mem-mem1 | ||
numa_nodeid_shm0 = 0 | ||
io_timeout = 600 | ||
fs_dest = '/mnt/${fs_target}' | ||
new_guest_user = "user00001" | ||
add_user_cmd = "useradd %s" | ||
del_user_cmd = "userdel -r -f %s" | ||
fs_enable_debug_mode = yes | ||
fs_source_dir = ${fs_dest}/virtio_fs_test/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
from virttest import env_process | ||
from virttest import error_context, utils_disk, utils_misc | ||
|
||
from provider import virtio_fs_utils | ||
|
||
|
||
@error_context.context_aware | ||
def run(test, params, env): | ||
""" | ||
Grant write access at users allowed by group permission | ||
on shared dir( linux only ) | ||
1) Run the virtiofsd daemon on the host and Set log level to "debug". | ||
2) Boot a guest on the host. | ||
3) Log into guest with root, then mount the file system. | ||
4) In the guest, add a new user(u1) | ||
and set the user to the wheel group (as supplementary group) | ||
and set the dir's group to 'wheel' | ||
5) In guest, using root to create a test directory at the shared dir. | ||
6) Run the basic io test with the u1 user | ||
7) After test, clear the environment. | ||
:param test: QEMU test object | ||
:param params: Dictionary with the test parameters | ||
:param env: Dictionary with test environment | ||
""" | ||
add_user_cmd = params.get("add_user_cmd") | ||
del_user_cmd = params.get("del_user_cmd") | ||
username = params.get("new_guest_user") | ||
fs_dest = params.get("fs_dest") | ||
fs_target = params.get("fs_target") | ||
|
||
testdir = "testdir" | ||
guest_root_session = None | ||
guest_user_session = None | ||
|
||
try: | ||
# create the share dir before daemon running | ||
shared_dir = params.get("fs_source_dir") | ||
|
||
params["start_vm"] = "yes" | ||
env_process.preprocess_vm(test, params, env, params["main_vm"]) | ||
vm = env.get_vm(params.get("main_vm")) | ||
vm.verify_alive() | ||
guest_root_session = vm.wait_for_login() | ||
|
||
error_context.context("Create a destination directory %s " | ||
"inside guest." % fs_dest, test.log.info) | ||
if not utils_misc.make_dirs(fs_dest, session=guest_root_session): | ||
test.fail("Creating directory was failed!") | ||
error_context.context("Mount virtiofs target %s to %s inside" | ||
" guest." % (fs_target, fs_dest), | ||
test.log.info) | ||
if not utils_disk.mount(fs_target, fs_dest, 'virtiofs', | ||
session=guest_root_session): | ||
test.fail('Mount virtiofs target failed.') | ||
|
||
guest_root_session.cmd(add_user_cmd % username) | ||
guest_root_session.cmd("usermod -G wheel %s" % username) | ||
|
||
guest_root_session.cmd("cd %s && mkdir -m 770 %s" % (fs_dest, testdir)) | ||
guest_root_session.cmd("cd %s && chgrp wheel %s" % (fs_dest, testdir)) | ||
params["fs_dest"] = fs_dest + "/" + testdir | ||
params["fs_source_dir"] = shared_dir[:-1] + "/" + testdir | ||
|
||
try: | ||
guest_user_session = vm.wait_for_login() | ||
guest_user_session.cmd("su %s" % username) | ||
virtio_fs_utils.basic_io_test(test, params, guest_user_session) | ||
except Exception: | ||
guest_user_session = None | ||
finally: | ||
if guest_user_session: | ||
guest_user_session.close() | ||
if guest_root_session: | ||
params["fs_dest"] = fs_dest | ||
params["fs_source_dir"] = shared_dir | ||
|
||
output = guest_root_session.cmd_output(del_user_cmd % username) | ||
if "is currently used by process" in output: | ||
error_context.context("Kill process before delete user...", | ||
test.log.info) | ||
pid = output.split(" ")[-1] | ||
guest_root_session.cmd_output("kill -9 %s" % pid) | ||
guest_root_session.cmd("rm -rf /home/%s" % username) | ||
|
||
guest_root_session.cmd("rm -rf %s" % (fs_dest + "/" + testdir)) | ||
|
||
guest_root_session.close() |